forked from Kliqqi-CMS/Kliqqi-CMS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete.php
More file actions
175 lines (144 loc) · 5.44 KB
/
Copy pathdelete.php
File metadata and controls
175 lines (144 loc) · 5.44 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
<?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');
/*echo "<pre>";
print_r($_REQUEST);
echo "</pre>";*/
//die;
check_referrer();
// sidebar
$main_smarty = do_sidebar($main_smarty);
// require user to log in
force_authentication();
// restrict access to admins
$canIhaveAccess = 0;
$canIhaveAccess = $canIhaveAccess + checklevel('admin');
if($canIhaveAccess == 0){
// $main_smarty->assign('tpl_center', '/templates/admin/admin_access_denied');
// $main_smarty->display($template_dir . '/admin/admin.tpl');
header("Location: " . getmyurl('login', $_SERVER['REQUEST_URI']));
die();
}
function dowork(){
$canIhaveAccess = 0;
$canIhaveAccess = $canIhaveAccess + checklevel('admin');
if($canIhaveAccess == 1)
{
if(is_writable('settings.php') == 0){
die("Error: settings.php is not writeable.");
}
if(isset($_REQUEST['action'])){
$action = $_REQUEST['action'];
} else {
$action = "view";
}
if($action == "view"){
$config = new pliggconfig;
if(isset($_REQUEST['page'])){
$config->var_page = $_REQUEST['page'];
$config->showpage();
}
}
if($action == "save"){
$config = new pliggconfig;
$config->var_id = substr($_REQUEST['var_id'], 6, 10);
$config->var_value = $_REQUEST['var_value'];
$config->store();
}
}
}
// pagename
define('pagename', 'delete');
$main_smarty->assign('pagename', pagename);
if(isset($_REQUEST['link_id'])){
global $db;
$link_id = $_REQUEST['link_id'];
if(!is_numeric($link_id)){die();}
$linkres = new Link;
$linkres->id = $link_id;
$linkres->read();
//echo $linkres->status;
totals_adjust_count($linkres->status, -1);
//$linkres->store_basic();
// module system hook
$vars = array('link_id' => $linkres->id);
check_actions('admin_story_delete', $vars);
/*********find out the page slug dynamically ***********/
$linkslugvalue = $db->get_results("SELECT ".table_links.".link_category, ".table_categories.".category_safe_name FROM ".table_categories." LEFT JOIN ".table_links. " ON ".table_links.".link_category = ".table_categories.".category__auto_id WHERE ".table_links.".link_id = '".$link_id."' LIMIT 0,1");
$linkslug = '';
foreach($linkslugvalue as $slug)
$linkslug = $slug->category_safe_name;
if($linkslug != ''){
$redirectUrl = $linkslug;
}
if(isset($_REQUEST['pnme']) and $_REQUEST['pnme'] != 'story' and $_REQUEST['pnme'] != 'published'){
$arr = explode("/", substr($_SERVER['HTTP_REFERER'],0, -1));
if(end($arr) != ''){
$secndlnk = end($arr);
array_pop($arr);
$firstlnk = end($arr);
if($secndlnk != ''){
$redirectUrl = $firstlnk."/".$secndlnk;
} else{
$redirectUrl = $firstlnk;
}
}
}
if(isset($_REQUEST['pnme']) and $_REQUEST['pnme'] != 'story' and $_REQUEST['pnme'] != 'published' and $_REQUEST['pnme'] != 'group_story'){
$redirectUrl = $_REQUEST['pnme'].'/'.$linkslug;
}
if(isset($_REQUEST['pnme']) and $_REQUEST['pnme'] == 'index'){
$redirectUrl = $linkslug;
}
$link_delete = $db->query(" Delete from ".table_links." where link_id =".$linkres->id);
//echo $link_delete."<br />";
$vote_delete = $db->query(" Delete from ".table_votes." where vote_link_id =".$linkres->id);
//echo $vote_delete."<br />";
$comment_delete = $db->query(" Delete from ".table_comments." where comment_link_id =".$linkres->id);
//echo $comment_delete."<br />";
$tag_delete = $db->query(" Delete from ".table_tags." where tag_link_id =".$linkres->id);
//echo $tag_delete."<br />";
$saved_delete = $db->query(" Delete from ".table_saved_links." where saved_link_id =".$linkres->id);
//echo $saved_delete."<br />";
$trackback_delete = $db->query(" Delete from ".table_trackbacks." where trackback_link_id =".$linkres->id);
//echo $trackback_delete."<br />";
$db->query("DELETE FROM ".table_additional_categories." WHERE ac_link_id =".$linkres->id);
$db->query("DELETE FROM ".table_tag_cache);
if ($_SERVER['HTTP_REFERER'] && strpos($_SERVER['HTTP_REFERER'], $my_base_url.$my_pligg_base) === 0){
header('Location: '.$my_pligg_base.'/'.$redirectUrl);
}
else{
header('Location: '.$my_pligg_base.'/'.$redirectUrl);
}
}
if(isset($_REQUEST['comment_id'])){
global $db;
$comment_id = $_REQUEST['comment_id'];
if(!is_numeric($comment_id)){die();}
$link_id = $db->get_var("SELECT comment_link_id FROM `" . table_comments . "` WHERE `comment_id` = $comment_id");
$vars = array('comment_id' => $comment_id);
check_actions('comment_deleted', $vars);
$db->query('DELETE FROM `' . table_comments . '` WHERE `comment_id` = "'.$comment_id.'"');
$comments = $db->get_results($sql="SELECT comment_id FROM " . table_comments . " WHERE `comment_parent` = '$comment_id'");
foreach($comments as $comment)
{
$vars = array('comment_id' => $comment->comment_id);
check_actions('comment_deleted', $vars);
}
$db->query('DELETE FROM `' . table_comments . '` WHERE `comment_parent` = "'.$comment_id.'"');
$link = new Link;
$link->id=$link_id;
$link->read();
$link->recalc_comments();
$link->store();
$link='';
if ($_SERVER['HTTP_REFERER'] && strpos($_SERVER['HTTP_REFERER'], $my_base_url.$my_pligg_base)===0)
header('Location: '.$_SERVER['HTTP_REFERER']);
else
header('Location: '.$my_base_url.$my_pligg_base);
}
?>