Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
s_ibanshou
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋林
s_ibanshou
Commits
ba647f58
Commit
ba647f58
authored
Jul 07, 2017
by
蒋林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
点赞
parent
ffae9a80
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
113 additions
and
20 deletions
+113
-20
comment.php
e/action/news/comment.php
+4
-14
index.php
e/action/news/index.php
+69
-0
q_functions.php
e/class/q_functions.php
+9
-0
news.js
skin/default/js/news.js
+31
-6
No files found.
e/
pl/comments
.php
→
e/
action/news/comment
.php
View file @
ba647f58
<?php
<?php
require
(
"
../class/connect.php"
);
require
(
__DIR__
.
"/../
../class/connect.php"
);
require
(
"
../class/db_sql.php"
);
require
(
__DIR__
.
"/../
../class/db_sql.php"
);
require
(
"
../member/class/user.php"
);
require
(
__DIR__
.
"/../
../member/class/user.php"
);
require
(
"
../class/q_functions.php"
);
require
(
__DIR__
.
"/../
../class/q_functions.php"
);
$link
=
db_connect
();
$link
=
db_connect
();
$empire
=
new
mysqlquery
();
$empire
=
new
mysqlquery
();
...
@@ -216,13 +216,3 @@ function handelcomment($comment) {
...
@@ -216,13 +216,3 @@ function handelcomment($comment) {
$comment
[
'created_at'
]
=
date
(
'Y-m-d H:i'
,
$comment
[
'created_at'
]);
$comment
[
'created_at'
]
=
date
(
'Y-m-d H:i'
,
$comment
[
'created_at'
]);
return
$comment
;
return
$comment
;
}
}
\ No newline at end of file
function
returnmsg
(
$status
=
false
,
$msg
=
''
,
$data
=
''
)
{
$return
[
'status'
]
=
$status
?
true
:
false
;
$return
[
'msg'
]
=
$msg
;
$return
[
'data'
]
=
$data
;
echo
json_encode
(
$return
,
JSON_UNESCAPED_UNICODE
);
exit
();
}
\ No newline at end of file
e/action/news/index.php
0 → 100644
View file @
ba647f58
<?php
require
(
__DIR__
.
"/../../class/connect.php"
);
require
(
__DIR__
.
"/../../class/db_sql.php"
);
require
(
__DIR__
.
"/../../member/class/user.php"
);
require
(
__DIR__
.
"/../../class/q_functions.php"
);
$link
=
db_connect
();
$empire
=
new
mysqlquery
();
$user
=
islogin
();
if
(
empty
(
$user
))
{
returnmsg
(
false
,
'请登录'
);
}
$mod
=
isset
(
$_GET
[
'mod'
])
?
$_GET
[
'mod'
]
:
''
;
$newsid
=
isset
(
$_POST
[
'newsid'
])
?
intval
(
$_POST
[
'newsid'
])
:
0
;
if
(
!
$newsid
)
{
returnmsg
(
false
,
'内容ID参数错误'
);
}
if
(
$mod
==
'diggtop'
)
{
diggtop
(
$newsid
,
$user
);
}
elseif
(
$mod
==
'checkdiggtop'
)
{
checkdiggtop
(
$newsid
,
$user
);
}
function
checkdiggtop
(
$newsid
,
$user
)
{
global
$empire
,
$dbtbpre
;
$tablenewsdiggtop
=
$dbtbpre
.
'ecms_news_diggtop'
;
$sql
=
"select * from
{
$tablenewsdiggtop
}
where user_id=
{
$user
[
'userid'
]
}
and news_id=
{
$newsid
}
"
;
$newsdiggtop
=
$empire
->
fetch1
(
$sql
);
if
(
$newsdiggtop
)
{
returnmsg
(
true
,
'已赞'
);
}
else
{
returnmsg
(
false
);
}
}
function
diggtop
(
$newsid
,
$user
)
{
global
$empire
,
$dbtbpre
;
$tablenews
=
$dbtbpre
.
'ecms_news'
;
$tablenewsdiggtop
=
$dbtbpre
.
'ecms_news_diggtop'
;
$sql
=
"select id,classid,userid from
{
$tablenews
}
where id=
{
$newsid
}
"
;
$news
=
$empire
->
fetch1
(
$sql
);
if
(
empty
(
$news
))
{
returnmsg
(
false
,
'该内容不存在'
);
}
$sql
=
"select * from
{
$tablenewsdiggtop
}
where user_id=
{
$user
[
'userid'
]
}
and news_id=
{
$newsid
}
"
;
$newsdiggtop
=
$empire
->
fetch1
(
$sql
);
if
(
$newsdiggtop
)
{
returnmsg
(
false
,
'已赞过该内容'
,
'diggtoped'
);
}
$now
=
time
();
$sql
=
"insert into
{
$tablenewsdiggtop
}
(user_id,news_uid,news_id,created_at) VALUES (
{
$user
[
'userid'
]
}
,
{
$news
[
'userid'
]
}
,
{
$newsid
}
,
{
$now
}
)"
;
$empire
->
query
(
$sql
);
$id
=
$empire
->
lastid
();
if
(
$id
)
{
$sql
=
"update
{
$tablenews
}
set diggtop=diggtop+1 where id=
{
$newsid
}
"
;
$empire
->
query
(
$sql
);
returnmsg
(
true
,
'点赞成功'
);
}
else
{
returnmsg
(
false
,
'点赞失败'
);
}
}
\ No newline at end of file
e/class/q_functions.php
View file @
ba647f58
...
@@ -297,4 +297,13 @@ function ReplaceTempvar($temp){
...
@@ -297,4 +297,13 @@ function ReplaceTempvar($temp){
return
$temp
;
return
$temp
;
}
}
function
returnmsg
(
$status
=
false
,
$msg
=
''
,
$data
=
''
)
{
$return
[
'status'
]
=
$status
?
true
:
false
;
$return
[
'msg'
]
=
$msg
;
$return
[
'data'
]
=
$data
;
echo
json_encode
(
$return
,
JSON_UNESCAPED_UNICODE
);
exit
();
}
?>
?>
\ No newline at end of file
skin/default/js/news.js
View file @
ba647f58
...
@@ -20,7 +20,7 @@ $(".send-pl").click(function () {
...
@@ -20,7 +20,7 @@ $(".send-pl").click(function () {
$
(
self
).
attr
(
"disabled"
,
true
);
$
(
self
).
attr
(
"disabled"
,
true
);
$
.
post
(
"/e/
pl/comments
.php?mod=create"
,
data
,
function
(
e
)
{
$
.
post
(
"/e/
action/news/comment
.php?mod=create"
,
data
,
function
(
e
)
{
$
(
self
).
attr
(
"disabled"
,
false
);
$
(
self
).
attr
(
"disabled"
,
false
);
if
(
e
.
status
)
{
if
(
e
.
status
)
{
$
(
"textarea[name='content']"
).
val
(
''
);
$
(
"textarea[name='content']"
).
val
(
''
);
...
@@ -35,7 +35,7 @@ $(".send-pl").click(function () {
...
@@ -35,7 +35,7 @@ $(".send-pl").click(function () {
});
});
function
comments
(
newsid
)
{
function
comments
(
newsid
)
{
$
.
post
(
"/e/
pl/comments
.php"
,
{
newsid
:
newsid
},
function
(
e
)
{
$
.
post
(
"/e/
action/news/comment
.php"
,
{
newsid
:
newsid
},
function
(
e
)
{
if
(
!
$
.
isEmptyObject
(
e
.
data
))
{
if
(
!
$
.
isEmptyObject
(
e
.
data
))
{
var
comments
=
e
.
data
;
var
comments
=
e
.
data
;
var
html
=
''
;
var
html
=
''
;
...
@@ -98,7 +98,7 @@ $(".reply-pl").click(function () {
...
@@ -98,7 +98,7 @@ $(".reply-pl").click(function () {
$
(
self
).
attr
(
"disabled"
,
true
);
$
(
self
).
attr
(
"disabled"
,
true
);
$
.
post
(
"/e/
pl/comments
.php?mod=reply"
,
data
,
function
(
e
)
{
$
.
post
(
"/e/
action/news/comment
.php?mod=reply"
,
data
,
function
(
e
)
{
$
(
self
).
attr
(
"disabled"
,
false
);
$
(
self
).
attr
(
"disabled"
,
false
);
if
(
e
.
status
)
{
if
(
e
.
status
)
{
handelReplyComment
(
data
.
plid
,
e
.
data
);
handelReplyComment
(
data
.
plid
,
e
.
data
);
...
@@ -134,7 +134,7 @@ function likeComment(plid, islike) {
...
@@ -134,7 +134,7 @@ function likeComment(plid, islike) {
return
false
;
return
false
;
}
}
$
.
post
(
"/e/
pl/comments
.php?mod=like"
,
{
plid
:
plid
},
function
(
e
)
{
$
.
post
(
"/e/
action/news/comment
.php?mod=like"
,
{
plid
:
plid
},
function
(
e
)
{
if
(
e
.
status
)
{
if
(
e
.
status
)
{
$
.
each
(
$
(
'.comment-list li'
),
function
(){
$
.
each
(
$
(
'.comment-list li'
),
function
(){
if
(
$
(
this
).
attr
(
'data-id'
)
==
plid
)
{
if
(
$
(
this
).
attr
(
'data-id'
)
==
plid
)
{
...
@@ -167,7 +167,7 @@ function scrollLoading() {
...
@@ -167,7 +167,7 @@ function scrollLoading() {
var
nextPage
=
currentPage
+
1
;
var
nextPage
=
currentPage
+
1
;
scrollLoad
.
html
(
"<img src='"
+
spinner
+
"'>"
);
scrollLoad
.
html
(
"<img src='"
+
spinner
+
"'>"
);
$
.
post
(
"/e/
pl/comments
.php"
,
{
newsid
:
newsid
,
p
:
currentPage
},
function
(
e
)
{
$
.
post
(
"/e/
action/news/comment
.php"
,
{
newsid
:
newsid
,
p
:
currentPage
},
function
(
e
)
{
if
(
!
$
.
isEmptyObject
(
e
.
data
))
{
if
(
!
$
.
isEmptyObject
(
e
.
data
))
{
var
comments
=
e
.
data
;
var
comments
=
e
.
data
;
var
html
=
''
;
var
html
=
''
;
...
@@ -196,5 +196,30 @@ if (scrollLoad.length > 0) {
...
@@ -196,5 +196,30 @@ if (scrollLoad.length > 0) {
}
}
//点赞
//检查内容点赞状态
$
.
post
(
"/e/action/news/index.php?mod=checkdiggtop"
,
{
newsid
:
newsid
},
function
(
e
)
{
if
(
e
.
status
)
{
$
(
"#zan"
).
find
(
'i'
).
removeClass
(
'icon-zan'
).
addClass
(
'icon-zan-fill'
);
}
else
{
$
(
'#zan'
).
one
(
'click'
,
function
()
{
diggtop
();
});
}
},
'json'
);
function
diggtop
()
{
$
.
post
(
"/e/action/news/index.php?mod=diggtop"
,
{
newsid
:
newsid
},
function
(
e
)
{
if
(
e
.
status
)
{
$
(
"#zan"
).
find
(
'i'
).
removeClass
(
'icon-zan'
).
addClass
(
'icon-zan-fill'
);
$
(
'.zan-tip'
).
animate
({
opacity
:
"1"
,
top
:
"-=30"
},
500
).
animate
({
opacity
:
"0"
,
top
:
"-30"
},
"slow"
);
}
else
{
pop
(
e
.
msg
);
}
},
'json'
);
}
//收藏
$
(
'#favor'
).
click
(
function
()
{
$
(
this
).
find
(
'i'
).
removeClass
(
'icon-favor'
).
addClass
(
'icon-favor-fill'
);
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment