-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmove_category.php
More file actions
64 lines (64 loc) · 1.59 KB
/
move_category.php
File metadata and controls
64 lines (64 loc) · 1.59 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
<?php
//This page let move a category
include('config.php');
if(isset($_GET['id'], $_GET['action']) and ($_GET['action']=='up' or $_GET['action']=='down'))
{
$id = intval($_GET['id']);
$action = $_GET['action'];
$dn1 = mysql_fetch_array(mysql_query('select count(c.id) as nb1, c.position, count(c2.id) as nb2 from categories as c, categories as c2 where c.id="'.$id.'" group by c.id'));
if($dn1['nb1']>0)
{
if(isset($_SESSION['username']) and $_SESSION['username']==$admin)
{
if($action=='up')
{
if($dn1['position']>1)
{
if(mysql_query('update categories as c, categories as c2 set c.position=c.position-1, c2.position=c2.position+1 where c.id="'.$id.'" and c2.position=c.position-1'))
{
header('Location: '.$url_home);
}
else
{
echo 'An error occured while moving the category.';
}
}
else
{
echo '<h2>The action you want to do is impossible.</h2>';
}
}
else
{
if($dn1['position']<$dn1['nb2'])
{
if(mysql_query('update categories as c, categories as c2 set c.position=c.position+1, c2.position=c2.position-1 where c.id="'.$id.'" and c2.position=c.position+1'))
{
header('Location: '.$url_home);
}
else
{
echo 'An error occured while moving the category.';
}
}
else
{
echo '<h2>The action you want to do is impossible.</h2>';
}
}
}
else
{
echo '<h2>You must be logged as an administrator to access this page: <a href="login.php">Login</a> - <a href="signup.php">Sign Up</a></h2>';
}
}
else
{
echo '<h2>The category you want to move doesn\'t exist.</h2>';
}
}
else
{
echo '<h2>The ID of the category you want to move is not defined.</h2>';
}
?>