-
Notifications
You must be signed in to change notification settings - Fork 0
/
service.php
163 lines (144 loc) · 3.85 KB
/
service.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?
// Connects to your Database
$mysql_host = 'localhost';
$mysql_user = 'faceware';
$mysql_password = 'swoh0720';
$mysql_db = 'faceware';
$callback = $_REQUEST['callback'];
mysql_connect($mysql_host, $mysql_user, $mysql_password) or die(mysql_error());
mysql_select_db($mysql_db) or die(mysql_error());
$service = $_GET['name'];
$result = null;
switch($service) {
case 'packlist':
$result = getPackList();
break;
case 'faceitem':
$result = getFaceItemByPack($_GET['packname'], $_GET['packtype']);
break;
}
$data = array('rows' =>$result);
$json = json_encode($data);
if($callback)
header('Content-Type: text/javascript, charset=UTF-8');
else
header('Content-Type: application/x-json, charset=UTF-8');
echo isset($callback)
? "{$callback}($json)"
: $json;
function getFaceItemByPack($pack_name, $pack_type) {
switch ($pack_type) {
case 'event':
$where = " AND wr_2='".$pack_name."'";
break;
case 'category':
$where = " AND wr_3='".$pack_name."'";
break;
default:
$where = "";
break;
}
$query = "SELECT p.wr_id id, wr_subject model, wr_content descript,".
" p.wr_1 maker, p.wr_2 event, p.wr_3 category, p.wr_4 tag, p.wr_5 market, p.wr_6 price, ".
" f.bf_file file, f.bf_width width, f.bf_height height, f.bf_no fileno".
" FROM g4_write_faceitem p ".
" INNER JOIN g4_board_file f ON p.wr_id=f.wr_id AND f.bo_table='faceitem' AND f.bf_filesize>0".
" WHERE p.wr_7 !='true'".$where.
" ORDER BY p.wr_id DESC, f.bf_no ASC ";
//echo $query;
$result = mysql_query($query) or Error(mysql_error());
$datarows = null;
$thumbs = null;
$styles = null;
$item_id = null;
if($result) {
while($rs = mysql_fetch_array($result)) {
if ($item_id != $rs[0]) {
if ($pack != null) {
$pack['styles'] = $styles;
$pack['thumbs'] = $thumbs;
$datarows[] = $pack;
}
$item_id = $rs[0];
$styles = null;
$thumbs = null;
$pack = array(
'id'=>$rs[0],
'model'=>$rs['model'],
'descript'=>$rs['descript'],
'maker'=>$rs['maker'],
'event'=>$rs['event'],
'category'=>$rs['category'],
'tag'=>$rs['tag'],
'market'=>$rs['market'],
'price'=>$rs['price'],
'thumbs'=>null,
'styles'=>null
);
}
if ($rs['fileno'] < 5)
$thumbs[] = array(
'img'=>'gnuboard4/data/file/faceitem/'.$rs['file'],
'width'=>$rs['width'],
'height'=>$rs['height'],
);
else
$styles[] = array(
'img'=>'gnuboard4/data/file/faceitem/'.$rs['file'],
'width'=>$rs['width'],
'height'=>$rs['height'],
);
// var_dump($pack);
}
mysql_free_result($result);
}
if ($pack != null) {
$pack['styles'] = $styles;
$pack['thumbs'] = $thumbs;
$datarows[] = $pack;
}
return $datarows;
}
function getPackList() {
$query = "SELECT p.wr_id id, wr_subject name, p.wr_1 type, p.wr_2 descript, f.bf_file, f.bf_width width, f.bf_height height".
" FROM g4_write_pack p ".
" INNER JOIN g4_board_file f ON p.wr_id=f.wr_id AND f.bo_table='pack' AND f.bf_filesize>0".
" WHERE p.wr_3 !='true'".
" ORDER BY p.wr_id DESC, f.bf_no ASC ";
//echo $query;
$result = mysql_query($query) or Error(mysql_error());
$datarows = null;
$icons = null;
$pack_id = null;
if($result) {
while($rs = mysql_fetch_array($result)) {
if ($pack_id != $rs[0]) {
if ($pack != null) {
$pack['icons'] = $icons;
$datarows[] = $pack;
}
$pack_id = $rs[0];
$icons = null;
$pack = array(
'id'=>$rs[0],
'name'=>$rs[1],
'type'=>$rs[2],
'descript'=>$rs[3],
'icons'=>null);
}
$icons[] = array(
'img'=>'gnuboard4/data/file/pack/'.$rs[4],
'width'=>$rs[5],
'height'=>$rs[6],
);
// var_dump($pack);
}
mysql_free_result($result);
}
if ($pack != null) {
$pack['icons'] = $icons;
$datarows[] = $pack;
}
return $datarows;
}
?>