OSDN Git Service

v1.0.2.6
[ntch/develop.git] / nce / nc_delete_attribute_db.php
1 <?php
2 /*
3  nce (ntch cloud environment.)
4  name: nc_update_readcnt_db.php
5  author: Akira Ohta (akohta001.gmail.com)
6  date: 2013-apr-14th
7  description:
8  License: GPLv3
9  */
10 include_once "account.php";
11 include_once "preference.php";
12 include_once "database.php";
13 include_once "log.php";
14 include_once "http_util.php";
15 include_once "error_code.php";
16
17 $user_id = $_POST['user'];
18 $token = $_POST['token'];
19 $board_name = $_POST['board_name'];
20 $dat_name = $_POST['dat_name'];
21 $res_number = $_POST['res_number'];
22 $record_type = $_POST['record_type'];
23
24 //--- authorization ---
25 $user = chk_passwd( $user_id, $token);
26 if(FALSE === $user){
27         echo $ERROR_MSG;
28         exit;
29 }
30
31 //--- parameter check start ---
32 if(!chk_param($board_name) || !chk_param($dat_name) ||
33         !chk_param($res_number) || !chk_param($record_type)){
34         echo ERROR303;
35         exit;
36 }
37
38 if(!is_numeric($record_type) && '*' != $record_type){
39         echo ERROR303;
40         exit;
41 }
42 //--- parameter check end ---
43
44
45 $table_name = TABLE_PREFIX."tbl{$user->home_dir}";
46 $error_msg;
47 $query = "delete from $table_name where board_name='{$board_name}' ";
48 if('*' != $dat_name){
49         $query = $query."and dat_name='{$dat_name}' ";
50         if('*' != $res_number){
51                 $query = $query."and res_number='{$res_number}' ";
52                 if('*' != $record_type){
53                         $query = $query."and record_type={$record_type} ";
54                 }
55         }
56 }
57
58 try{
59         $db->open();
60         $result = $db->execute($query);
61         if(!$result){
62                 echo  ERROR504;
63                 exit;
64         }
65         $db->close();
66 }catch(Exception $e){
67         $error = __FILE__."(".__LINE__.
68                 ") An error occured during delete.";
69         
70         nc_logging($error, $e);
71         echo ERROR500;
72         exit;
73 }
74
75 echo SUCCESS100;
76
77 ?>