-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmove.php
110 lines (81 loc) · 2.87 KB
/
move.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
<?php
require_once("configuration/main.php");
if(!$permissions['viewforum'])
{
redirect("errors/permissions.html");
}
$mQuery = $mysql->query("SELECT `poster`, `title`, `section` FROM `threads` WHERE `id` = '" . escape($_GET['thread']) . "'");
if($mQuery->num_rows)
{
$mData = $mQuery->fetch_assoc();
setPageInfo("Move Thread", $mData['title']);
}
else
{
die("You have followed an invalid link.");
}
if(!$permissions['viewotherthreads'] && $mData['poster'] != $_SESSION['accountid'])
{
redirect("errors/permissions.html");
}
if(!$permissions['movethreads'] && (!$permissions['moveownthreads'] || $mData['poster'] != $_SESSION['accountid']))
{
redirect("errors/permissions.html");
}
function listSubSections($sectionID, $parentIndex)
{
global $mysql;
$sectionQuery = $mysql->query("SELECT `id`, `name` FROM `sections` WHERE `parent` = '$sectionID' ORDER BY `order` ASC");
while($sectionData = $sectionQuery->fetch_assoc())
{
echo "<option value='" . $sectionData['id'] . "'>" . getParentIndex($parentIndex) . " " . $sectionData['name'] . "</option>";
$parentQuery = $mysql->query("SELECT `id` FROM `sections` WHERE `parent` = '" . $sectionData['id'] . "' ORDER BY `order` ASC");
if($parentQuery->num_rows)
{
listSubSections($sectionData['id'], $parentIndex + 1);
}
}
}
if($_POST['sectionList'])
{
if($_POST['sectionList'] == "invalid")
{
die("You have followed an invalid link.");
}
$mysql->query("UPDATE `threads` SET `section` = '" . escape($_POST['sectionList']) . "' WHERE `id` = '" . escape($_GET['thread']) . "'");
echo "The thread has been moved";
redirect("thread?id=" . $_GET['thread'] . "", 2);
}
echo "<form id='selectSection' action='?thread=" . $_GET['thread'] . "' method='POST'> <select id='sectionList' name='sectionList' class='sectionList'> <option selected disabled>Select a section...</option>";
$mQuery = $mysql->query("SELECT * FROM `categories` ORDER BY `order` ASC");
while($mData = $mQuery->fetch_assoc())
{
echo "<option value='invalid' disabled>" . $mData['name'] . "</option>";
$sectionQuery = $mysql->query("SELECT * FROM `sections` WHERE `category` = '" . $mData['id'] . "' AND `parent` IS NULL ORDER BY `order` ASC");
while($sectionData = $sectionQuery->fetch_assoc())
{
$parentIndex = 1;
echo "<option value='" . $sectionData['id'] . "'>" . getParentIndex($parentIndex) . " " . $sectionData['name'] . "</option>";
listSubSections($sectionData['id'], 2);
}
}
echo "</select> </form>";
?>
<script>
$(document).ready(function()
{
$('#sectionList').change(function()
{
jConfirm("Are you sure you want to move this thread to:\r\n" + $('#sectionList option:selected').text().trim() + "", "Move Thread", function(isConfirmed)
{
if(isConfirmed)
{
$('#selectSection').submit();
}
});
});
});
</script>
<?php
require_once("includes/footer.php");
?>