forked from Kliqqi-CMS/Kliqqi-CMS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_add_remove_links.php
63 lines (53 loc) · 1.86 KB
/
user_add_remove_links.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
<?php
include_once('internal/Smarty.class.php');
$main_smarty = new Smarty;
include('config.php');
include(mnminclude.'html1.php');
include(mnminclude.'link.php');
include(mnminclude.'smartyvariables.php');
check_referrer();
// "Save this" feature by Nick Strand, http://strandalo.us
// -------------------------------------------------------------------------------------
global $db;
if($current_user->user_id != 0)
{
$action = isset($_POST['action']) ? sanitize($_POST['action'], 3) : '';
if($action == 'add') {
/*if(!($linkid = check_integer('link_id')))
{
die("Invalid Link ID");
}*/
$linkid=(int)$_POST['link_id'];
//$link = new Link;
//$link->id=$linkid;
//$link->read();
//$title = $db->get_var("SELECT link_title_url FROM " . table_links . " WHERE link_id = $linkid");
$count = $db->get_var("SELECT count(*) FROM " . table_saved_links . " WHERE saved_link_id = $linkid AND saved_user_id = $current_user->user_id");
if ($count == 0)
{
$sql="INSERT INTO " . table_saved_links . " (saved_user_id, saved_link_id) VALUES ($current_user->user_id, $linkid)";
$db->query($sql);
echo "1";
}else
echo "Error";
} elseif ($action == 'remove') {
/*if(!($linkid = check_integer('link')))
{
die("Invalid Link ID");
}*/
$linkid=(int)$_POST['link_id'];
//$link = new Link;
//$link->id=$linkid;
//$link->read();
//$title = $db->get_var("SELECT link_title_url FROM " . table_links . " WHERE link_id = $linkid");
$count = $db->get_var("SELECT count(*) FROM " . table_saved_links . " WHERE saved_link_id = $linkid AND saved_user_id = $current_user->user_id");
if ($count != 0)
{
$sql="DELETE FROM " . table_saved_links . " WHERE saved_user_id=$current_user->user_id AND saved_link_id=$linkid";
$db->query($sql);
echo "2";
}else
echo "Error";
}
}
?>