-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathupdowngrade.php
54 lines (52 loc) · 1.65 KB
/
updowngrade.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
<?php
/*
* updowngrade: script to change category from permanent to non permanent or
* vice versa
* PHP version 5
*
* LICENSE: This source file is subject to version 3.01 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_01.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to [email protected] so we can mail you a copy immediately.
*
* @category admin feature
* @author CSC-325 Database and Web Application Fall 2010 Class
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version 3.0
*/
include 'functions/connection.php';
if ( $_POST )
{
/* Change category permanence */
$admintype = $_GET['admintype'];
if(($admintype == 1) || (!isset($admintype)) {
$table = "categories";
$field = "categoryID";
}
if($admintype == 2) {
$table = "locations";
$field = "locationID";
}
$queryDelete = 'UPDATE $table SET permanent=0 WHERE $field = ';
$queryAdd = 'UPDATE $table SET permanent=1 WHERE $field = ';
$addArray = array_keys( $_POST, 'upgrade' );
$deleteArray = array_keys( $_POST, 'downgrade' );
if ( $addArray )
{
$queryAdd .= implode( ' OR $field = ', $addArray );
$resultAdd = mysql_query($queryAdd);
/* To do: error check */
echo 1;
exit();
}
if ( $deleteArray )
{
$queryDelete .= implode( ' OR $field = ', $deleteArray );
$resultDelete = mysql_query($queryDelete);
/* To do: error check */
echo 1;
exit();
}
}
?>