OSDN Git Service

Fix: In some situations LEFT/RIGHT arrow keys do not work. (patch by Takeutch Kemeco.)
[ntch/develop.git] / nce / nc_query_thread_attribute_list_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 $hashed_passwd = $_POST['hashed_passwd'];
19 $board_name = $_POST['board_name'];
20 $dat_name = $_POST['dat_name'];
21 $type1 = $_POST['type1'];
22 $type2 = $_POST['type2'];
23
24 //--- authorization ---
25 $user = chk_passwd( $user_id, $hashed_passwd);
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($type1)){
34         echo ERROR303;
35         exit;
36 }
37 if(!is_numeric($type1)){
38         echo ERROR303;
39         exit;
40 }
41 if($type1!=2 && $type1!=3 && $type1!=5 && $type1!=6){
42         echo ERROR304;
43         exit;
44 }
45 //--- parameter check end ---
46
47 $table_name = TABLE_PREFIX."tbl{$user->home_dir}";
48 $query = <<< QUERY1
49 select res_number, record_type from $table_name 
50     where board_name='{$board_name}' and dat_name='{$dat_name}' 
51     and ( record_type = '{$type1}'
52 QUERY1;
53
54 if(chk_param($type2)){
55         if(!is_numeric($type2) ||
56                 ($type2!=2 && $type2!=3 && $type2!=5 && $type2!=6) ||
57                 ($type1 == $type2)){
58                 echo ERROR303;
59                 exit;
60         }
61         $query = $query." or record_type = '{$type2}')"; 
62 }else{
63         $query = $query." )"; 
64 }
65
66 try{
67         $db->open();
68         $result = $db->execute($query);
69         
70         if(!$result){
71                 echo ERROR503;
72                 exit;
73         }
74         $db->close();
75 }catch(Exception $e){
76         $error = __FILE__."(".__LINE__.
77                 ") An error occured during query.";
78         nc_logging($error, $e);
79         echo ERROR500;
80         exit;
81 }
82
83 echo SUCCESS100;
84 for($i = 0; $i < $result->num_rows; $i++){
85         $row = $result->fetch_assoc();
86         echo $row['record_type']."=".$row['res_number']."\n";
87 }
88
89 ?>