-
Notifications
You must be signed in to change notification settings - Fork 5
/
down_vote.php
72 lines (64 loc) · 3.2 KB
/
down_vote.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
<?php
/*
* You may not change or alter any portion of this comment or credits
* of supporting developers from this source code or any supporting source code
* which is considered copyrighted (c) material of the original comment or credit authors.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
* SmallWorld
*
* @package \XoopsModules\Smallworld
* @license GNU GPL (https://www.gnu.org/licenses/gpl-2.0.html/)
* @copyright The XOOPS Project (https://xoops.org)
* @copyright 2011 Culex
* @author Michael Albertsen (http://culex.dk) <[email protected]>
* @link https://github.com/XoopsModules25x/smallworld
* @since 1.0
*/
use Xmf\Request;
use XoopsModules\Smallworld;
require_once __DIR__ . '/header.php';
require_once XOOPS_ROOT_PATH . '/class/template.php';
/** @var \XoopsModules\Smallworld\Helper $helper */
require_once $helper->path('include/functions.php');
require_once $helper->path('include/arrays.php');
$GLOBALS['xoopsLogger']->activated = false;
$wall = new Smallworld\WallUpdates();
if ($GLOBALS['xoopsUser'] && ($GLOBALS['xoopsUser'] instanceof \XoopsUser)) {
if (Request::hasVar('id', 'POST')) {
$id = Request::getInt('id', 0, 'POST');
$type = $GLOBALS['xoopsDB']->escape($_POST['type']);
$type2 = $GLOBALS['xoopsDB']->escape($_POST['type2']);
$owner = $GLOBALS['xoopsDB']->escape($_POST['owner']);
$userid = $GLOBALS['xoopsUser']->getVar('uid');
$hasvoted = $wall->hasVoted($userid, $type, $type2, $id);
if ('msg' === $type) {
if ($hasvoted > 0) {
echo "<script type='text/javascript'>";
echo "alert('" . _SMALLWORLD_JS_ALREADYVOTED . "');";
echo '</script>';
} else {
$sql = 'INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('smallworld_vote') . " (vote_id,msg_id,com_id,user_id,owner,up,down) VALUES (null, '" . $id . "', '0', '" . $userid . "', '" . $owner . "', '0', '1')";
$result = $GLOBALS['xoopsDB']->queryF($sql);
}
$newvote = $wall->countVotes($type, 'down', $id);
}
if ('com' === $type) {
if ($hasvoted > 0) {
echo "<script type='text/javascript'>alert('" . _SMALLWORLD_JS_ALREADYVOTED . "');</script>";
} else {
$sql = 'INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('smallworld_vote') . " (vote_id,msg_id,com_id,user_id,owner,up,down) VALUES (null, '" . $id . "', '" . $type2 . "', '" . $userid . "', '" . $owner . "', '0', '1')";
$result = $GLOBALS['xoopsDB']->queryF($sql);
}
$newvote = $wall->countVotesCom($type, 'down', $type2, $id);
}
}
$link = '<span id ="smallworld_votenum">' . $newvote . '</span> <a href="javascript:void(0)" name="down" class="smallworld_stcomment_vote"';
$link .= ' id="' . $id . '" type="' . $type . '" owner="' . $owner . '" type2="' . $type2 . '">';
$link .= '<img class="smallworld_voteimg" src = "assets/images/dislike.png" ></a>';
echo $link;
}