-
Notifications
You must be signed in to change notification settings - Fork 1
/
2ndpagelike.php
429 lines (338 loc) · 10.3 KB
/
2ndpagelike.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
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en">
<![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en">
<![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<title>迷你市集</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<!--
Concept Template
http://www.templatemo.com/preview/templatemo_397_concept
-->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="UTF-8">
<link rel='stylesheet' href='style.css' media='screen' />
<!-- CSS Bootstrap & Custom -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/animate.css">
<link rel="stylesheet" href="css/font-awesome.min.css">
<link rel="stylesheet" href="css/templatemo_misc.css">
<!-- Main CSS -->
<link rel="stylesheet" href="css/templatemo_style.css">
<!-- Favicons -->
<link rel="shortcut icon" href="images/logo.png">
<!--<link rel="shortcut icon" href="images/ico/favicon.ico">-->
<!-- like button style css-->
<style>
.loading {
padding:3px 7px;
text-align:center;
line-height:16px;
}
.like {
display:inline-block;
padding:3px 7px;
margin-right:5px;
background:#33cccc;
color:#fff;
font:bold 12px Tahoma;
text-align:center;
line-height:16px;
}
.like span {
display:inline-block;
border-left:1px solid #eee;
padding-left:4px;
}
.liked {
display:inline-block;
padding:3px 7px;
margin-right:5px;
background:#ddd;
color:#888;
font:bold 12px Tahoma;
text-align:center;
line-height:16px;
}
.liked span {
display:inline-block;
border-left:1px solid #eee;
padding-left:4px;
}
</style>
<!-- like button js-->
<!-- <script type="text/javascript" src="js/function.js"></script> -->
<script type="text/javascript" src="js/jquery.min.js"></script>
<script>
$(function() {
$(".like").click(function() {
var item_id = $(this).attr("id");
var dataString = 'item_id='+item_id;
$('a#'+item_id).removeClass('like');
$('a#'+item_id).html('<img src="images/loader.gif" class="loading" />');
$.ajax({
type: "POST",
url: "ajax.php",
data: dataString,
cache: false,
success: function(data){
if (data == 0) {
alert('you have liked this quote before');
} else {
$('a#'+item_id).addClass('liked');
$('a#'+item_id).html(data);
}
}
});
return false;
});
});
</script>
<!-- like button js-->
<!-- <script src="jquery.min.js"></script> -->
<!--[if lt IE 9]>
<script src="../html5.js"></script>
<![endif]-->
<script src="blocksit.min.js"></script>
<script>
$(document).ready(function() {
//vendor script
$('#header')
.css({ 'top':-40 })
.delay(1000)
.animate({'top': 0}, 800);
$('#footer')
.css({ 'bottom':-15 })
.delay(1000)
.animate({'bottom': 0}, 800);
//blocksit define
$(window).load( function() {
$('#container').BlocksIt({
numOfCol: 4,
offsetX: 4,
offsetY: 8
});
});
//window resize
var currentWidth = 1100;
$(window).resize(function() {
var winWidth = $(window).width();
var conWidth;
if(winWidth < 660) {
conWidth = 440;
col = 2
} else if(winWidth < 880) {
conWidth = 660;
col = 3
} else if(winWidth <= 1100) {
conWidth = 880;
col = 4;
} else {
conWidth = 1100;
col = 5;
}
if(conWidth != currentWidth) {
currentWidth = conWidth;
$('#container').width(conWidth);
$('#container').BlocksIt({
numOfCol: col,
offsetX: 4,
offsetY: 8
});
}
});
});
</script>
</head>
<body>
<?php
/* require('test/bookmark_fns.php'); */
include('test/output_fns.php');
require_once('test/data_valid_fns.php');
require_once('test/db_fns.php');
require_once('test/user_auth_fns.php');
require_once('test/url_fns.php');
session_start();
//do_html_header();
?>
<div class="site-header">
<div class="main-navigation">
<div class="container">
<!--<div class="row">-->
<div class="col-md-12 main_menu" >
<ul style="display: inline">
<li style="float: left !important "><a href="http://youyouyou.co" target="_self"><img src="images/logow.png" ?></a> </li>
<li ><a href="http://youyouyou.co/new1stpage.php" target="_self">Gallery</a></li>
<li><a href="http://youyouyou.co/2ndpagelike.php" target="_self">Mini Market</a></li>
<li><a href="http://youyouyou.co/forum/forum.php" target="_self">Forum</a></li>
<!--<li><a href="http://youyouyou.co/4thpage.php" target="_self">关于</a></li>-->
<!-- <li><a href="http://youyouyou.co/5thpage.php" target="_self">联系</a></li> -->
<?php
if(isset($_SESSION[ 'valid_user'])) {
?>
<li style="float:right; margin-left: 30px; !important"><a href="http://youyouyou.co/3rdpage.php" target="_self"> <?php echo $_SESSION[ 'valid_user'] ?>的小屋 </a> <a href="test/logout.php">Logout</a> </li>
<?php }
else { ?>
<li style="float:right; margin-left: 30px;" ><a href="http://youyouyou.co/test/login.php" target="_self">Login / Sign Up</a></li>
<?php } ?>
</ul>
</div> <!-- /.col-md-12 -->
<!--</div> /.row -->
</div> <!-- /.container -->
</div>
<div class="container">
<div class="row">
<div class="col-md-12 text-center">
<br / >
<a href="#" class="templatemo_logo">
<h1>迷你市集</h1>
</a> <!-- /.logo -->
</div> <!-- /.col-md-12 -->
</div> <!-- /.row -->
</div> <!-- /.container -->
</div> <!-- /.site-header -->
<p style="text-align:center; font-size:18px; color: #33CCCC">
在在这里钉上你认为值得分享的物品,再看看大家都在谈论什么 </p>
<!-- Header -->
<!-- like button functions -->
<?php
function get_real_ip()
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
{
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
$ip=$_SERVER['REMOTE_ADDR'];
}
return $ip;
}
function check_ip($item_id,$ip) {
global $conn;
$query = "SELECT * FROM likes WHERE item_id='$item_id' AND ip='$ip' LIMIT 1";
$result = $conn->query($query);
$likes = $result->num_rows;
return $likes;
}
function likes($item_id) {
global $conn;
$query = "SELECT * FROM likes WHERE item_id='$item_id'";
$result = $conn->query($query);
$likes = $result->num_rows;
return $likes;
}
?>
<!-- like button functions -->
<!-- Content -->
<section id="wrapper">
<?php
$conn = db_connect();
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT `id` FROM `product`";
$result = $conn->query($sql);
$idArray = Array();
if ($result->num_rows > 0) {
// output data of each row
while($row = $result-> fetch_array()) {
$idArray[] = $row["id"];
}
} else {
echo "0 results";
}
?>
<div id="container">
<?php
for($i=0; $i< count($idArray); $i++){ ?>
<div class="grid">
<div class="imgholder">
<a href="http://youyouyou.co/comment.php?product=<?php echo $idArray[$i] ?>" target="_self"> <img src="images/products/<?php echo $idArray[$i] ?>.jpg" /> </a>
</div>
<?php
$sql = "SELECT title FROM product WHERE id = '$idArray[$i]'";
$r = $conn->query($sql);
if ($r->num_rows > 0) {
// output data of each row
while($row = $r->fetch_assoc()) {
$title = $row["title"] ;
}
} else {
echo "0 results";
}
$sql2 = "SELECT description FROM product WHERE id ='$idArray[$i]'";
$r2 = $conn->query($sql2);
if ($r2->num_rows > 0) {
// output data of each row
while($row2 = $r2->fetch_assoc()) {
$description = $row2["description"] ;
}
} else {
echo "0 results";
}
?>
<strong> <?php echo $title ?> </strong>
<p> <?php echo $description ?> </p>
<?php
$sql = "SELECT `like` FROM product WHERE id = '$idArray[$i]'";
$r = $conn->query($sql);
if ($r->num_rows > 0) {
// output data of each row
while($row = $r->fetch_assoc()) {
$like = $row["like"] ;
}
} else {
echo "0 results";
}
?>
<!-- like button-->
<?php if (check_ip($idArray[$i],get_real_ip()) == 0) { ?>
<a href="javascript:void();" class="like" id="<?php echo $idArray[$i]; ?>">Like <span><?php echo likes($idArray[$i]); ?></span></a>
<?php } else { ?>
<a href="javascript:void();" class="liked">Liked <span><?php echo likes($idArray[$i]); ?></span></a>
<?php } ?>
<!-- like button -->
<!-- collect button-->
<input type="button" value="Collect" class="btn btn-collect" id="btn-collect">
<!-- collect-->
<?php
$sql = "SELECT owner FROM product WHERE id = '$idArray[$i]'";
$r = $conn->query($sql);
if ($r->num_rows > 0) {
// output data of each row
while($row = $r->fetch_assoc()) {
$owner = $row["owner"] ;
}
} else {
echo "0 results";
}
?>
<div class="meta">by <?php echo '<a href="http://youyouyou.co/member.php?user='.$owner.'">'.$owner.'</a>'; ?>
</div>
</div> <!-- class='grid' -->
<?php } ?> <!-- for -->
</div> <!-- id="container" -->
<?php $conn->close(); ?>
</section>
<div id="templatemo_footer">
<div class="container">
<div class="row">
<div class="col-md-12 text-center">
<p style="text-align: right"><a href="http://youyouyou.co/5thpage.php" class="btn_2"> 联系我们 </a></p>
<p style="text-align: left">Copyright © 2015 Handsome Four</p>
</div> <!-- /.col-md-12 -->
</div> <!-- /.row -->
</div> <!-- /.container -->
</div> <!-- /.templatemo_footer -->
</body>
</html>