1 | <?php |
---|
2 | /** |
---|
3 | * @copyright 2005-2008 OpenPNE Project |
---|
4 | * @license http://www.php.net/license/3_01.txt PHP License 3.01 |
---|
5 | */ |
---|
6 | |
---|
7 | /** |
---|
8 | * メンバーリスト取得 |
---|
9 | */ |
---|
10 | function db_admin_c_member_list($page, $page_size, &$pager) |
---|
11 | { |
---|
12 | $sql = 'SELECT c_member_id FROM c_member ORDER BY c_member_id'; |
---|
13 | $ids = db_get_col_page($sql, $page, $page_size); |
---|
14 | |
---|
15 | $c_member_list = array(); |
---|
16 | foreach ($ids as $id) { |
---|
17 | $c_member_list[] = db_member_c_member4c_member_id($id, true, true, 'private'); |
---|
18 | } |
---|
19 | |
---|
20 | $sql = 'SELECT COUNT(*) FROM c_member'; |
---|
21 | $total_num = db_get_one($sql); |
---|
22 | $pager = admin_make_pager($page, $page_size, $total_num); |
---|
23 | |
---|
24 | return $c_member_list; |
---|
25 | } |
---|
26 | |
---|
27 | function db_admin_c_member4mail_address($mail_address) |
---|
28 | { |
---|
29 | $sql = 'SELECT c_member_id FROM c_member_secure' . |
---|
30 | ' WHERE pc_address = ? OR ktai_address = ? OR regist_address = ?'; |
---|
31 | $enc_address = t_encrypt($mail_address); |
---|
32 | $params = array($enc_address, $enc_address, $enc_address); |
---|
33 | $list = db_get_col($sql, $params); |
---|
34 | |
---|
35 | $c_member_list = array(); |
---|
36 | foreach ($list as $c_member_id) { |
---|
37 | $c_member_list[] = db_member_c_member4c_member_id($c_member_id, true, true, 'private'); |
---|
38 | } |
---|
39 | return $c_member_list; |
---|
40 | } |
---|
41 | |
---|
42 | function db_admin_c_member4username($username) |
---|
43 | { |
---|
44 | $sql = 'SELECT c_member_id FROM c_username WHERE username = ?'; |
---|
45 | $c_member_id = db_get_one($sql, array($username)); |
---|
46 | |
---|
47 | $c_member = db_member_c_member4c_member_id($c_member_id, true, true, 'private'); |
---|
48 | return $c_member; |
---|
49 | } |
---|
50 | |
---|
51 | function db_admin_c_siteadmin($target) |
---|
52 | { |
---|
53 | $sql = 'SELECT * FROM c_siteadmin WHERE target = ?'; |
---|
54 | $params = array($target); |
---|
55 | return db_get_row($sql, $params); |
---|
56 | } |
---|
57 | |
---|
58 | function db_admin_insert_c_siteadmin($target, $body) |
---|
59 | { |
---|
60 | $data = array( |
---|
61 | 'target' => $target, |
---|
62 | 'body' => $body, |
---|
63 | 'r_date' => db_now(), |
---|
64 | ); |
---|
65 | return db_insert('c_siteadmin', $data); |
---|
66 | } |
---|
67 | |
---|
68 | function db_admin_update_c_siteadmin($target, $body) |
---|
69 | { |
---|
70 | $data = array( |
---|
71 | 'body' => $body, |
---|
72 | 'r_date' => db_now(), |
---|
73 | ); |
---|
74 | $where = array('target' => $target); |
---|
75 | return db_update('c_siteadmin', $data, $where); |
---|
76 | } |
---|
77 | |
---|
78 | function db_admin_delete_c_profile_option($c_profile_option_id) |
---|
79 | { |
---|
80 | //function cache削除 |
---|
81 | pne_cache_drop('db_member_c_profile_list'); |
---|
82 | |
---|
83 | if (!$c_profile_option_id) { |
---|
84 | return false; |
---|
85 | } |
---|
86 | |
---|
87 | $sql = 'DELETE FROM c_member_profile WHERE c_profile_option_id = ?'; |
---|
88 | $params = array(intval($c_profile_option_id)); |
---|
89 | db_query($sql, $params); |
---|
90 | |
---|
91 | $sql = 'DELETE FROM c_profile_option WHERE c_profile_option_id = ?'; |
---|
92 | db_query($sql, $params); |
---|
93 | |
---|
94 | return true; |
---|
95 | } |
---|
96 | |
---|
97 | function db_admin_insert_c_profile_option($c_profile_id, $value, $sort_order) |
---|
98 | { |
---|
99 | //function cache削除 |
---|
100 | pne_cache_drop('db_member_c_profile_list'); |
---|
101 | |
---|
102 | $data = array( |
---|
103 | 'c_profile_id' => intval($c_profile_id), |
---|
104 | 'value' => $value, |
---|
105 | 'sort_order' => intval($sort_order), |
---|
106 | ); |
---|
107 | return db_insert('c_profile_option', $data); |
---|
108 | } |
---|
109 | |
---|
110 | function db_admin_update_c_profile_option($c_profile_option_id, $value, $sort_order) |
---|
111 | { |
---|
112 | //function cache削除 |
---|
113 | pne_cache_drop('db_member_c_profile_list'); |
---|
114 | |
---|
115 | $data = array('value' => $value); |
---|
116 | $where = array('c_profile_option_id' => intval($c_profile_option_id)); |
---|
117 | db_update('c_member_profile', $data, $where); |
---|
118 | |
---|
119 | $data = array( |
---|
120 | 'value' => $value, |
---|
121 | 'sort_order' => intval($sort_order), |
---|
122 | ); |
---|
123 | db_update('c_profile_option', $data, $where); |
---|
124 | } |
---|
125 | |
---|
126 | function db_admin_insert_c_banner($a_href, $type, $nickname) |
---|
127 | { |
---|
128 | $data = array( |
---|
129 | 'a_href' => $a_href, |
---|
130 | 'type' => $type, |
---|
131 | 'nickname' => $nickname, |
---|
132 | 'is_hidden_after' => 0, |
---|
133 | 'is_hidden_before' => 0, |
---|
134 | 'image_filename' => '', |
---|
135 | ); |
---|
136 | return db_insert('c_banner', $data); |
---|
137 | } |
---|
138 | |
---|
139 | function db_admin_update_c_banner($c_banner_id, $sets) |
---|
140 | { |
---|
141 | $where = array('c_banner_id' => intval($c_banner_id)); |
---|
142 | db_update('c_banner', $sets, $where); |
---|
143 | } |
---|
144 | |
---|
145 | function db_admin_delete_c_banner($c_banner_id) |
---|
146 | { |
---|
147 | db_admin_delete_c_image4c_banner_id($c_banner_id); |
---|
148 | |
---|
149 | $sql = 'DELETE FROM c_banner WHERE c_banner_id = ?'; |
---|
150 | $params = array(intval($c_banner_id)); |
---|
151 | db_query($sql, $params); |
---|
152 | } |
---|
153 | |
---|
154 | function db_admin_delete_c_image4c_banner_id($c_banner_id) |
---|
155 | { |
---|
156 | $sql = 'SELECT image_filename FROM c_banner WHERE c_banner_id = ?'; |
---|
157 | $params = array(intval($c_banner_id)); |
---|
158 | $image_filename = db_get_one($sql, $params); |
---|
159 | image_data_delete($image_filename); |
---|
160 | } |
---|
161 | |
---|
162 | function db_admin_insert_c_profile( |
---|
163 | $name |
---|
164 | , $caption |
---|
165 | , $info |
---|
166 | , $is_required |
---|
167 | , $public_flag_edit |
---|
168 | , $public_flag_default |
---|
169 | , $form_type |
---|
170 | , $sort_order |
---|
171 | , $disp_regist |
---|
172 | , $disp_config |
---|
173 | , $disp_search |
---|
174 | , $val_type |
---|
175 | , $val_regexp |
---|
176 | , $val_min |
---|
177 | , $val_max |
---|
178 | ) |
---|
179 | { |
---|
180 | pne_cache_drop('db_member_c_profile_list'); |
---|
181 | |
---|
182 | if (empty($info) || is_null($info)) { |
---|
183 | $info = ''; |
---|
184 | } |
---|
185 | |
---|
186 | $data = array( |
---|
187 | 'name' => $name, |
---|
188 | 'caption' => $caption, |
---|
189 | 'info' => $info, |
---|
190 | 'is_required' => (bool)$is_required, |
---|
191 | 'public_flag_edit' => (bool)$public_flag_edit, |
---|
192 | 'public_flag_default' => $public_flag_default, |
---|
193 | 'form_type' => $form_type, |
---|
194 | 'sort_order' => (int)$sort_order, |
---|
195 | 'disp_regist' => (bool)$disp_regist, |
---|
196 | 'disp_config' => (bool)$disp_config, |
---|
197 | 'disp_search' => (bool)$disp_search, |
---|
198 | 'val_type' => $val_type, |
---|
199 | 'val_regexp' => $val_regexp, |
---|
200 | 'val_min' => (int)$val_min, |
---|
201 | 'val_max' => (int)$val_max, |
---|
202 | ); |
---|
203 | return db_insert('c_profile', $data); |
---|
204 | } |
---|
205 | |
---|
206 | function db_admin_update_c_profile($c_profile_id |
---|
207 | , $name |
---|
208 | , $caption |
---|
209 | , $info |
---|
210 | , $is_required |
---|
211 | , $public_flag_edit |
---|
212 | , $public_flag_default |
---|
213 | , $form_type |
---|
214 | , $sort_order |
---|
215 | , $disp_regist |
---|
216 | , $disp_config |
---|
217 | , $disp_search |
---|
218 | , $val_type |
---|
219 | , $val_regexp |
---|
220 | , $val_min |
---|
221 | , $val_max |
---|
222 | ) |
---|
223 | { |
---|
224 | if (empty($info) || is_null($info)) { |
---|
225 | $info = ''; |
---|
226 | } |
---|
227 | |
---|
228 | $data = array( |
---|
229 | 'name' => $name, |
---|
230 | 'caption' => $caption, |
---|
231 | 'info' => $info, |
---|
232 | 'is_required' => (bool)$is_required, |
---|
233 | 'public_flag_edit' => (bool)$public_flag_edit, |
---|
234 | 'public_flag_default' => $public_flag_default, |
---|
235 | 'form_type' => $form_type, |
---|
236 | 'sort_order' => intval($sort_order), |
---|
237 | 'disp_regist' => (bool)$disp_regist, |
---|
238 | 'disp_config' => (bool)$disp_config, |
---|
239 | 'disp_search' => (bool)$disp_search, |
---|
240 | 'val_type' => $val_type, |
---|
241 | 'val_regexp' => $val_regexp, |
---|
242 | 'val_min' => intval($val_min), |
---|
243 | 'val_max' => intval($val_max), |
---|
244 | ); |
---|
245 | $where = array('c_profile_id' => intval($c_profile_id)); |
---|
246 | db_update('c_profile', $data, $where); |
---|
247 | |
---|
248 | // 公開設定が固定のときはメンバーの設定値を上書き |
---|
249 | if (!$public_flag_edit) { |
---|
250 | $data = array('public_flag' => $public_flag_default); |
---|
251 | db_update('c_member_profile', $data, $where); |
---|
252 | } |
---|
253 | |
---|
254 | pne_cache_drop('db_member_c_profile_list'); |
---|
255 | } |
---|
256 | |
---|
257 | function db_admin_delete_c_profile($c_profile_id) |
---|
258 | { |
---|
259 | $params = array(intval($c_profile_id)); |
---|
260 | |
---|
261 | // メンバーのプロフィールから削除 |
---|
262 | $sql = 'DELETE FROM c_member_profile WHERE c_profile_id = ?'; |
---|
263 | db_query($sql, $params); |
---|
264 | |
---|
265 | // 選択肢項目を削除 |
---|
266 | $sql = 'DELETE FROM c_profile_option WHERE c_profile_id = ?'; |
---|
267 | db_query($sql, $params); |
---|
268 | |
---|
269 | // プロフィール項目を削除 |
---|
270 | $sql = 'DELETE FROM c_profile WHERE c_profile_id = ?'; |
---|
271 | db_query($sql, $params); |
---|
272 | |
---|
273 | pne_cache_drop('db_member_c_profile_list'); |
---|
274 | } |
---|
275 | |
---|
276 | function db_admin_c_profile4c_profile_id($c_profile_id) |
---|
277 | { |
---|
278 | $sql = 'SELECT * FROM c_profile WHERE c_profile_id = ?'; |
---|
279 | $params = array(intval($c_profile_id)); |
---|
280 | return db_get_row($sql, $params); |
---|
281 | } |
---|
282 | |
---|
283 | /** |
---|
284 | * 全バナー取得 |
---|
285 | * |
---|
286 | * @param int $limit 取得最大件数 |
---|
287 | * @return array_of_array c_banner_list バナー配列 |
---|
288 | */ |
---|
289 | function db_admin_c_banner_list4null($type = '') |
---|
290 | { |
---|
291 | $sql = 'SELECT * FROM c_banner'; |
---|
292 | $params = array(); |
---|
293 | if ($type) { |
---|
294 | $sql .= ' WHERE type = ?'; |
---|
295 | $params[] = $type; |
---|
296 | } |
---|
297 | return db_get_all($sql, $params); |
---|
298 | } |
---|
299 | |
---|
300 | function db_admin_c_commu_category_parent_list() |
---|
301 | { |
---|
302 | $sql = 'SELECT * FROM c_commu_category_parent ORDER BY sort_order'; |
---|
303 | return db_get_all($sql); |
---|
304 | } |
---|
305 | |
---|
306 | function db_admin_c_commu_category_list() |
---|
307 | { |
---|
308 | $sql = 'SELECT * FROM c_commu_category ORDER BY sort_order'; |
---|
309 | $list = db_get_all($sql); |
---|
310 | |
---|
311 | $category_list = array(); |
---|
312 | foreach ($list as $item) { |
---|
313 | $category_list[$item['c_commu_category_parent_id']][] = $item; |
---|
314 | } |
---|
315 | return $category_list; |
---|
316 | } |
---|
317 | |
---|
318 | function db_admin_insert_c_commu_category_parent($name, $sort_order) |
---|
319 | { |
---|
320 | $data = array( |
---|
321 | 'name' => $name, |
---|
322 | 'sort_order' => intval($sort_order), |
---|
323 | ); |
---|
324 | return db_insert('c_commu_category_parent', $data); |
---|
325 | } |
---|
326 | |
---|
327 | function db_admin_update_c_commu_category_parent($c_commu_category_parent_id, $name, $sort_order) |
---|
328 | { |
---|
329 | $data = array( |
---|
330 | 'name' => $name, |
---|
331 | 'sort_order' => intval($sort_order), |
---|
332 | ); |
---|
333 | $where = array( |
---|
334 | 'c_commu_category_parent_id' => intval($c_commu_category_parent_id) |
---|
335 | ); |
---|
336 | db_update('c_commu_category_parent', $data, $where); |
---|
337 | } |
---|
338 | |
---|
339 | function db_admin_delete_c_commu_category_parent($c_commu_category_parent_id) |
---|
340 | { |
---|
341 | $params = array(intval($c_commu_category_parent_id)); |
---|
342 | |
---|
343 | // 小カテゴリを削除 |
---|
344 | $sql = 'DELETE FROM c_commu_category WHERE c_commu_category_parent_id = ?'; |
---|
345 | db_query($sql, $params); |
---|
346 | |
---|
347 | // 中カテゴリを削除 |
---|
348 | $sql = 'DELETE FROM c_commu_category_parent WHERE c_commu_category_parent_id = ?'; |
---|
349 | db_query($sql, $params); |
---|
350 | } |
---|
351 | |
---|
352 | function db_admin_insert_c_commu_category($c_commu_category_parent_id, $name, $sort_order) |
---|
353 | { |
---|
354 | $data = array( |
---|
355 | 'c_commu_category_parent_id' => intval($c_commu_category_parent_id), |
---|
356 | 'name' => $name, |
---|
357 | 'sort_order' => intval($sort_order), |
---|
358 | ); |
---|
359 | return db_insert('c_commu_category', $data); |
---|
360 | } |
---|
361 | |
---|
362 | function db_admin_update_c_commu_category($c_commu_category_id, $name, $sort_order) |
---|
363 | { |
---|
364 | $data = array( |
---|
365 | 'name' => $name, |
---|
366 | 'sort_order' => intval($sort_order) |
---|
367 | ); |
---|
368 | $where = array('c_commu_category_id' => intval($c_commu_category_id)); |
---|
369 | db_update('c_commu_category', $data, $where); |
---|
370 | } |
---|
371 | |
---|
372 | function db_admin_delete_c_commu_category($c_commu_category_id) |
---|
373 | { |
---|
374 | // 小カテゴリを削除 |
---|
375 | $sql = 'DELETE FROM c_commu_category WHERE c_commu_category_id = ?'; |
---|
376 | $params = array(intval($c_commu_category_id)); |
---|
377 | db_query($sql, $params); |
---|
378 | } |
---|
379 | |
---|
380 | function db_admin_c_admin_user_id4username($username) |
---|
381 | { |
---|
382 | $sql = 'SELECT c_admin_user_id FROM c_admin_user WHERE username = ?'; |
---|
383 | $params = array($username); |
---|
384 | return db_get_one($sql, $params); |
---|
385 | } |
---|
386 | |
---|
387 | function db_admin_authenticate_password($uid, $password) |
---|
388 | { |
---|
389 | $sql = 'SELECT c_admin_user_id FROM c_admin_user WHERE c_admin_user_id = ? AND password = ?'; |
---|
390 | $params = array(intval($uid), md5($password)); |
---|
391 | return (bool)db_get_one($sql, $params); |
---|
392 | } |
---|
393 | |
---|
394 | function db_admin_update_c_admin_user_password($uid, $password) |
---|
395 | { |
---|
396 | $data = array('password' => md5($password)); |
---|
397 | $where = array('c_admin_user_id' => intval($uid)); |
---|
398 | db_update('c_admin_user', $data, $where); |
---|
399 | } |
---|
400 | |
---|
401 | function db_admin_c_admin_config4name($name) |
---|
402 | { |
---|
403 | $sql = 'SELECT value FROM c_admin_config WHERE name = ?'; |
---|
404 | $params = array($name); |
---|
405 | return db_get_one($sql, $params); |
---|
406 | } |
---|
407 | |
---|
408 | function db_admin_insert_c_admin_config($name, $value) |
---|
409 | { |
---|
410 | $data = array( |
---|
411 | 'name' => $name, |
---|
412 | 'value' => $value, |
---|
413 | ); |
---|
414 | return db_insert('c_admin_config', $data); |
---|
415 | } |
---|
416 | |
---|
417 | function db_admin_update_c_admin_config($name, $value) |
---|
418 | { |
---|
419 | $data = array('value' => $value); |
---|
420 | $where = array('name' => $name); |
---|
421 | db_update('c_admin_config', $data, $where); |
---|
422 | } |
---|
423 | |
---|
424 | function db_admin_replace_c_admin_config($name, $value) |
---|
425 | { |
---|
426 | $sql = 'DELETE FROM c_admin_config WHERE name = ?'; |
---|
427 | $params = array($name); |
---|
428 | db_query($sql, $params); |
---|
429 | |
---|
430 | $data = array( |
---|
431 | 'name' => strval($name), |
---|
432 | 'value' => strval($value), |
---|
433 | ); |
---|
434 | return db_insert('c_admin_config', $data); |
---|
435 | } |
---|
436 | |
---|
437 | function db_admin_c_admin_config_all() |
---|
438 | { |
---|
439 | $sql = 'SELECT name, value FROM c_admin_config'; |
---|
440 | return db_get_assoc($sql); |
---|
441 | } |
---|
442 | |
---|
443 | function db_admin_delete_c_image_link4image_filename($image_filename) |
---|
444 | { |
---|
445 | // c_banner (削除) |
---|
446 | $sql = 'DELETE FROM c_banner WHERE image_filename = ?'; |
---|
447 | $params = array($image_filename); |
---|
448 | db_query($sql, $params); |
---|
449 | |
---|
450 | // c_commu |
---|
451 | $tbl = 'c_commu'; |
---|
452 | _db_admin_empty_image_filename($tbl, $image_filename); |
---|
453 | |
---|
454 | // c_commu_topic_comment |
---|
455 | $tbl = 'c_commu_topic_comment'; |
---|
456 | _db_admin_empty_image_filename($tbl, $image_filename, 'image_filename1'); |
---|
457 | _db_admin_empty_image_filename($tbl, $image_filename, 'image_filename2'); |
---|
458 | _db_admin_empty_image_filename($tbl, $image_filename, 'image_filename3'); |
---|
459 | |
---|
460 | // c_diary |
---|
461 | $tbl = 'c_diary'; |
---|
462 | _db_admin_empty_image_filename($tbl, $image_filename, 'image_filename_1'); |
---|
463 | _db_admin_empty_image_filename($tbl, $image_filename, 'image_filename_2'); |
---|
464 | _db_admin_empty_image_filename($tbl, $image_filename, 'image_filename_3'); |
---|
465 | |
---|
466 | // c_diary_comment |
---|
467 | $tbl = 'c_diary_comment'; |
---|
468 | _db_admin_empty_image_filename($tbl, $image_filename, 'image_filename_1'); |
---|
469 | _db_admin_empty_image_filename($tbl, $image_filename, 'image_filename_2'); |
---|
470 | _db_admin_empty_image_filename($tbl, $image_filename, 'image_filename_3'); |
---|
471 | |
---|
472 | // c_member |
---|
473 | $tbl = 'c_member'; |
---|
474 | _db_admin_empty_image_filename($tbl, $image_filename); |
---|
475 | _db_admin_empty_image_filename($tbl, $image_filename, 'image_filename_1'); |
---|
476 | _db_admin_empty_image_filename($tbl, $image_filename, 'image_filename_2'); |
---|
477 | _db_admin_empty_image_filename($tbl, $image_filename, 'image_filename_3'); |
---|
478 | } |
---|
479 | |
---|
480 | function _db_admin_empty_image_filename($tbl, $image_filename, $column = 'image_filename') |
---|
481 | { |
---|
482 | $data = array( |
---|
483 | db_escapeIdentifier($column) => '', |
---|
484 | ); |
---|
485 | $where = array( |
---|
486 | db_escapeIdentifier($column) => $image_filename, |
---|
487 | ); |
---|
488 | db_update(db_escapeIdentifier($tbl), $data, $where); |
---|
489 | } |
---|
490 | |
---|
491 | function db_admin_c_profile_name_exists($name) |
---|
492 | { |
---|
493 | $sql = 'SELECT c_profile_id FROM c_profile WHERE name = ?'; |
---|
494 | $params = array($name); |
---|
495 | return db_get_one($sql, $params); |
---|
496 | } |
---|
497 | |
---|
498 | function db_admin_update_is_login_rejected($c_member_id) |
---|
499 | { |
---|
500 | // function cacheを削除 |
---|
501 | cache_drop_c_member_profile($c_member_id); |
---|
502 | |
---|
503 | $sql = 'SELECT is_login_rejected FROM c_member WHERE c_member_id = ?'; |
---|
504 | $params = array(intval($c_member_id)); |
---|
505 | $is_login_rejected = db_get_one($sql, $params); |
---|
506 | if (is_null($is_login_rejected)) { |
---|
507 | return false; |
---|
508 | } |
---|
509 | |
---|
510 | $data = array('is_login_rejected' => !($is_login_rejected)); |
---|
511 | $where = array('c_member_id' => intval($c_member_id)); |
---|
512 | return db_update('c_member', $data, $where); |
---|
513 | } |
---|
514 | |
---|
515 | function db_admin_c_admin_user_list() |
---|
516 | { |
---|
517 | $sql = 'SELECT * FROM c_admin_user ORDER BY c_admin_user_id'; |
---|
518 | return db_get_all($sql); |
---|
519 | } |
---|
520 | |
---|
521 | function db_admin_exists_c_admin_username($username) |
---|
522 | { |
---|
523 | $sql = 'SELECT c_admin_user_id FROM c_admin_user WHERE username = ?'; |
---|
524 | $params = array(strval($username)); |
---|
525 | return (bool)db_get_one($sql, $params); |
---|
526 | } |
---|
527 | |
---|
528 | function db_admin_insert_c_admin_user($username, $password, $auth_type) |
---|
529 | { |
---|
530 | $data = array( |
---|
531 | 'username' => strval($username), |
---|
532 | 'password' => md5($password), |
---|
533 | 'auth_type' => strval($auth_type), |
---|
534 | ); |
---|
535 | return db_insert('c_admin_user', $data); |
---|
536 | } |
---|
537 | |
---|
538 | function db_admin_delete_c_admin_user($c_admin_user_id) |
---|
539 | { |
---|
540 | $sql = 'DELETE FROM c_admin_user WHERE c_admin_user_id = ?'; |
---|
541 | $params = array(intval($c_admin_user_id)); |
---|
542 | return db_query($sql, $params); |
---|
543 | } |
---|
544 | |
---|
545 | function db_admin_get_auth_type($c_admin_user_id) |
---|
546 | { |
---|
547 | $sql = 'SELECT auth_type FROM c_admin_user WHERE c_admin_user_id = ?'; |
---|
548 | $params = array(intval($c_admin_user_id)); |
---|
549 | return db_get_one($sql, $params); |
---|
550 | } |
---|
551 | |
---|
552 | /** |
---|
553 | * c_member テーブル内データによるメンバーIDリスト取得 |
---|
554 | * |
---|
555 | * @return array |
---|
556 | */ |
---|
557 | function db_admin_c_member_id_list4cond_c_member($cond_list, $type = array()) |
---|
558 | { |
---|
559 | $sql = 'SELECT c_member_id FROM c_member'; |
---|
560 | $wheres = array(); |
---|
561 | |
---|
562 | // 開始年 |
---|
563 | if (!empty($cond_list['s_year'])) { |
---|
564 | $wheres[] = 'birth_year >= ?'; |
---|
565 | $params[] = $cond_list['s_year']; |
---|
566 | } |
---|
567 | // 終了年 |
---|
568 | if (!empty($cond_list['e_year'])) { |
---|
569 | $wheres[] = 'birth_year <= ?'; |
---|
570 | $params[] = $cond_list['e_year']; |
---|
571 | } |
---|
572 | |
---|
573 | // 誕生日による絞り込みの場合は、誕生年が0のメンバーを除外する |
---|
574 | if (!empty($cond_list['s_year']) || !empty($cond_list['e_year'])) { |
---|
575 | $wheres[] = 'birth_year <> 0'; |
---|
576 | } |
---|
577 | |
---|
578 | //最終ログイン時間で絞り込み |
---|
579 | if (isset($cond_list['last_login'])) { |
---|
580 | switch($cond_list['last_login']) { |
---|
581 | case 1 : // 3日以内 |
---|
582 | $wheres[] = 'access_date >= ?'; |
---|
583 | $params[] = date('Y-m-d', strtotime('-3 day')); |
---|
584 | break; |
---|
585 | case 2 : // 3~7日以内 |
---|
586 | $wheres[] = 'access_date >= ? AND access_date < ?'; |
---|
587 | $params[] = date('Y-m-d', strtotime('-7 day')); |
---|
588 | $params[] = date('Y-m-d', strtotime('-3 day')); |
---|
589 | break; |
---|
590 | case 3 : // 7~30日以内 |
---|
591 | $wheres[] = 'access_date >= ? AND access_date < ?'; |
---|
592 | $params[] = date('Y-m-d', strtotime('-30 day')); |
---|
593 | $params[] = date('Y-m-d', strtotime('-7 day')); |
---|
594 | break; |
---|
595 | case 4 : // 30日以上 |
---|
596 | $wheres[] = 'access_date > ? AND access_date < ?'; |
---|
597 | $params[] = '0000-00-00 00:00:00'; |
---|
598 | $params[] = date('Y-m-d', strtotime('-30 day')); |
---|
599 | break; |
---|
600 | case 5 : // 未ログイン |
---|
601 | $wheres[] = 'access_date = ?'; |
---|
602 | $params[] = '0000-00-00 00:00:00'; |
---|
603 | break; |
---|
604 | } |
---|
605 | } |
---|
606 | |
---|
607 | if ($wheres) { |
---|
608 | $sql .= ' WHERE ' . implode(' AND ', $wheres); |
---|
609 | } |
---|
610 | |
---|
611 | // --- ソートオーダーここから |
---|
612 | |
---|
613 | // $orderの例:id_1 , id_2 |
---|
614 | // 「-」の前が項目名であとが1なら昇順 2なら降順 |
---|
615 | $is_order = false; |
---|
616 | if (!empty($type)) { |
---|
617 | $is_order = true; |
---|
618 | |
---|
619 | switch ($type[0]) { |
---|
620 | case "c_member_id": |
---|
621 | $sql .= ' ORDER BY c_member_id'; |
---|
622 | break; |
---|
623 | case "nickname": |
---|
624 | $sql .= ' ORDER BY nickname'; |
---|
625 | break; |
---|
626 | case "image_filename": |
---|
627 | $sql .= ' ORDER BY image_filename'; |
---|
628 | break; |
---|
629 | case "c_member_id_invite": |
---|
630 | $sql .= ' ORDER BY c_member_id_invite'; |
---|
631 | break; |
---|
632 | case "access_date": |
---|
633 | $sql .= ' ORDER BY access_date'; |
---|
634 | break; |
---|
635 | case "r_date": |
---|
636 | $sql .= ' ORDER BY r_date'; |
---|
637 | break; |
---|
638 | case "birth": |
---|
639 | // 降順指定 |
---|
640 | if ($type[1] == "2") { |
---|
641 | $sql .= ' ORDER BY birth_year DESC, birth_month DESC, birth_day'; |
---|
642 | } else { |
---|
643 | $sql .= ' ORDER BY birth_year, birth_month, birth_day'; |
---|
644 | } |
---|
645 | break; |
---|
646 | default : |
---|
647 | $is_order = false; |
---|
648 | } |
---|
649 | |
---|
650 | // 降順指定 |
---|
651 | if ($is_order && $type[1] == "2") { |
---|
652 | $sql .= ' DESC'; |
---|
653 | } |
---|
654 | |
---|
655 | } |
---|
656 | |
---|
657 | // --- ソートオーダーここまで |
---|
658 | |
---|
659 | return db_get_col($sql, $params); |
---|
660 | } |
---|
661 | |
---|
662 | /** |
---|
663 | * PNE_POINT によるメンバーIDリスト絞り込み |
---|
664 | * |
---|
665 | * 渡されたメンバーIDの配列を条件に従い絞り込んだものを返す |
---|
666 | * |
---|
667 | * @return array |
---|
668 | */ |
---|
669 | function db_admin_c_member_id_list4cond_pne_point($ids, $cond_list) |
---|
670 | { |
---|
671 | $sql = 'SELECT c_member_id'. |
---|
672 | ' FROM c_member_profile '. |
---|
673 | ' INNER JOIN c_profile USING (c_profile_id) '. |
---|
674 | ' WHERE name = ? '; |
---|
675 | $params = array('PNE_POINT'); |
---|
676 | |
---|
677 | // 開始ポイント |
---|
678 | if (!empty($cond_list['s_point'])) { |
---|
679 | $sql .= ' AND value >= ?'; |
---|
680 | $params[] = $cond_list['s_point']; |
---|
681 | } |
---|
682 | |
---|
683 | // 終了ポイント |
---|
684 | if (!empty($cond_list['e_point'])) { |
---|
685 | $sql .= ' AND value <= ?'; |
---|
686 | $params[] = $cond_list['e_point']; |
---|
687 | } |
---|
688 | |
---|
689 | $point_ids = db_get_col($sql, $params); |
---|
690 | |
---|
691 | return array_intersect($ids, $point_ids); |
---|
692 | } |
---|
693 | |
---|
694 | /** |
---|
695 | * メールアドレスの有無によるメンバーIDリスト絞り込み |
---|
696 | * |
---|
697 | * 渡されたメンバーIDの配列を条件に従い絞り込んだものを返す |
---|
698 | * |
---|
699 | * @return array |
---|
700 | */ |
---|
701 | function db_admin_c_member_id_list4cond_mail_address($ids, $cond_list) |
---|
702 | { |
---|
703 | $sql = 'SELECT c_member_id FROM c_member_secure'; |
---|
704 | $wheres = array(); |
---|
705 | |
---|
706 | // PCメールアドレスの有無で絞る |
---|
707 | if ($cond_list['is_pc_address'] == 1) { |
---|
708 | $wheres[] = "pc_address <> ''"; |
---|
709 | } elseif ($cond_list['is_pc_address'] == 2) { |
---|
710 | $wheres[] = "pc_address = ''"; |
---|
711 | } |
---|
712 | |
---|
713 | // 携帯メールアドレスの有無で絞る |
---|
714 | if ($cond_list['is_ktai_address'] == 1) { |
---|
715 | $wheres[] = "ktai_address <> ''"; |
---|
716 | } elseif ($cond_list['is_ktai_address'] == 2) { |
---|
717 | $wheres[] = "ktai_address = ''"; |
---|
718 | } |
---|
719 | |
---|
720 | if ($wheres) { |
---|
721 | $where = ' WHERE ' . implode(' AND ', $wheres); |
---|
722 | } else { |
---|
723 | $where = ''; |
---|
724 | } |
---|
725 | $sql .= $where; |
---|
726 | |
---|
727 | $temp_ids = db_get_col($sql); |
---|
728 | |
---|
729 | return array_intersect($ids, $temp_ids); |
---|
730 | } |
---|
731 | |
---|
732 | /** |
---|
733 | * c_profile 内データによるメンバーIDリスト絞り込み |
---|
734 | * |
---|
735 | * 渡されたメンバーIDの配列を条件に従い絞り込んだものを返す |
---|
736 | * |
---|
737 | * @return array |
---|
738 | */ |
---|
739 | function db_admin_c_member_id_list4cond_c_profile($ids, $cond_list, $type) |
---|
740 | { |
---|
741 | // ランクでソートとポイントでソートは同等 |
---|
742 | if ($type[0] == 'RANK') { |
---|
743 | $type[0] = 'PNE_POINT'; |
---|
744 | } |
---|
745 | |
---|
746 | // 各プロフィールごとに絞り込み |
---|
747 | $sql = 'SELECT name, form_type, c_profile_id FROM c_profile'; |
---|
748 | $profile = db_get_all($sql); |
---|
749 | |
---|
750 | if ($profile) { |
---|
751 | foreach ($profile as $value) { |
---|
752 | if(!empty($cond_list[$value['name']]) |
---|
753 | && ($value['form_type'] == 'radio' || $value['form_type'] == 'select')) { |
---|
754 | $sql = 'SELECT c_member_id FROM c_member_profile WHERE c_profile_option_id = ?'; |
---|
755 | $params = array($cond_list[$value['name']]); |
---|
756 | $temp_ids = db_get_col($sql, $params); |
---|
757 | $ids = array_intersect($ids, $temp_ids); |
---|
758 | } |
---|
759 | |
---|
760 | if($value['name'] == $type[0]) { |
---|
761 | $sql = 'SELECT c_member_id FROM c_member_profile WHERE c_profile_id = ?'; |
---|
762 | |
---|
763 | if ($value['form_type'] == 'radio' |
---|
764 | || $value['form_type'] == 'select' |
---|
765 | || $value['form_type'] == 'checkbox') { |
---|
766 | $sql .= ' ORDER BY c_profile_option_id'; |
---|
767 | } else { |
---|
768 | if ($value['name'] == "PNE_POINT") { |
---|
769 | if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { |
---|
770 | $sql .= ' ORDER BY cast(value as integer)'; |
---|
771 | } else { |
---|
772 | $sql .= ' ORDER BY cast(value as signed)'; |
---|
773 | } |
---|
774 | } else { |
---|
775 | $sql .= ' ORDER BY value'; |
---|
776 | } |
---|
777 | } |
---|
778 | |
---|
779 | if ($type[1] == "2") { |
---|
780 | $sql .= ' DESC'; |
---|
781 | } |
---|
782 | $params = array($value['c_profile_id']); |
---|
783 | $temp_ids = db_get_col($sql, $params); |
---|
784 | $ids = array_intersect($temp_ids, $ids); |
---|
785 | } |
---|
786 | } |
---|
787 | } |
---|
788 | |
---|
789 | return $ids; |
---|
790 | } |
---|
791 | |
---|
792 | /** |
---|
793 | * ログインIDによるメンバーIDリストソート |
---|
794 | * |
---|
795 | * @return array |
---|
796 | */ |
---|
797 | function db_admin_c_member_id_list_sort4username($ids, $type) |
---|
798 | { |
---|
799 | $sql = 'SELECT c_member_id FROM c_username ORDER BY username'; |
---|
800 | if ($type[1] == '2') { |
---|
801 | $sql .= ' DESC'; |
---|
802 | } |
---|
803 | |
---|
804 | $temp_ids = db_get_col($sql, $params); |
---|
805 | $ids = array_intersect($temp_ids, $ids); |
---|
806 | |
---|
807 | return $ids; |
---|
808 | } |
---|
809 | |
---|
810 | /** |
---|
811 | * メンバーIDリスト取得(絞り込み対応) |
---|
812 | */ |
---|
813 | function _db_admin_c_member_id_list($cond_list, $order = '') |
---|
814 | { |
---|
815 | $type = explode('-', $order); |
---|
816 | $ids = db_admin_c_member_id_list4cond_c_member($cond_list, $type); |
---|
817 | |
---|
818 | // ポイントで絞り込み |
---|
819 | if (isset($cond_list['s_point']) || isset($cond_list['e_point'])) { |
---|
820 | $ids = db_admin_c_member_id_list4cond_pne_point($ids, $cond_list); |
---|
821 | } |
---|
822 | |
---|
823 | // メールアドレスで絞り込み |
---|
824 | if (!empty($cond_list['is_pc_address']) || !empty($cond_list['is_ktai_address'])) { |
---|
825 | $ids = db_admin_c_member_id_list4cond_mail_address($ids, $cond_list); |
---|
826 | } |
---|
827 | |
---|
828 | // ログインIDでソート |
---|
829 | if ($type[0] == 'username' && OPENPNE_AUTH_MODE != 'email') { |
---|
830 | $ids = db_admin_c_member_id_list_sort4username($ids, $type); |
---|
831 | } |
---|
832 | |
---|
833 | // プロフィール項目で絞り込み |
---|
834 | $ids = db_admin_c_member_id_list4cond_c_profile($ids, $cond_list, $type); |
---|
835 | |
---|
836 | return $ids; |
---|
837 | } |
---|
838 | |
---|
839 | /** |
---|
840 | * メンバーリスト取得 |
---|
841 | * 誕生年+プロフィール(select,radioのみ) |
---|
842 | */ |
---|
843 | function _db_admin_c_member_list($page, $page_size, &$pager, $cond_list, $order) |
---|
844 | { |
---|
845 | $ids = _db_admin_c_member_id_list($cond_list, $order); |
---|
846 | $total_num = count($ids); |
---|
847 | $ids = array_slice($ids, ($page - 1) * $page_size, $page_size); |
---|
848 | |
---|
849 | $c_member_list = array(); |
---|
850 | foreach ($ids as $id) { |
---|
851 | $c_member_list[] = db_member_c_member4c_member_id($id, true, true, 'private'); |
---|
852 | } |
---|
853 | |
---|
854 | if ($total_num > 0) { |
---|
855 | $pager = admin_make_pager($page, $page_size, $total_num); |
---|
856 | } else { |
---|
857 | $pager = array('page_size' => $page_size); |
---|
858 | } |
---|
859 | |
---|
860 | return $c_member_list; |
---|
861 | } |
---|
862 | |
---|
863 | function db_c_profile_option4c_profile_option_id($c_profile_option_id) |
---|
864 | { |
---|
865 | $sql = "SELECT * FROM c_profile_option WHERE c_profile_option_id = ? "; |
---|
866 | $params = array(intval($c_profile_option_id)); |
---|
867 | return db_get_row($sql, $params); |
---|
868 | } |
---|
869 | |
---|
870 | /** |
---|
871 | * メンバー絞込みパラメータ取得 |
---|
872 | */ |
---|
873 | function validate_cond($requests) |
---|
874 | { |
---|
875 | $cond_list = array(); |
---|
876 | //誕生年 |
---|
877 | if (!empty($requests['s_year'])) { |
---|
878 | $cond_list['s_year'] = intval($requests['s_year']); |
---|
879 | } |
---|
880 | if (!empty($requests['e_year'])) { |
---|
881 | $cond_list['e_year'] = intval($requests['e_year']); |
---|
882 | } |
---|
883 | //プロフィール |
---|
884 | $profile_list = db_member_c_profile_list(); |
---|
885 | |
---|
886 | foreach ($profile_list as $key => $value) { |
---|
887 | if (!empty($requests[$key])) { |
---|
888 | $cond_list[$key] = intval($requests[$key]); |
---|
889 | } |
---|
890 | } |
---|
891 | |
---|
892 | // 最終ログイン時間 |
---|
893 | if (!empty($requests['last_login'])) { |
---|
894 | $cond_list['last_login'] = intval($requests['last_login']); |
---|
895 | } |
---|
896 | |
---|
897 | //PCメールアドレスの有無 |
---|
898 | if (!empty($requests['is_pc_address'])) { |
---|
899 | $cond_list['is_pc_address'] = intval($requests['is_pc_address']); |
---|
900 | } |
---|
901 | //携帯メールアドレスの有無 |
---|
902 | if (!empty($requests['is_ktai_address'])) { |
---|
903 | $cond_list['is_ktai_address'] = intval($requests['is_ktai_address']); |
---|
904 | } |
---|
905 | |
---|
906 | //ポイント |
---|
907 | if (isset($requests['s_point']) && $requests['s_point'] !== '') { |
---|
908 | $cond_list['s_point'] = intval($requests['s_point']); |
---|
909 | } |
---|
910 | if (isset($requests['e_point']) && $requests['e_point'] !== '') { |
---|
911 | $cond_list['e_point'] = intval($requests['e_point']); |
---|
912 | } |
---|
913 | |
---|
914 | return $cond_list; |
---|
915 | } |
---|
916 | |
---|
917 | function do_admin_send_mail($c_member_id, $subject, $body) |
---|
918 | { |
---|
919 | $c_member = db_member_c_member4c_member_id($c_member_id, true); |
---|
920 | |
---|
921 | if ($c_member['secure']['pc_address']) { |
---|
922 | $send_address = $c_member['secure']['pc_address']; |
---|
923 | } else { |
---|
924 | $send_address = $c_member['secure']['ktai_address']; |
---|
925 | } |
---|
926 | |
---|
927 | if (OPENPNE_MAIL_QUEUE) { |
---|
928 | //メールキューに蓄積 |
---|
929 | put_mail_queue($send_address, $subject, $body); |
---|
930 | } else { |
---|
931 | t_send_email($send_address, $subject, $body); |
---|
932 | } |
---|
933 | } |
---|
934 | |
---|
935 | //メッセージ受信メール(メール&メッセージキュー蓄積対応) |
---|
936 | function do_admin_send_message($c_member_id_from, $c_member_id_to, $subject, $body) |
---|
937 | { |
---|
938 | //メッセージ |
---|
939 | if (OPENPNE_MESSAGE_QUEUE) { |
---|
940 | //メッセージキューに蓄積 |
---|
941 | db_admin_insert_c_message_queue($c_member_id_from, $c_member_id_to, $subject, $body); |
---|
942 | return true; |
---|
943 | } else { |
---|
944 | db_message_insert_c_message($c_member_id_from, $c_member_id_to, $subject, $body); |
---|
945 | do_admin_send_message_mail_send($c_member_id_to, $c_member_id_from); |
---|
946 | do_admin_send_message_mail_send_ktai($c_member_id_to, $c_member_id_from); |
---|
947 | return true; |
---|
948 | } |
---|
949 | |
---|
950 | return false; |
---|
951 | } |
---|
952 | |
---|
953 | //メッセージ受信メール(メールキュー蓄積対応) |
---|
954 | function do_admin_send_message_mail_send($c_member_id_to, $c_member_id_from) |
---|
955 | { |
---|
956 | $c_member_to = db_member_c_member4c_member_id($c_member_id_to, true); |
---|
957 | $pc_address = $c_member_to['secure']['pc_address']; |
---|
958 | $is_receive_mail = $c_member_to['is_receive_mail']; |
---|
959 | |
---|
960 | $params = array( |
---|
961 | "c_member_to" => db_member_c_member4c_member_id($c_member_id_to), |
---|
962 | "c_member_from" => db_member_c_member4c_member_id($c_member_id_from), |
---|
963 | ); |
---|
964 | return admin_fetch_send_mail($pc_address, 'm_pc_message_zyushin', $params, $is_receive_mail); |
---|
965 | } |
---|
966 | |
---|
967 | //◆メッセージ受信メール(携帯) |
---|
968 | function do_admin_send_message_mail_send_ktai($c_member_id_to, $c_member_id_from) |
---|
969 | { |
---|
970 | $c_member_to = db_member_c_member4c_member_id($c_member_id_to, true); |
---|
971 | $ktai_address = $c_member_to['secure']['ktai_address']; |
---|
972 | $is_receive_ktai_mail = $c_member_to['is_receive_ktai_mail']; |
---|
973 | $p = array('kad' => t_encrypt(db_member_username4c_member_id($c_member_to['c_member_id'], true))); |
---|
974 | $login_url = openpne_gen_url('ktai', 'page_o_login', $p); |
---|
975 | |
---|
976 | $params = array( |
---|
977 | 'c_member_to' => db_member_c_member4c_member_id($c_member_id_to), |
---|
978 | 'c_member_from' => db_member_c_member4c_member_id($c_member_id_from), |
---|
979 | 'login_url' => $login_url, |
---|
980 | ); |
---|
981 | return admin_fetch_send_mail($ktai_address, 'm_ktai_message_zyushin', $params, $is_receive_ktai_mail); |
---|
982 | } |
---|
983 | |
---|
984 | function admin_fetch_send_mail($address, $tpl_name, $params = array(), $force = true, $from = '') |
---|
985 | { |
---|
986 | $tpl_name .= '.tpl'; |
---|
987 | if ($tpl = fetch_mail_m_tpl($tpl_name, $params)) { |
---|
988 | list($subject, $body) = $tpl; |
---|
989 | if ($from) { |
---|
990 | if (OPENPNE_MAIL_QUEUE) { |
---|
991 | //メールキューに蓄積 |
---|
992 | put_mail_queue($address, $subject, $body, $force, $from); |
---|
993 | } else { |
---|
994 | t_send_email($address, $subject, $body, $force, $from); |
---|
995 | } |
---|
996 | } else { |
---|
997 | if (OPENPNE_MAIL_QUEUE) { |
---|
998 | //メールキューに蓄積 |
---|
999 | put_mail_queue($address, $subject, $body, $force); |
---|
1000 | } else { |
---|
1001 | t_send_email($address, $subject, $body, $force); |
---|
1002 | } |
---|
1003 | } |
---|
1004 | return true; |
---|
1005 | } else { |
---|
1006 | return false; |
---|
1007 | } |
---|
1008 | } |
---|
1009 | |
---|
1010 | function db_access_analysis_c_admin_user_id4username($username) |
---|
1011 | { |
---|
1012 | $sql = "SELECT c_admin_user_id FROM c_admin_user" . |
---|
1013 | " WHERE username = ?"; |
---|
1014 | $params = array($username); |
---|
1015 | return db_get_one($sql,$params); |
---|
1016 | } |
---|
1017 | |
---|
1018 | function p_access_analysis_month_access_analysis_month($ktai_flag) |
---|
1019 | { |
---|
1020 | if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { |
---|
1021 | $sql = "SELECT to_char(r_datetime, 'YYYY-MM-01') as ym, count(*) as count" . |
---|
1022 | " FROM c_access_log " . |
---|
1023 | " where ktai_flag = ?" . |
---|
1024 | " group by ym"; |
---|
1025 | } else { |
---|
1026 | $sql = "SELECT date_format(r_datetime, '%Y-%m-01') as ym, count(*) as count" . |
---|
1027 | " FROM c_access_log " . |
---|
1028 | " where ktai_flag = ?" . |
---|
1029 | " group by ym"; |
---|
1030 | } |
---|
1031 | |
---|
1032 | $params = array(intval($ktai_flag)); |
---|
1033 | $list = db_get_all($sql,$params); |
---|
1034 | return $list; |
---|
1035 | } |
---|
1036 | |
---|
1037 | |
---|
1038 | function p_access_analysis_day_access_analysis_day($ym, $ktai_flag) |
---|
1039 | { |
---|
1040 | if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { |
---|
1041 | $sql = "SELECT substr(r_datetime,1,10) as ymd , count(*) as count" . |
---|
1042 | " FROM c_access_log " . |
---|
1043 | " where substr(r_datetime,1,7) = ?" . |
---|
1044 | " and ktai_flag = ? " . |
---|
1045 | " group by ymd"; |
---|
1046 | } else { |
---|
1047 | $sql = "SELECT left(r_datetime,10) as ymd , count(*) as count" . |
---|
1048 | " FROM c_access_log " . |
---|
1049 | " where left(r_datetime, 7) = ?" . |
---|
1050 | " and ktai_flag = ? " . |
---|
1051 | " group by ymd"; |
---|
1052 | } |
---|
1053 | $params = array(intval(substr($ym,0,7)),intval($ktai_flag)); |
---|
1054 | $list = db_get_all($sql,$params); |
---|
1055 | |
---|
1056 | $year = substr($ym, 0, 4); |
---|
1057 | $month = substr($ym, 5,2); |
---|
1058 | |
---|
1059 | $return = array(); |
---|
1060 | $days_num = date("t", mktime (0,0,0,$month,1,$year)); |
---|
1061 | for($i=1 ; $i<=$days_num; $i++) { |
---|
1062 | $date = substr($ym,0,8) . substr("00".$i, -2, 2); |
---|
1063 | |
---|
1064 | $count = 0; |
---|
1065 | foreach($list as $value) { |
---|
1066 | if ($value['ymd'] == $date) { |
---|
1067 | $count = $value['count']; |
---|
1068 | } |
---|
1069 | } |
---|
1070 | $return[] = array("ymd"=>$date, "count"=>$count); |
---|
1071 | } |
---|
1072 | return $return; |
---|
1073 | } |
---|
1074 | |
---|
1075 | function get_page_name($ktai_flag, $orderby=1) |
---|
1076 | { |
---|
1077 | if ($orderby == 1) { |
---|
1078 | $orderby_str = " order by page_name asc"; |
---|
1079 | } elseif ($orderby == -1) { |
---|
1080 | $orderby_str = " order by page_name desc"; |
---|
1081 | } |
---|
1082 | $sql = "select distinct page_name from c_access_log " . |
---|
1083 | " where ktai_flag = ? " . |
---|
1084 | $orderby_str; |
---|
1085 | $params = array(intval($ktai_flag)); |
---|
1086 | return db_get_col($sql,$params); |
---|
1087 | } |
---|
1088 | |
---|
1089 | function p_access_analysis_page_access_analysis_page4ym($ymd, $month_flag, $ktai_flag, $orderby) |
---|
1090 | { |
---|
1091 | |
---|
1092 | if ($orderby == 1) { |
---|
1093 | $orderby_str = " order by page_name asc"; |
---|
1094 | } elseif ($orderby == -1) { |
---|
1095 | $orderby_str = " order by page_name desc"; |
---|
1096 | } elseif ($orderby == 2) { |
---|
1097 | $orderby_str = " order by count asc"; |
---|
1098 | } elseif ($orderby == -2) { |
---|
1099 | $orderby_str = " order by count desc"; |
---|
1100 | } |
---|
1101 | $sql = "select page_name , count(*) as count from c_access_log where ktai_flag = ? "; |
---|
1102 | $params = array(intval($ktai_flag)); |
---|
1103 | if ($month_flag) { |
---|
1104 | if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { |
---|
1105 | $sql .= " and substr(r_datetime,1,7) = ? "; |
---|
1106 | } else { |
---|
1107 | $sql .= " and left(r_datetime, 7) = ? "; |
---|
1108 | } |
---|
1109 | |
---|
1110 | array_push($params,substr($ymd,0,7)); |
---|
1111 | } else { |
---|
1112 | if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { |
---|
1113 | $sql .= " and substr(r_datetime,1,10) = ? "; |
---|
1114 | } else { |
---|
1115 | $sql .= " and left(r_datetime,10) = ? "; |
---|
1116 | } |
---|
1117 | array_push($params,$ymd); |
---|
1118 | } |
---|
1119 | $sql .= " group by page_name ". $orderby_str; |
---|
1120 | $list = db_get_all($sql,$params); |
---|
1121 | |
---|
1122 | $sum = 0; |
---|
1123 | $return = array(); |
---|
1124 | if (abs($orderby) == 1) { |
---|
1125 | $page_name = get_page_name($ktai_flag, $orderby); |
---|
1126 | foreach($page_name as $name) { |
---|
1127 | $count = 0; |
---|
1128 | foreach($list as $value) { |
---|
1129 | if ($value['page_name'] == $name) $count = $value['count']; |
---|
1130 | } |
---|
1131 | |
---|
1132 | list($is_target_c_member_id,$is_target_c_commu_id,$is_target_c_topic_id,$is_target_c_diary_id,$is_c_member_id) = get_is_show($name); |
---|
1133 | |
---|
1134 | $return[] = array("page_name"=>$name, "count"=> $count, "is_target_c_member_id"=> $is_target_c_member_id, "is_target_c_commu_id"=> $is_target_c_commu_id, "is_target_c_topic_id"=> $is_target_c_topic_id, "is_target_c_diary_id"=> $is_target_c_diary_id, "is_c_member_id"=> $is_c_member_id); |
---|
1135 | $sum += $count; |
---|
1136 | } |
---|
1137 | } elseif (abs($orderby) == 2) { |
---|
1138 | $page_name = get_page_name($ktai_flag); |
---|
1139 | |
---|
1140 | $t_page_name = $page_name; |
---|
1141 | |
---|
1142 | //アクセスがゼロのページを取得する |
---|
1143 | foreach($page_name as $key=>$name) { |
---|
1144 | foreach($list as $value) { |
---|
1145 | if ($value['page_name'] == $name) { |
---|
1146 | unset($page_name[$key]);//$listに含まれるページネームを削除 |
---|
1147 | } |
---|
1148 | } |
---|
1149 | } |
---|
1150 | |
---|
1151 | foreach($page_name as $key=>$name) { |
---|
1152 | $page_name[$key] = array("page_name"=>$name, "count"=>0); |
---|
1153 | } |
---|
1154 | |
---|
1155 | if ($orderby == 2) { |
---|
1156 | $return = array_merge($page_name , $list); |
---|
1157 | } elseif ($orderby == -2) { |
---|
1158 | $return = array_merge($list, $page_name); |
---|
1159 | } |
---|
1160 | foreach($list as $value) { |
---|
1161 | $sum += $value['count']; |
---|
1162 | } |
---|
1163 | |
---|
1164 | foreach($return as $value) { |
---|
1165 | |
---|
1166 | list($is_target_c_member_id,$is_target_c_commu_id,$is_target_c_topic_id,$is_target_c_diary_id,$is_c_member_id) = get_is_show($value['page_name']); |
---|
1167 | |
---|
1168 | $value['is_target_c_member_id'] = $is_target_c_member_id; |
---|
1169 | $value['is_target_c_commu_id'] = $is_target_c_commu_id; |
---|
1170 | $value['is_target_c_topic_id'] = $is_target_c_topic_id; |
---|
1171 | $value['is_target_c_diary_id'] = $is_target_c_diary_id; |
---|
1172 | $value['is_c_member_id'] = $is_c_member_id; |
---|
1173 | $t_return[] = $value; |
---|
1174 | |
---|
1175 | } |
---|
1176 | |
---|
1177 | $return = $t_return; |
---|
1178 | |
---|
1179 | } |
---|
1180 | |
---|
1181 | return array($return, $sum); |
---|
1182 | } |
---|
1183 | |
---|
1184 | |
---|
1185 | /* |
---|
1186 | * target_commu |
---|
1187 | * |
---|
1188 | */ |
---|
1189 | function p_access_analysis_target_commu_target_commu4ym_page_name |
---|
1190 | ($ymd, $month_flag, $page_name, $ktai_flag, $page, $page_size, $orderby=1) |
---|
1191 | { |
---|
1192 | |
---|
1193 | $start = ($page - 1) * $page_size; |
---|
1194 | |
---|
1195 | if ($orderby == 1) { |
---|
1196 | $orderby_str = " order by target_c_commu_id asc"; |
---|
1197 | } elseif ($orderby == -1) { |
---|
1198 | $orderby_str = " order by target_c_commu_id desc"; |
---|
1199 | } elseif ($orderby == 2) { |
---|
1200 | $orderby_str = " order by count asc"; |
---|
1201 | } elseif ($orderby == -2) { |
---|
1202 | $orderby_str = " order by count desc"; |
---|
1203 | } |
---|
1204 | |
---|
1205 | $sql = "select target_c_commu_id , count(*) as count from c_access_log where ktai_flag = ? "; |
---|
1206 | $params = array(intval($ktai_flag)); |
---|
1207 | if ($month_flag) { |
---|
1208 | if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { |
---|
1209 | $sql .= " and substr(r_datetime,1,7) = ? "; |
---|
1210 | } else { |
---|
1211 | $sql .= " and left(r_datetime, 7) = ? "; |
---|
1212 | } |
---|
1213 | array_push($params,substr($ymd,0,7)); |
---|
1214 | } else { |
---|
1215 | if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { |
---|
1216 | $sql .= " and substr(r_datetime,1,10) = ? "; |
---|
1217 | } else { |
---|
1218 | $sql .= " and left(r_datetime,10) = ? "; |
---|
1219 | } |
---|
1220 | array_push($params,$ymd); |
---|
1221 | } |
---|
1222 | if ($page_name!="all") { |
---|
1223 | $sql .= " and page_name = ? "; |
---|
1224 | array_push($params,$page_name); |
---|
1225 | } |
---|
1226 | $sql .= " and target_c_commu_id <> 0 "; |
---|
1227 | |
---|
1228 | $sql .= " group by target_c_commu_id " .$orderby_str; |
---|
1229 | $list = db_get_all_limit($sql, $start, $page_size, $params); |
---|
1230 | |
---|
1231 | $return = array(); |
---|
1232 | $sum = 0; |
---|
1233 | foreach($list as $key => $value) { |
---|
1234 | if ($value['target_c_commu_id']) { |
---|
1235 | if ($c_commu = db_commu_c_commu4c_commu_id($value['target_c_commu_id'])) { |
---|
1236 | $return[] = array_merge($value, $c_commu); |
---|
1237 | $sum += $value['count']; |
---|
1238 | } |
---|
1239 | } |
---|
1240 | } |
---|
1241 | |
---|
1242 | $sql = "select count(*) from c_access_log where ktai_flag = ? "; |
---|
1243 | $params = array(intval($ktai_flag)); |
---|
1244 | if ($month_flag) { |
---|
1245 | if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { |
---|
1246 | $sql .= " and substr(r_datetime,1,7) = ? "; |
---|
1247 | } else { |
---|
1248 | $sql .= " and left(r_datetime, 7) = ? "; |
---|
1249 | } |
---|
1250 | array_push($params,substr($ymd,0,7)); |
---|
1251 | } else { |
---|
1252 | if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { |
---|
1253 | $sql .= " and substr(r_datetime,1,10) = ? "; |
---|
1254 | } else { |
---|
1255 | $sql .= " and left(r_datetime,10) = ? "; |
---|
1256 | } |
---|
1257 | array_push($params,$ymd); |
---|
1258 | } |
---|
1259 | if ($page_name!="all") { |
---|
1260 | $sql .= " and page_name = ? "; |
---|
1261 | array_push($params,$page_name); |
---|
1262 | } |
---|
1263 | $sql .= " and target_c_commu_id <> 0 "; |
---|
1264 | $sql .= " group by target_c_commu_id "; |
---|
1265 | $result = db_get_all($sql,$params); |
---|
1266 | $total_num = count($result); |
---|
1267 | |
---|
1268 | if ($total_num != 0) { |
---|
1269 | $total_page_num = ceil($total_num / $page_size); |
---|
1270 | if ($page >= $total_page_num) { |
---|
1271 | $next = false; |
---|
1272 | }else{ |
---|
1273 | $next = true; |
---|
1274 | } |
---|
1275 | if ($page <= 1) { |
---|
1276 | $prev = false; |
---|
1277 | }else{ |
---|
1278 | $prev = true; |
---|
1279 | } |
---|
1280 | } |
---|
1281 | $start_num = ($page - 1) * $page_size + 1 ; |
---|
1282 | $end_num = ($page - 1) * $page_size + $page_size > $total_num ? $total_num : ($page - 1) * $page_size + $page_size ; |
---|
1283 | |
---|
1284 | return array($return, $sum, $prev, $next, $total_num, $start_num, $end_num); |
---|
1285 | } |
---|
1286 | |
---|
1287 | function p_access_analysis_target_topic_target_topic4ym_page_name |
---|
1288 | ($ymd, $month_flag, $page_name, $ktai_flag, $page, $page_size, $orderby=1) |
---|
1289 | { |
---|
1290 | $start = ($page - 1) * $page_size; |
---|
1291 | |
---|
1292 | if ($orderby == 1) { |
---|
1293 | $orderby_str = " order by target_c_commu_topic_id asc"; |
---|
1294 | } elseif ($orderby == -1) { |
---|
1295 | $orderby_str = " order by target_c_commu_topic_id desc"; |
---|
1296 | } elseif ($orderby == 2) { |
---|
1297 | $orderby_str = " order by count asc"; |
---|
1298 | } elseif ($orderby == -2) { |
---|
1299 | $orderby_str = " order by count desc"; |
---|
1300 | } |
---|
1301 | $where =" where ktai_flag = ? "; |
---|
1302 | $params = array(intval($ktai_flag)); |
---|
1303 | if ($month_flag) { |
---|
1304 | if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { |
---|
1305 | $where .= " and substr(r_datetime,1, 7) = ? "; |
---|
1306 | } else { |
---|
1307 | $where .= " and left(r_datetime, 7) = ? "; |
---|
1308 | } |
---|
1309 | array_push($params,substr($ymd,0,7)); |
---|
1310 | } else { |
---|
1311 | if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { |
---|
1312 | $where .= " and substr(r_datetime,1,10) = ? "; |
---|
1313 | } else { |
---|
1314 | $where .= " and left(r_datetime,10) = ? "; |
---|
1315 | } |
---|
1316 | array_push($params,$ymd); |
---|
1317 | } |
---|
1318 | if ($page_name!="all") { |
---|
1319 | $where .= " and page_name = ? "; |
---|
1320 | array_push($params,$page_name); |
---|
1321 | } |
---|
1322 | $sql = "select target_c_commu_topic_id , count(*) as count from c_access_log "; |
---|
1323 | $sql .= $where." group by target_c_commu_topic_id " .$orderby_str; |
---|
1324 | $list = db_get_all_limit($sql, $start, $page_size, $params); |
---|
1325 | $sql = "select count(*) from c_access_log "; |
---|
1326 | $sql .= $where ." group by target_c_commu_topic_id "; |
---|
1327 | $result = db_get_all($sql,$params); |
---|
1328 | $total_num = count($result); |
---|
1329 | |
---|
1330 | $return = array(); |
---|
1331 | $sum = 0; |
---|
1332 | foreach ($list as $key => $value) { |
---|
1333 | if ($value['target_c_commu_topic_id']) { |
---|
1334 | if ($c_commu_topic = c_topic_detail_c_topic4c_commu_topic_id($value['target_c_commu_topic_id'])) { |
---|
1335 | $c_commu_topic['topic_name'] = $c_commu_topic['name']; |
---|
1336 | $c_commu = db_commu_c_commu4c_commu_id($c_commu_topic['c_commu_id']); |
---|
1337 | $c_commu_topic['commu_name'] = $c_commu['name']; |
---|
1338 | $return[] = array_merge($value, $c_commu_topic); |
---|
1339 | $sum += $value['count']; |
---|
1340 | } |
---|
1341 | } |
---|
1342 | } |
---|
1343 | |
---|
1344 | if ($total_num != 0) { |
---|
1345 | $total_page_num = ceil($total_num / $page_size); |
---|
1346 | if ($page >= $total_page_num) { |
---|
1347 | $next = false; |
---|
1348 | } else { |
---|
1349 | $next = true; |
---|
1350 | } |
---|
1351 | if ($page <= 1) { |
---|
1352 | $prev = false; |
---|
1353 | } else { |
---|
1354 | $prev = true; |
---|
1355 | } |
---|
1356 | } |
---|
1357 | $start_num = ($page - 1) * $page_size + 1 ; |
---|
1358 | $end_num = ($page - 1) * $page_size + $page_size > $total_num ? $total_num : ($page - 1) * $page_size + $page_size ; |
---|
1359 | |
---|
1360 | return array($return, $sum, $prev, $next, $total_num, $start_num, $end_num); |
---|
1361 | } |
---|
1362 | |
---|
1363 | function p_access_analysis_target_diary_target_diary4ym_page_name |
---|
1364 | ($ymd, $month_flag, $page_name, $ktai_flag, $page, $page_size, $orderby=1) |
---|
1365 | { |
---|
1366 | |
---|
1367 | $start = ($page - 1) * $page_size; |
---|
1368 | |
---|
1369 | if ($orderby == 1) { |
---|
1370 | $orderby_str = " order by target_c_diary_id asc"; |
---|
1371 | } elseif ($orderby == -1) { |
---|
1372 | $orderby_str = " order by target_c_diary_id desc"; |
---|
1373 | } elseif ($orderby == 2) { |
---|
1374 | $orderby_str = " order by count asc"; |
---|
1375 | } elseif ($orderby == -2) { |
---|
1376 | $orderby_str = " order by count desc"; |
---|
1377 | } |
---|
1378 | |
---|
1379 | $sql = "select target_c_diary_id , count(*) as count from c_access_log where ktai_flag = ? "; |
---|
1380 | $params = array(intval($ktai_flag)); |
---|
1381 | if ($month_flag) { |
---|
1382 | if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { |
---|
1383 | $sql .= " and substr(r_datetime,1,7) = ? "; |
---|
1384 | } else { |
---|
1385 | $sql .= " and left(r_datetime, 7) = ? "; |
---|
1386 | } |
---|
1387 | array_push($params,substr($ymd,0,7)); |
---|
1388 | } else { |
---|
1389 | if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { |
---|
1390 | $sql .= " and substr(r_datetime,1,10) = ? "; |
---|
1391 | } else { |
---|
1392 | $sql .= " and left(r_datetime,10) = ? "; |
---|
1393 | } |
---|
1394 | array_push($params,$ymd); |
---|
1395 | } |
---|
1396 | if ($page_name!="all") { |
---|
1397 | $sql .= " and page_name = ? "; |
---|
1398 | array_push($params,$page_name); |
---|
1399 | } |
---|
1400 | $sql .= " and target_c_diary_id <> 0 "; |
---|
1401 | $sql .= " group by target_c_diary_id " . $orderby_str; |
---|
1402 | $list = db_get_all_limit($sql, $start, $page_size, $params); |
---|
1403 | |
---|
1404 | $return = array(); |
---|
1405 | $sum = 0; |
---|
1406 | foreach ($list as $key => $value) { |
---|
1407 | if ($value['target_c_diary_id']) { |
---|
1408 | if ($c_diary = db_diary_get_c_diary4id($value['target_c_diary_id'])) { |
---|
1409 | $c_member = db_member_c_member4c_member_id($c_diary['c_member_id']); |
---|
1410 | $c_diary['nickname'] = $c_member['nickname']; |
---|
1411 | $return[] = array_merge($value, $c_diary); |
---|
1412 | $sum += $value['count']; |
---|
1413 | } |
---|
1414 | } |
---|
1415 | } |
---|
1416 | |
---|
1417 | $sql = "select count(*) from c_access_log where ktai_flag = ? "; |
---|
1418 | $params = array(intval($ktai_flag)); |
---|
1419 | if ($month_flag) { |
---|
1420 | if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { |
---|
1421 | $sql .= " and substr(r_datetime,1,7) = ? "; |
---|
1422 | } else { |
---|
1423 | $sql .= " and left(r_datetime, 7) = ? "; |
---|
1424 | } |
---|
1425 | array_push($params,substr($ymd,0,7)); |
---|
1426 | } else { |
---|
1427 | if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { |
---|
1428 | $sql .= " and substr(r_datetime,1,10) = ? "; |
---|
1429 | } else { |
---|
1430 | $sql .= " and left(r_datetime,10) = ? "; |
---|
1431 | } |
---|
1432 | array_push($params,$ymd); |
---|
1433 | } |
---|
1434 | $sql .= " and target_c_diary_id <> 0 "; |
---|
1435 | $sql .= " group by target_c_diary_id "; |
---|
1436 | $result = db_get_all($sql,$params); |
---|
1437 | $total_num = count($result); |
---|
1438 | |
---|
1439 | if ($total_num != 0) { |
---|
1440 | $total_page_num = ceil($total_num / $page_size); |
---|
1441 | if ($page >= $total_page_num) { |
---|
1442 | $next = false; |
---|
1443 | }else{ |
---|
1444 | $next = true; |
---|
1445 | } |
---|
1446 | if ($page <= 1) { |
---|
1447 | $prev = false; |
---|
1448 | }else{ |
---|
1449 | $prev = true; |
---|
1450 | } |
---|
1451 | } |
---|
1452 | $start_num = ($page - 1) * $page_size + 1 ; |
---|
1453 | $end_num = ($page - 1) * $page_size + $page_size > $total_num ? $total_num : ($page - 1) * $page_size + $page_size ; |
---|
1454 | |
---|
1455 | return array($return, $sum, $prev, $next, $total_num, $start_num, $end_num); |
---|
1456 | } |
---|
1457 | |
---|
1458 | function p_access_analysis_member_access_member4ym_page_name |
---|
1459 | ($ymd, $month_flag, $page_name, $ktai_flag, $page, $page_size, $orderby=1) |
---|
1460 | { |
---|
1461 | $start = ($page - 1) * $page_size; |
---|
1462 | |
---|
1463 | if ($orderby == 1) { |
---|
1464 | $orderby_str = " order by c_member_id asc"; |
---|
1465 | } elseif ($orderby == -1) { |
---|
1466 | $orderby_str = " order by c_member_id desc"; |
---|
1467 | } elseif ($orderby == 2) { |
---|
1468 | $orderby_str = " order by count asc"; |
---|
1469 | } elseif ($orderby == -2) { |
---|
1470 | $orderby_str = " order by count desc"; |
---|
1471 | } |
---|
1472 | |
---|
1473 | $where =" where ktai_flag = ? "; |
---|
1474 | $params = array(intval($ktai_flag)); |
---|
1475 | if ($month_flag) { |
---|
1476 | if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { |
---|
1477 | $where .= " and substr(r_datetime,1,7) = ? "; |
---|
1478 | } else { |
---|
1479 | $where .= " and left(r_datetime, 7) = ? "; |
---|
1480 | } |
---|
1481 | array_push($params,substr($ymd,0,7)); |
---|
1482 | } else { |
---|
1483 | if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { |
---|
1484 | $where .= " and substr(r_datetime,1,10) = ? "; |
---|
1485 | } else { |
---|
1486 | $where .= " and left(r_datetime,10) = ? "; |
---|
1487 | } |
---|
1488 | array_push($params,$ymd); |
---|
1489 | } |
---|
1490 | if ($page_name!="all") { |
---|
1491 | $where .= " and page_name = ? "; |
---|
1492 | array_push($params,$page_name); |
---|
1493 | } |
---|
1494 | |
---|
1495 | $sql = "select c_member_id , count(*) as count from c_access_log"; |
---|
1496 | $sql .= $where." group by c_member_id $orderby_str"; |
---|
1497 | $list = db_get_all_limit($sql, $start, $page_size, $params); |
---|
1498 | $sql = "select count(*) from c_access_log "; |
---|
1499 | $sql .= $where ." group by c_member_id "; |
---|
1500 | $result = db_get_all($sql,$params); |
---|
1501 | $total_num = count($result); |
---|
1502 | |
---|
1503 | $return = array(); |
---|
1504 | $sum = 0; |
---|
1505 | foreach($list as $key => $value) { |
---|
1506 | if ($value['c_member_id']) { |
---|
1507 | if ($c_member = _db_c_member4c_member_id($value['c_member_id'])) { |
---|
1508 | $return[] = array_merge($value, $c_member); |
---|
1509 | $sum += $value['count']; |
---|
1510 | } |
---|
1511 | } |
---|
1512 | } |
---|
1513 | |
---|
1514 | |
---|
1515 | if ($total_num != 0) { |
---|
1516 | $total_page_num = ceil($total_num / $page_size); |
---|
1517 | if ($page >= $total_page_num) { |
---|
1518 | $next = false; |
---|
1519 | }else{ |
---|
1520 | $next = true; |
---|
1521 | } |
---|
1522 | if ($page <= 1) { |
---|
1523 | $prev = false; |
---|
1524 | }else{ |
---|
1525 | $prev = true; |
---|
1526 | } |
---|
1527 | } |
---|
1528 | $start_num = ($page - 1) * $page_size + 1 ; |
---|
1529 | $end_num = ($page - 1) * $page_size + $page_size > $total_num ? $total_num : ($page - 1) * $page_size + $page_size ; |
---|
1530 | return array($return, $sum, $prev, $next, $total_num, $start_num, $end_num); |
---|
1531 | } |
---|
1532 | |
---|
1533 | function p_access_analysis_target_member_access_member4ym_page_name |
---|
1534 | ($ymd, $month_flag, $page_name, $ktai_flag, $page, $page_size, $orderby=1) |
---|
1535 | { |
---|
1536 | $start = ($page - 1) * $page_size; |
---|
1537 | |
---|
1538 | if ($orderby == 1) { |
---|
1539 | $orderby_str = " order by target_c_member_id asc"; |
---|
1540 | } elseif ($orderby == -1) { |
---|
1541 | $orderby_str = " order by target_c_member_id desc"; |
---|
1542 | } elseif ($orderby == 2) { |
---|
1543 | $orderby_str = " order by count asc"; |
---|
1544 | } elseif ($orderby == -2) { |
---|
1545 | $orderby_str = " order by count desc"; |
---|
1546 | } |
---|
1547 | $where =" where ktai_flag = ? "; |
---|
1548 | $params = array(intval($ktai_flag)); |
---|
1549 | if ($month_flag) { |
---|
1550 | if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { |
---|
1551 | $where .= " and substr(r_datetime,1,7) = ? "; |
---|
1552 | } else { |
---|
1553 | $where .= " and left(r_datetime, 7) = ? "; |
---|
1554 | } |
---|
1555 | array_push($params,substr($ymd,0,7)); |
---|
1556 | } else { |
---|
1557 | if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { |
---|
1558 | $where .= " and substr(r_datetime,1,10) = ? "; |
---|
1559 | } else { |
---|
1560 | $where .= " and left(r_datetime,10) = ? "; |
---|
1561 | } |
---|
1562 | array_push($params,$ymd); |
---|
1563 | } |
---|
1564 | if ($page_name != "all") { |
---|
1565 | $where .= " and page_name = ? "; |
---|
1566 | array_push($params,$page_name); |
---|
1567 | } |
---|
1568 | $sql = "select target_c_member_id , count(*) as count from c_access_log "; |
---|
1569 | $sql .= $where; |
---|
1570 | $sql .= " AND target_c_member_id <> 0 "; |
---|
1571 | $sql .= " group by target_c_member_id " . $orderby_str; |
---|
1572 | |
---|
1573 | $list = db_get_all_limit($sql, $start, $page_size, $params); |
---|
1574 | |
---|
1575 | $return = array(); |
---|
1576 | $sum = 0; |
---|
1577 | foreach($list as $key => $value) { |
---|
1578 | if ($value['target_c_member_id']) { |
---|
1579 | if ($c_member = db_member_c_member4c_member_id($value['target_c_member_id'])) { |
---|
1580 | $return[] = array_merge($value, $c_member); |
---|
1581 | $sum += $value['count']; |
---|
1582 | } |
---|
1583 | } |
---|
1584 | } |
---|
1585 | |
---|
1586 | $where =" where ktai_flag = ? "; |
---|
1587 | $params = array(intval($ktai_flag)); |
---|
1588 | if ($month_flag) { |
---|
1589 | if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { |
---|
1590 | $where .= " and substr(r_datetime,1,7) = ? "; |
---|
1591 | } else { |
---|
1592 | $where .= " and left(r_datetime, 7) = ? "; |
---|
1593 | } |
---|
1594 | array_push($params,substr($ymd,0,7)); |
---|
1595 | } else { |
---|
1596 | if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { |
---|
1597 | $where .= " and substr(r_datetime,1,10) = ? "; |
---|
1598 | } else { |
---|
1599 | $where .= " and left(r_datetime,10) = ? "; |
---|
1600 | } |
---|
1601 | array_push($params,$ymd); |
---|
1602 | } |
---|
1603 | if ($page_name != "all") { |
---|
1604 | $where .= " and page_name = ? "; |
---|
1605 | array_push($params,$page_name); |
---|
1606 | } |
---|
1607 | $sql = "select count(*) from c_access_log " ; |
---|
1608 | $sql .= $where; |
---|
1609 | $sql .= " AND target_c_member_id <> 0 "; |
---|
1610 | $sql .= " group by target_c_member_id "; |
---|
1611 | |
---|
1612 | $result = db_get_all($sql,$params); |
---|
1613 | $total_num = count($result); |
---|
1614 | |
---|
1615 | if ($total_num != 0) { |
---|
1616 | $total_page_num = ceil($total_num / $page_size); |
---|
1617 | if ($page >= $total_page_num) { |
---|
1618 | $next = false; |
---|
1619 | } else { |
---|
1620 | $next = true; |
---|
1621 | } |
---|
1622 | if ($page <= 1) { |
---|
1623 | $prev = false; |
---|
1624 | } else { |
---|
1625 | $prev = true; |
---|
1626 | } |
---|
1627 | } |
---|
1628 | $start_num = ($page - 1) * $page_size + 1 ; |
---|
1629 | $end_num = ($page - 1) * $page_size + $page_size > $total_num ? $total_num : ($page - 1) * $page_size + $page_size ; |
---|
1630 | |
---|
1631 | return array($return, $sum, $prev, $next, $total_num, $start_num, $end_num); |
---|
1632 | } |
---|
1633 | |
---|
1634 | function get_is_show($name) |
---|
1635 | { |
---|
1636 | |
---|
1637 | $is_target_c_member_id = 0; |
---|
1638 | $is_target_c_commu_id = 0; |
---|
1639 | $is_target_c_topic_id = 0; |
---|
1640 | $is_target_c_diary_id = 0; |
---|
1641 | $is_c_member_id = 1; |
---|
1642 | |
---|
1643 | |
---|
1644 | //必要のない詳細ボタンを消す |
---|
1645 | $list = explode("_", $name); |
---|
1646 | $is_c_member_id = 1; |
---|
1647 | |
---|
1648 | if (strpos($list[0], 'f') !== false) { |
---|
1649 | $is_target_c_member_id = 1; |
---|
1650 | } |
---|
1651 | if (strpos($list[0], 'c') !== false) { |
---|
1652 | $is_target_c_commu_id = 1; |
---|
1653 | } |
---|
1654 | |
---|
1655 | if (strpos($name, 'topic') !== false || strpos($name, 'event') !== false) { |
---|
1656 | $is_target_c_topic_id = 1; |
---|
1657 | } |
---|
1658 | if (strpos($name, 'diary') !== false) { |
---|
1659 | $is_target_c_diary_id = 1; |
---|
1660 | } |
---|
1661 | |
---|
1662 | |
---|
1663 | return array($is_target_c_member_id,$is_target_c_commu_id,$is_target_c_topic_id,$is_target_c_diary_id,$is_c_member_id); |
---|
1664 | |
---|
1665 | } |
---|
1666 | |
---|
1667 | /** |
---|
1668 | |
---|
1669 | カラムごとに条件を指定して絞ったメンバーの一覧を返す |
---|
1670 | |
---|
1671 | [引数] |
---|
1672 | 適時追加していく |
---|
1673 | |
---|
1674 | $s_access_date 最終ログイン時刻 開始年月日 |
---|
1675 | $e_access_date 最終ログイン時刻 終了年月日 |
---|
1676 | |
---|
1677 | [返り値] |
---|
1678 | c_member_list |
---|
1679 | |
---|
1680 | */ |
---|
1681 | function p_member_edit_c_member_list($page_size, $page, $s_access_date='', $e_access_date='') |
---|
1682 | { |
---|
1683 | $page = intval($page); |
---|
1684 | $page_size = intval($page_size); |
---|
1685 | |
---|
1686 | $wheres = array(); |
---|
1687 | $params = array(); |
---|
1688 | |
---|
1689 | //指定された条件で絞っていく |
---|
1690 | if ($s_access_date != '') { |
---|
1691 | $wheres[] = 'access_date >= ?'; |
---|
1692 | $params[] = $s_access_date; |
---|
1693 | } |
---|
1694 | |
---|
1695 | if ($e_access_date != '') { |
---|
1696 | $wheres[] = 'access_date < ?'; |
---|
1697 | $params[] = $e_access_date; |
---|
1698 | } |
---|
1699 | |
---|
1700 | if ($wheres) { |
---|
1701 | $where = ' WHERE ' . implode(' AND ', $wheres); |
---|
1702 | } else { |
---|
1703 | $where = ''; |
---|
1704 | } |
---|
1705 | |
---|
1706 | $select = "SELECT * FROM c_member"; |
---|
1707 | $order = " order by c_member_id"; |
---|
1708 | $sql = $select . $where . $order; |
---|
1709 | if ($page_size > 0) { |
---|
1710 | $list = db_get_all_page($sql, $page, $page_size, $params); |
---|
1711 | } else { |
---|
1712 | $list = db_get_all($sql, $params); |
---|
1713 | } |
---|
1714 | |
---|
1715 | $sql = "select count(*) from c_member".$where; |
---|
1716 | |
---|
1717 | $total_num = db_get_one($sql, $params); |
---|
1718 | |
---|
1719 | if ($total_num != 0 && $page_size != 0) { |
---|
1720 | $total_page_num = ceil($total_num / $page_size); |
---|
1721 | if ($page >= $total_page_num) { |
---|
1722 | $next = false; |
---|
1723 | } else { |
---|
1724 | $next = true; |
---|
1725 | } |
---|
1726 | if ($page <= 1) { |
---|
1727 | $prev = false; |
---|
1728 | } else { |
---|
1729 | $prev = true; |
---|
1730 | } |
---|
1731 | } |
---|
1732 | |
---|
1733 | return array($list , $prev , $next, $total_num); |
---|
1734 | } |
---|
1735 | |
---|
1736 | function _db_c_member4c_member_id($c_member_id) |
---|
1737 | { |
---|
1738 | $sql = "SELECT * FROM c_member WHERE c_member_id= ? "; |
---|
1739 | $params = array(intval($c_member_id)); |
---|
1740 | return db_get_row($sql,$params); |
---|
1741 | } |
---|
1742 | |
---|
1743 | /** |
---|
1744 | * 男と女の人数を取得 |
---|
1745 | */ |
---|
1746 | function get_analysis_sex() |
---|
1747 | { |
---|
1748 | $sql = "select count(*) from c_member where sex = '男'"; |
---|
1749 | $analysis_sex['male'] = get_one4db($sql); |
---|
1750 | $sql = "select count(*) from c_member where sex = '女'"; |
---|
1751 | $analysis_sex['female'] = get_one4db($sql); |
---|
1752 | |
---|
1753 | return $analysis_sex; |
---|
1754 | |
---|
1755 | } |
---|
1756 | |
---|
1757 | /** |
---|
1758 | * 世代の人数を取得 |
---|
1759 | */ |
---|
1760 | function get_analysis_generation() |
---|
1761 | { |
---|
1762 | $analysis_generation = array( |
---|
1763 | '0~9' => 0, |
---|
1764 | '10~19' => 0, |
---|
1765 | '20~29' => 0, |
---|
1766 | '30~39' => 0, |
---|
1767 | '40~49' => 0, |
---|
1768 | '50~59' => 0, |
---|
1769 | '60~69' => 0, |
---|
1770 | '70~79' => 0, |
---|
1771 | '80~' =>0 |
---|
1772 | ); |
---|
1773 | |
---|
1774 | if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { |
---|
1775 | $sql = "SELECT ((date_part('year', now()) - birth_year)- " . |
---|
1776 | "cast(substring(CURRENT_DATE,'.....$')<(to_char(birth_month, '00') || '-' || to_char(birth_day, '00')) as int)) " . |
---|
1777 | "AS age FROM c_member WHERE birth_year <> 0;"; |
---|
1778 | } else { |
---|
1779 | $today = getdate(); |
---|
1780 | $mmdd = $today['mon'] * 100 + $today['mday']; |
---|
1781 | $sql = 'SELECT ' . $today['year'] . ' - birth_year' |
---|
1782 | . ' - (' . $mmdd . ' < (birth_month * 100 + birth_day))' |
---|
1783 | . ' AS age FROM c_member WHERE birth_year <> 0'; |
---|
1784 | } |
---|
1785 | $lst = db_get_all($sql); |
---|
1786 | |
---|
1787 | $temp = array_keys($analysis_generation); |
---|
1788 | foreach($lst as $value) { |
---|
1789 | $key = (int)($value['age'] / 10); |
---|
1790 | if ($key > count($analysis_generation)-1) { |
---|
1791 | $analysis_generation[$temp[count($analysis_generation)-1]]++; |
---|
1792 | } else { |
---|
1793 | $analysis_generation[$temp[$key]]++; |
---|
1794 | } |
---|
1795 | } |
---|
1796 | |
---|
1797 | return $analysis_generation; |
---|
1798 | |
---|
1799 | } |
---|
1800 | |
---|
1801 | /** |
---|
1802 | * 地域別の人数を取得 |
---|
1803 | */ |
---|
1804 | function get_analysis_region() |
---|
1805 | { |
---|
1806 | $pref = p_regist_prof_c_profile_pref_list4null(); |
---|
1807 | $sql = "select pre_addr_c_profile_pref_id as pref_id from c_member"; |
---|
1808 | $lst = get_array_list4db($sql); |
---|
1809 | |
---|
1810 | foreach($pref as $value) { |
---|
1811 | $analysis_region[$value] = 0; |
---|
1812 | } |
---|
1813 | |
---|
1814 | foreach ($lst as $value) { |
---|
1815 | if ($value['pref_id'] == 0) { |
---|
1816 | $analysis_region['その他']++; |
---|
1817 | } else { |
---|
1818 | $analysis_region[$pref[$value['pref_id']]]++; |
---|
1819 | } |
---|
1820 | } |
---|
1821 | |
---|
1822 | return $analysis_region; |
---|
1823 | |
---|
1824 | } |
---|
1825 | |
---|
1826 | function get_analysis_date_month($year = "", $month = "") |
---|
1827 | { |
---|
1828 | if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { |
---|
1829 | $sql = "select to_char(r_date,'YYYY-MM') from c_member order by r_date"; |
---|
1830 | } else { |
---|
1831 | $sql = "select date_format(r_date,'%Y-%m') from c_member order by r_date"; |
---|
1832 | } |
---|
1833 | $start_date = db_get_one($sql); |
---|
1834 | |
---|
1835 | $i = 0; |
---|
1836 | list($y, $m) = split("-",$start_date); |
---|
1837 | do{ |
---|
1838 | $date = date("Y-m", mktime (0,0,0,$m+$i++,1,$y)); |
---|
1839 | $analysis_date_month[$date] = 0; |
---|
1840 | }while($date < date("Y-m")); |
---|
1841 | |
---|
1842 | if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { |
---|
1843 | $sql = "select to_char(r_date,'YYYY-MM') as d from c_member"; |
---|
1844 | } else { |
---|
1845 | $sql = "select date_format(r_date,'%Y-%m') as d from c_member"; |
---|
1846 | } |
---|
1847 | $lst = db_get_all($sql); |
---|
1848 | foreach ($lst as $value) { |
---|
1849 | $analysis_date_month[$value['d']]++; |
---|
1850 | } |
---|
1851 | return $analysis_date_month; |
---|
1852 | } |
---|
1853 | |
---|
1854 | function get_analysis_date_day_d($date="") |
---|
1855 | { |
---|
1856 | if ($date == "") { |
---|
1857 | $date = date("Y-m-d"); |
---|
1858 | } |
---|
1859 | return $date; |
---|
1860 | } |
---|
1861 | |
---|
1862 | |
---|
1863 | function get_analysis_date_day($date="") |
---|
1864 | { |
---|
1865 | if ($date == "") { |
---|
1866 | $date = date("Y-m"); |
---|
1867 | } |
---|
1868 | //一ヶ月の日数 |
---|
1869 | $day_num = date("t"); |
---|
1870 | |
---|
1871 | for($i=1 ; $i<=$day_num; $i++) { |
---|
1872 | //一桁の数を二桁にする |
---|
1873 | if ($i < 10) { |
---|
1874 | $i = "0".$i; |
---|
1875 | } |
---|
1876 | $analysis_date_day[$i] = 0; |
---|
1877 | } |
---|
1878 | |
---|
1879 | if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { |
---|
1880 | $sql = "select to_char(r_date,'DD') as d from c_member where to_char(r_date,'YYYY-MM') = ?"; |
---|
1881 | } else { |
---|
1882 | $sql = "select date_format(r_date,'%d') as d from c_member where date_format(r_date,'%Y-%m') = ?"; |
---|
1883 | } |
---|
1884 | $params = array($date); |
---|
1885 | $lst = db_get_all($sql,$params); |
---|
1886 | |
---|
1887 | foreach($lst as $value) { |
---|
1888 | $analysis_date_day[$value['d']]++; |
---|
1889 | } |
---|
1890 | |
---|
1891 | return $analysis_date_day; |
---|
1892 | } |
---|
1893 | |
---|
1894 | function p_access_analysis_select_profile_list() |
---|
1895 | { |
---|
1896 | $sql = "SELECT * " . |
---|
1897 | " FROM c_profile " . |
---|
1898 | " where form_type = 'select' "; |
---|
1899 | |
---|
1900 | $list = db_get_all($sql); |
---|
1901 | return $list; |
---|
1902 | } |
---|
1903 | |
---|
1904 | /** |
---|
1905 | * 指定されたIDのプロフィールの人数別一覧を作成 |
---|
1906 | */ |
---|
1907 | function get_analysis_profile($c_profile_id) |
---|
1908 | { |
---|
1909 | $sql = "select count(*) as count,value,c_profile.caption from c_member_profile " . |
---|
1910 | " LEFT JOIN c_profile ON c_profile.c_profile_id = c_member_profile.c_profile_id " . |
---|
1911 | " WHERE c_member_profile.c_profile_id = ? GROUP BY value "; |
---|
1912 | $params = array(intval($c_profile_id)); |
---|
1913 | $analysis_profile = db_get_all($sql,$params); |
---|
1914 | |
---|
1915 | return $analysis_profile; |
---|
1916 | } |
---|
1917 | |
---|
1918 | function get_analysis_count_profile_all($c_profile_id) |
---|
1919 | { |
---|
1920 | $sql = "select count(*) as count from c_member_profile " . |
---|
1921 | " WHERE c_profile_id = ? "; |
---|
1922 | $params = array(intval($c_profile_id)); |
---|
1923 | $analysis_profile = db_get_one($sql,$params); |
---|
1924 | |
---|
1925 | return $analysis_profile; |
---|
1926 | } |
---|
1927 | |
---|
1928 | function analysis_profile4c_profile_id($c_profile_id) |
---|
1929 | { |
---|
1930 | $sql = "SELECT * FROM c_profile" . |
---|
1931 | " WHERE c_profile_id = ? "; |
---|
1932 | $params = array(intval($c_profile_id)); |
---|
1933 | $profile = db_get_row($sql,$params); |
---|
1934 | |
---|
1935 | return $profile; |
---|
1936 | } |
---|
1937 | |
---|
1938 | function monitor_diary_list($keyword, $page_size, $page) |
---|
1939 | { |
---|
1940 | $page = intval($page); |
---|
1941 | $page_size = intval($page_size); |
---|
1942 | |
---|
1943 | $wheres = array(); |
---|
1944 | |
---|
1945 | if ($keyword) { |
---|
1946 | //全角空白を半角に統一 |
---|
1947 | $keyword = str_replace(' ', ' ', $keyword); |
---|
1948 | $keyword_list = explode(' ', $keyword); |
---|
1949 | |
---|
1950 | for ($i = 0; $i < count($keyword_list); $i++) { |
---|
1951 | $keyword = check_search_word($keyword_list[$i]); |
---|
1952 | |
---|
1953 | $wheres[] = '(subject LIKE ? OR body LIKE ?)'; |
---|
1954 | $params[] = '%' . $keyword . '%'; |
---|
1955 | $params[] = '%' . $keyword . '%'; |
---|
1956 | } |
---|
1957 | } |
---|
1958 | if ($wheres) { |
---|
1959 | $where = ' WHERE ' . implode(' AND ', $wheres); |
---|
1960 | } else { |
---|
1961 | $where = ''; |
---|
1962 | } |
---|
1963 | |
---|
1964 | $select = "SELECT *"; |
---|
1965 | $from = " FROM c_diary"; |
---|
1966 | $order = " ORDER BY r_datetime DESC"; |
---|
1967 | |
---|
1968 | $sql = $select . $from . $where . $order; |
---|
1969 | $list = db_get_all_limit($sql,($page-1)*$page_size,$page_size,$params); |
---|
1970 | foreach ($list as $key => $value) { |
---|
1971 | $list[$key]['c_member'] = db_member_c_member_with_profile($value['c_member_id']); |
---|
1972 | $list[$key]['count_comments'] = db_diary_count_c_diary_comment4c_diary_id($value['c_diary_id']); |
---|
1973 | } |
---|
1974 | |
---|
1975 | $sql = |
---|
1976 | "SELECT COUNT(*) " |
---|
1977 | . $from |
---|
1978 | . $where ; |
---|
1979 | $total_num = db_get_one($sql, $params); |
---|
1980 | |
---|
1981 | $total_page_num = ceil($total_num / $page_size); |
---|
1982 | $next = ($page < $total_page_num); |
---|
1983 | $prev = ($page > 1); |
---|
1984 | |
---|
1985 | return array($list , $prev , $next, $total_num, $total_page_num); |
---|
1986 | } |
---|
1987 | |
---|
1988 | function monitor_diary_list4c_diary_id($c_diary_id, $page_size, $page) |
---|
1989 | { |
---|
1990 | $page = intval($page); |
---|
1991 | $page_size = intval($page_size); |
---|
1992 | |
---|
1993 | $where = " WHERE c_diary_id = ? "; |
---|
1994 | $params[] = intval($c_diary_id); |
---|
1995 | |
---|
1996 | $select = "SELECT c_diary.*"; |
---|
1997 | $from = " FROM c_diary"; |
---|
1998 | $order = " ORDER BY r_datetime DESC"; |
---|
1999 | |
---|
2000 | $sql = $select . $from . $where . $order; |
---|
2001 | $list = db_get_all_limit($sql,($page-1)*$page_size,$page_size,$params); |
---|
2002 | foreach ($list as $key => $value) { |
---|
2003 | $list[$key]['c_member'] = db_member_c_member_with_profile($value['c_member_id']); |
---|
2004 | $list[$key]['count_comments'] = db_diary_count_c_diary_comment4c_diary_id($value['c_diary_id']); |
---|
2005 | } |
---|
2006 | |
---|
2007 | $sql = |
---|
2008 | "SELECT COUNT(*) " |
---|
2009 | . $from |
---|
2010 | . $where ; |
---|
2011 | $total_num = db_get_one($sql, $params); |
---|
2012 | |
---|
2013 | $total_page_num = ceil($total_num / $page_size); |
---|
2014 | $next = ($page < $total_page_num); |
---|
2015 | $prev = ($page > 1); |
---|
2016 | |
---|
2017 | return array($list , $prev , $next, $total_num, $total_page_num); |
---|
2018 | } |
---|
2019 | |
---|
2020 | function monitor_diary_comment_list($keyword, $page_size, $page) |
---|
2021 | { |
---|
2022 | $page = intval($page); |
---|
2023 | $page_size = intval($page_size); |
---|
2024 | |
---|
2025 | $wheres = array(); |
---|
2026 | |
---|
2027 | if ($keyword) { |
---|
2028 | //全角空白を半角に統一 |
---|
2029 | $keyword = str_replace(' ', ' ', $keyword); |
---|
2030 | $keyword_list = explode(' ', $keyword); |
---|
2031 | |
---|
2032 | for($i = 0; $i < count($keyword_list); $i++) { |
---|
2033 | $keyword = check_search_word($keyword_list[$i]); |
---|
2034 | |
---|
2035 | $wheres[] = 'c_diary_comment.body LIKE ?'; |
---|
2036 | $params[] = '%' . $keyword . '%'; |
---|
2037 | } |
---|
2038 | } |
---|
2039 | |
---|
2040 | if ($wheres) { |
---|
2041 | $where = ' WHERE ' . implode(' AND ', $wheres); |
---|
2042 | } else { |
---|
2043 | $where = ''; |
---|
2044 | } |
---|
2045 | |
---|
2046 | $select = "SELECT c_diary_comment.*, c_diary.subject"; |
---|
2047 | $from = " FROM c_diary_comment" |
---|
2048 | ." LEFT JOIN c_diary ON c_diary.c_diary_id = c_diary_comment.c_diary_id "; |
---|
2049 | $order = " ORDER BY r_datetime desc"; |
---|
2050 | |
---|
2051 | $sql = $select . $from . $where . $order; |
---|
2052 | $list = db_get_all_limit($sql,($page-1)*$page_size,$page_size,$params); |
---|
2053 | foreach ($list as $key => $value) { |
---|
2054 | $list[$key]['c_member'] = db_member_c_member_with_profile($value['c_member_id']); |
---|
2055 | $list[$key]['count_comments'] = db_diary_count_c_diary_comment4c_diary_id($value['c_diary_id']); |
---|
2056 | } |
---|
2057 | |
---|
2058 | $sql = |
---|
2059 | "SELECT COUNT(*) " |
---|
2060 | . $from |
---|
2061 | . $where ; |
---|
2062 | $total_num = db_get_one($sql, $params); |
---|
2063 | |
---|
2064 | $total_page_num = ceil($total_num / $page_size); |
---|
2065 | $next = ($page < $total_page_num); |
---|
2066 | $prev = ($page > 1); |
---|
2067 | |
---|
2068 | return array($list , $prev , $next, $total_num, $total_page_num); |
---|
2069 | } |
---|
2070 | |
---|
2071 | function monitor_diary_comment_list4c_diary_comment_id($c_diary_comment_id, $page_size, $page) |
---|
2072 | { |
---|
2073 | $page = intval($page); |
---|
2074 | $page_size = intval($page_size); |
---|
2075 | |
---|
2076 | $where = " WHERE c_diary_comment.c_diary_comment_id = ? "; |
---|
2077 | $params[] = intval($c_diary_comment_id); |
---|
2078 | |
---|
2079 | $select = "SELECT c_diary_comment.*, c_diary.subject"; |
---|
2080 | $from = " FROM c_diary_comment" |
---|
2081 | ." LEFT JOIN c_diary ON c_diary.c_diary_id = c_diary_comment.c_diary_id "; |
---|
2082 | $order = " ORDER BY r_datetime desc"; |
---|
2083 | |
---|
2084 | $sql = $select . $from . $where . $order; |
---|
2085 | $list = db_get_all_limit($sql,($page-1)*$page_size,$page_size,$params); |
---|
2086 | |
---|
2087 | foreach ($list as $key => $value) { |
---|
2088 | $list[$key]['c_member'] = db_member_c_member_with_profile($value['c_member_id']); |
---|
2089 | $list[$key]['count_comments'] = db_diary_count_c_diary_comment4c_diary_id($value['c_diary_id']); |
---|
2090 | } |
---|
2091 | |
---|
2092 | $sql = |
---|
2093 | "SELECT COUNT(*) " |
---|
2094 | . $from |
---|
2095 | . $where ; |
---|
2096 | $total_num = db_get_one($sql, $params); |
---|
2097 | |
---|
2098 | $total_page_num = ceil($total_num / $page_size); |
---|
2099 | $next = ($page < $total_page_num); |
---|
2100 | $prev = ($page > 1); |
---|
2101 | |
---|
2102 | return array($list , $prev , $next, $total_num, $total_page_num); |
---|
2103 | } |
---|
2104 | |
---|
2105 | function monitor_diary_comment_list4c_diary_id($c_diary_id, $page_size, $page) |
---|
2106 | { |
---|
2107 | $page = intval($page); |
---|
2108 | $page_size = intval($page_size); |
---|
2109 | |
---|
2110 | $where = " WHERE c_diary_comment.c_diary_id = ? "; |
---|
2111 | $params[] = intval($c_diary_id); |
---|
2112 | |
---|
2113 | $select = "SELECT c_diary_comment.*, c_diary.subject"; |
---|
2114 | $from = " FROM c_diary_comment" |
---|
2115 | ." LEFT JOIN c_diary ON c_diary.c_diary_id = c_diary_comment.c_diary_id "; |
---|
2116 | $order = " ORDER BY r_datetime desc"; |
---|
2117 | |
---|
2118 | $sql = $select . $from . $where . $order; |
---|
2119 | $list = db_get_all_limit($sql,($page-1)*$page_size,$page_size,$params); |
---|
2120 | |
---|
2121 | foreach ($list as $key => $value) { |
---|
2122 | $list[$key]['c_member'] = db_member_c_member_with_profile($value['c_member_id']); |
---|
2123 | $list[$key]['count_comments'] = db_diary_count_c_diary_comment4c_diary_id($value['c_diary_id']); |
---|
2124 | } |
---|
2125 | |
---|
2126 | $sql = |
---|
2127 | "SELECT COUNT(*) " |
---|
2128 | . $from |
---|
2129 | . $where ; |
---|
2130 | $total_num = db_get_one($sql, $params); |
---|
2131 | |
---|
2132 | $total_page_num = ceil($total_num / $page_size); |
---|
2133 | $next = ($page < $total_page_num); |
---|
2134 | $prev = ($page > 1); |
---|
2135 | |
---|
2136 | return array($list , $prev , $next, $total_num, $total_page_num); |
---|
2137 | } |
---|
2138 | |
---|
2139 | function monitor_commu_list($keyword, $page_size, $page) |
---|
2140 | { |
---|
2141 | $page = intval($page); |
---|
2142 | $page_size = intval($page_size); |
---|
2143 | |
---|
2144 | $wheres = array(); |
---|
2145 | |
---|
2146 | if ($keyword) { |
---|
2147 | $keyword = str_replace(' ', ' ', $keyword); |
---|
2148 | $keyword_list = explode(' ', $keyword); |
---|
2149 | |
---|
2150 | for($i = 0; $i < count($keyword_list); $i++) { |
---|
2151 | $keyword = check_search_word($keyword_list[$i]); |
---|
2152 | |
---|
2153 | $wheres[] = '(name LIKE ? OR info LIKE ?)'; |
---|
2154 | $params[] = '%' . $keyword . '%'; |
---|
2155 | $params[] = '%' . $keyword . '%'; |
---|
2156 | } |
---|
2157 | } |
---|
2158 | |
---|
2159 | if ($wheres) { |
---|
2160 | $where = ' WHERE ' . implode(' AND ', $wheres); |
---|
2161 | } else { |
---|
2162 | $where = ''; |
---|
2163 | } |
---|
2164 | |
---|
2165 | $select = "SELECT * "; |
---|
2166 | $from = " FROM c_commu"; |
---|
2167 | $order = " ORDER BY r_datetime DESC"; |
---|
2168 | |
---|
2169 | $sql = $select . $from . $where . $order; |
---|
2170 | |
---|
2171 | $list = db_get_all_limit($sql,($page-1)*$page_size,$page_size,$params); |
---|
2172 | |
---|
2173 | foreach ($list as $key => $value) { |
---|
2174 | $list[$key]['c_member'] = db_member_c_member_with_profile($value['c_member_id_admin']); |
---|
2175 | } |
---|
2176 | |
---|
2177 | $sql = |
---|
2178 | "SELECT COUNT(*) " |
---|
2179 | . $from |
---|
2180 | . $where ; |
---|
2181 | $total_num = db_get_one($sql, $params); |
---|
2182 | |
---|
2183 | $total_page_num = ceil($total_num / $page_size); |
---|
2184 | $next = ($page < $total_page_num); |
---|
2185 | $prev = ($page > 1); |
---|
2186 | |
---|
2187 | return array($list, $prev, $next, $total_num, $total_page_num); |
---|
2188 | } |
---|
2189 | |
---|
2190 | function monitor_commu_list4c_commu_id($c_commu_id, $page_size, $page) |
---|
2191 | { |
---|
2192 | $page = intval($page); |
---|
2193 | $page_size = intval($page_size); |
---|
2194 | |
---|
2195 | $where = " WHERE c_commu_id = ? "; |
---|
2196 | $params[] = intval($c_commu_id); |
---|
2197 | |
---|
2198 | $select = "SELECT * "; |
---|
2199 | $from = " FROM c_commu"; |
---|
2200 | $order = " ORDER BY r_datetime DESC"; |
---|
2201 | |
---|
2202 | $sql = $select . $from . $where . $order; |
---|
2203 | |
---|
2204 | $list = db_get_all_limit($sql,($page-1)*$page_size,$page_size,$params); |
---|
2205 | |
---|
2206 | foreach ($list as $key => $value) { |
---|
2207 | $list[$key]['c_member'] = db_member_c_member_with_profile($value['c_member_id_admin']);; |
---|
2208 | } |
---|
2209 | |
---|
2210 | $sql = |
---|
2211 | "SELECT COUNT(*) " |
---|
2212 | . $from |
---|
2213 | . $where ; |
---|
2214 | $total_num = db_get_one($sql, $params); |
---|
2215 | |
---|
2216 | $total_page_num = ceil($total_num / $page_size); |
---|
2217 | $next = ($page < $total_page_num); |
---|
2218 | $prev = ($page > 1); |
---|
2219 | |
---|
2220 | return array($list , $prev , $next, $total_num, $total_page_num); |
---|
2221 | } |
---|
2222 | |
---|
2223 | function monitor_topic_comment_list($keyword, $page_size, $page) |
---|
2224 | { |
---|
2225 | $page = intval($page); |
---|
2226 | $page_size = intval($page_size); |
---|
2227 | |
---|
2228 | $where = " WHERE ctc.number <> 0 "; |
---|
2229 | |
---|
2230 | if ($keyword) { |
---|
2231 | $keyword = str_replace("?@", " ", $keyword); |
---|
2232 | $keyword_list = explode(" ", $keyword); |
---|
2233 | |
---|
2234 | for($i=0;$i < count($keyword_list);$i++) { |
---|
2235 | $keyword = check_search_word( $keyword_list[$i] ); |
---|
2236 | |
---|
2237 | $where .= " AND (ctc.body LIKE ? )"; |
---|
2238 | $params[]="%$keyword%"; |
---|
2239 | } |
---|
2240 | } |
---|
2241 | |
---|
2242 | $select = "SELECT ctc.*,ct.name as topic_name,c.name as commu_name"; |
---|
2243 | $from = " FROM c_commu_topic_comment as ctc" |
---|
2244 | ." LEFT JOIN c_commu_topic as ct ON ct.c_commu_topic_id = ctc.c_commu_topic_id " |
---|
2245 | ." LEFT JOIN c_commu as c ON c.c_commu_id = ct.c_commu_id "; |
---|
2246 | $order = " ORDER BY r_datetime desc"; |
---|
2247 | |
---|
2248 | $sql = $select . $from . $where . $order; |
---|
2249 | |
---|
2250 | $list = db_get_all_limit($sql,($page-1)*$page_size,$page_size,$params); |
---|
2251 | |
---|
2252 | foreach ($list as $key => $value) { |
---|
2253 | $list[$key]['count_comments'] = _db_count_c_commu_topic_comments4c_commu_topic_id($value['c_commu_topic_id']); |
---|
2254 | $c_member = db_member_c_member4c_member_id_LIGHT($value['c_member_id']); |
---|
2255 | $list[$key]['nickname'] = $c_member['nickname']; |
---|
2256 | $list[$key]['original_filename'] = db_file_original_filename4filename($value['filename']); |
---|
2257 | } |
---|
2258 | |
---|
2259 | $sql = |
---|
2260 | "SELECT COUNT(*) " |
---|
2261 | . $from |
---|
2262 | . $where ; |
---|
2263 | $total_num = db_get_one($sql, $params); |
---|
2264 | |
---|
2265 | $total_page_num = ceil($total_num / $page_size); |
---|
2266 | $next = ($page < $total_page_num); |
---|
2267 | $prev = ($page > 1); |
---|
2268 | |
---|
2269 | return array($list , $prev , $next, $total_num, $total_page_num); |
---|
2270 | } |
---|
2271 | |
---|
2272 | function monitor_topic_comment_list4c_commu_topic_comment_id($c_commu_topic_comment_id, $page_size, $page) |
---|
2273 | { |
---|
2274 | $page = intval($page); |
---|
2275 | $page_size = intval($page_size); |
---|
2276 | |
---|
2277 | $where = " WHERE ctc.number <> 0 AND ctc.c_commu_topic_comment_id = ? "; |
---|
2278 | $params[] = intval($c_commu_topic_comment_id); |
---|
2279 | |
---|
2280 | $select = "SELECT ctc.*,ct.name as topic_name,c.name as commu_name"; |
---|
2281 | $from = " FROM c_commu_topic_comment as ctc" |
---|
2282 | ." LEFT JOIN c_commu_topic as ct ON ct.c_commu_topic_id = ctc.c_commu_topic_id " |
---|
2283 | ." LEFT JOIN c_commu as c ON c.c_commu_id = ct.c_commu_id "; |
---|
2284 | $order = " ORDER BY r_datetime desc"; |
---|
2285 | |
---|
2286 | $sql = $select . $from . $where . $order; |
---|
2287 | |
---|
2288 | $list = db_get_all_limit($sql,($page-1)*$page_size,$page_size,$params); |
---|
2289 | |
---|
2290 | foreach ($list as $key => $value) { |
---|
2291 | $list[$key]['count_comments'] = _db_count_c_commu_topic_comments4c_commu_topic_id($value['c_commu_topic_id']); |
---|
2292 | $c_member = db_member_c_member4c_member_id_LIGHT($value['c_member_id']); |
---|
2293 | $list[$key]['nickname'] = $c_member['nickname']; |
---|
2294 | $list[$key]['original_filename'] = db_file_original_filename4filename($value['filename']); |
---|
2295 | } |
---|
2296 | |
---|
2297 | $sql = |
---|
2298 | "SELECT COUNT(*) " |
---|
2299 | . $from |
---|
2300 | . $where ; |
---|
2301 | $total_num = db_get_one($sql, $params); |
---|
2302 | |
---|
2303 | $total_page_num = ceil($total_num / $page_size); |
---|
2304 | $next = ($page < $total_page_num); |
---|
2305 | $prev = ($page > 1); |
---|
2306 | |
---|
2307 | return array($list , $prev , $next, $total_num, $total_page_num); |
---|
2308 | } |
---|
2309 | |
---|
2310 | function monitor_topic_list($keyword, $page_size, $page) |
---|
2311 | { |
---|
2312 | $page = intval($page); |
---|
2313 | $page_size = intval($page_size); |
---|
2314 | |
---|
2315 | $wheres = array(); |
---|
2316 | |
---|
2317 | if ($keyword) { |
---|
2318 | $keyword = str_replace(' ', ' ', $keyword); |
---|
2319 | $keyword_list = explode(' ', $keyword); |
---|
2320 | |
---|
2321 | for ($i = 0; $i < count($keyword_list); $i++) { |
---|
2322 | $keyword = check_search_word($keyword_list[$i]); |
---|
2323 | |
---|
2324 | $wheres[] = '(ctc.body like ? OR ct.name like ? OR c.name like ?)'; |
---|
2325 | $params[] = '%' . $keyword . '%'; |
---|
2326 | $params[] = '%' . $keyword . '%'; |
---|
2327 | $params[] = '%' . $keyword . '%'; |
---|
2328 | } |
---|
2329 | } |
---|
2330 | |
---|
2331 | if ($wheres) { |
---|
2332 | $where = ' WHERE ' . implode(' AND ', $wheres); |
---|
2333 | } else { |
---|
2334 | $where = ''; |
---|
2335 | } |
---|
2336 | |
---|
2337 | $select = "SELECT ct.*," . |
---|
2338 | "ct.name AS topic_name, c.name AS commu_name," . |
---|
2339 | "ctc.body, ctc.filename, ctc.image_filename1, ctc.image_filename2, ctc.image_filename3"; |
---|
2340 | |
---|
2341 | $from = " FROM c_commu_topic AS ct" |
---|
2342 | ." LEFT JOIN c_commu AS c ON c.c_commu_id = ct.c_commu_id " |
---|
2343 | ." LEFT JOIN c_commu_topic_comment AS ctc ON (ctc.c_commu_topic_id = ct.c_commu_topic_id AND ctc.number = 0)"; |
---|
2344 | |
---|
2345 | $order = " ORDER BY r_datetime desc"; |
---|
2346 | |
---|
2347 | $sql = $select . $from . $where . $order; |
---|
2348 | |
---|
2349 | $list = db_get_all_limit($sql,($page-1)*$page_size,$page_size,$params); |
---|
2350 | |
---|
2351 | foreach ($list as $key => $value) { |
---|
2352 | $list[$key]['count_comments'] = _db_count_c_commu_topic_comments4c_commu_topic_id($value['c_commu_topic_id']); |
---|
2353 | $c_member = db_member_c_member4c_member_id_LIGHT($value['c_member_id']); |
---|
2354 | $list[$key]['nickname'] = $c_member['nickname']; |
---|
2355 | if (!empty($value['filename'])) { |
---|
2356 | $list[$key]['original_filename'] = db_file_original_filename4filename($value['filename']); |
---|
2357 | } |
---|
2358 | } |
---|
2359 | |
---|
2360 | $sql = |
---|
2361 | "SELECT COUNT(*) " |
---|
2362 | . $from |
---|
2363 | . $where ; |
---|
2364 | $total_num = db_get_one($sql, $params); |
---|
2365 | |
---|
2366 | $total_page_num = ceil($total_num / $page_size); |
---|
2367 | $next = ($page < $total_page_num); |
---|
2368 | $prev = ($page > 1); |
---|
2369 | |
---|
2370 | return array($list , $prev , $next, $total_num, $total_page_num); |
---|
2371 | } |
---|
2372 | |
---|
2373 | function monitor_topic_list4target_c_commu_topic_id($c_commu_topic_id, $page_size, $page) |
---|
2374 | { |
---|
2375 | $page = intval($page); |
---|
2376 | $page_size = intval($page_size); |
---|
2377 | |
---|
2378 | $where = " where ct.c_commu_topic_id = ? "; |
---|
2379 | $params[] = intval($c_commu_topic_id); |
---|
2380 | |
---|
2381 | $select = "SELECT ct.*," . |
---|
2382 | "ct.name as topic_name,c.name as commu_name," . |
---|
2383 | "m.nickname,ctc.body as body," . |
---|
2384 | "ctc.image_filename1 as image_filename1,ctc.image_filename2 as image_filename2,ctc.image_filename3 as image_filename3," . |
---|
2385 | "ctc.filename as filename,f.original_filename as original_filename"; |
---|
2386 | |
---|
2387 | $from = " FROM c_commu_topic as ct" |
---|
2388 | ." LEFT JOIN c_member as m ON ct.c_member_id = m.c_member_id " |
---|
2389 | ." LEFT JOIN c_commu as c ON c.c_commu_id = ct.c_commu_id " |
---|
2390 | ." LEFT JOIN c_commu_topic_comment as ctc ON (ctc.c_commu_topic_id = ct.c_commu_topic_id AND ctc.number = 0)" |
---|
2391 | ." LEFT JOIN c_file as f ON f.filename = ctc.filename " |
---|
2392 | ; |
---|
2393 | $order = " ORDER BY r_datetime desc"; |
---|
2394 | |
---|
2395 | $sql = $select . $from . $where . $order; |
---|
2396 | |
---|
2397 | $list = db_get_all_limit($sql,($page-1)*$page_size,$page_size,$params); |
---|
2398 | |
---|
2399 | foreach ($list as $key => $value) { |
---|
2400 | $list[$key]['count_comments'] = _db_count_c_commu_topic_comments4c_commu_topic_id($value['c_commu_topic_id']); |
---|
2401 | } |
---|
2402 | |
---|
2403 | $sql = |
---|
2404 | "SELECT count(*) " |
---|
2405 | . $from |
---|
2406 | . $where ; |
---|
2407 | $total_num = db_get_one($sql, $params); |
---|
2408 | |
---|
2409 | $total_page_num = ceil($total_num / $page_size); |
---|
2410 | $next = ($page < $total_page_num); |
---|
2411 | $prev = ($page > 1); |
---|
2412 | |
---|
2413 | return array($list , $prev , $next, $total_num, $total_page_num); |
---|
2414 | } |
---|
2415 | |
---|
2416 | function monitor_review_list($keyword, $page_size, $page) |
---|
2417 | { |
---|
2418 | $page = intval($page); |
---|
2419 | $page_size = intval($page_size); |
---|
2420 | |
---|
2421 | $wheres = array(); |
---|
2422 | |
---|
2423 | if ($keyword) { |
---|
2424 | //全角空白を半角に統一 |
---|
2425 | $keyword = str_replace(' ', ' ', $keyword); |
---|
2426 | $keyword_list = explode(' ', $keyword); |
---|
2427 | |
---|
2428 | for ($i = 0; $i < count($keyword_list); $i++) { |
---|
2429 | $keyword = check_search_word($keyword_list[$i]); |
---|
2430 | |
---|
2431 | $wheres[] = 'c_review_comment.body like ?'; |
---|
2432 | $params[] = '%' . $keyword . '%'; |
---|
2433 | } |
---|
2434 | } |
---|
2435 | |
---|
2436 | if ($wheres) { |
---|
2437 | $where = ' WHERE ' . implode(' AND ', $wheres); |
---|
2438 | } else { |
---|
2439 | $where = ''; |
---|
2440 | } |
---|
2441 | |
---|
2442 | $select = "SELECT c_review_comment.*"; |
---|
2443 | $from = " FROM c_review_comment"; |
---|
2444 | $order = " ORDER BY r_datetime desc"; |
---|
2445 | |
---|
2446 | $sql = $select . $from . $where . $order; |
---|
2447 | $list = db_get_all_limit($sql,($page-1)*$page_size,$page_size,$params); |
---|
2448 | |
---|
2449 | |
---|
2450 | foreach ($list as $key => $value) { |
---|
2451 | $list[$key]['c_member'] = db_common_c_member4c_member_id_LIGHT($value['c_member_id']); |
---|
2452 | $list[$key]['c_review'] = db_review_list_product_c_review4c_review_id($value['c_review_id']); |
---|
2453 | } |
---|
2454 | |
---|
2455 | $sql = |
---|
2456 | "SELECT COUNT(*) " |
---|
2457 | . $from |
---|
2458 | . $where ; |
---|
2459 | $total_num = db_get_one($sql,$params); |
---|
2460 | |
---|
2461 | $total_page_num = ceil($total_num / $page_size); |
---|
2462 | $next = ($page < $total_page_num); |
---|
2463 | $prev = ($page > 1); |
---|
2464 | |
---|
2465 | return array($list , $prev , $next, $total_num, $total_page_num); |
---|
2466 | } |
---|
2467 | |
---|
2468 | function monitor_review_list4c_review_id($c_review_comment_id, $page_size, $page) |
---|
2469 | { |
---|
2470 | $page = intval($page); |
---|
2471 | $page_size = intval($page_size); |
---|
2472 | |
---|
2473 | $where = " WHERE c_review_comment_id = ? "; |
---|
2474 | $params[] = intval($c_review_comment_id); |
---|
2475 | |
---|
2476 | $select = "SELECT c_review_comment.*"; |
---|
2477 | $from = " FROM c_review_comment"; |
---|
2478 | $order = " ORDER BY r_datetime desc"; |
---|
2479 | |
---|
2480 | $sql = $select . $from . $where . $order; |
---|
2481 | $list = db_get_all_limit($sql,($page-1)*$page_size,$page_size,$params); |
---|
2482 | |
---|
2483 | foreach ($list as $key => $value) { |
---|
2484 | $list[$key]['c_member'] = db_common_c_member4c_member_id_LIGHT($value['c_member_id']); |
---|
2485 | $list[$key]['c_review'] = db_review_list_product_c_review4c_review_id($value['c_review_id']); |
---|
2486 | } |
---|
2487 | |
---|
2488 | $sql = |
---|
2489 | "SELECT COUNT(*) " |
---|
2490 | . $from |
---|
2491 | . $where ; |
---|
2492 | $total_num = db_get_one($sql, $params); |
---|
2493 | |
---|
2494 | $total_page_num = ceil($total_num / $page_size); |
---|
2495 | $next = ($page < $total_page_num); |
---|
2496 | $prev = ($page > 1); |
---|
2497 | |
---|
2498 | return array($list , $prev , $next, $total_num, $total_page_num); |
---|
2499 | } |
---|
2500 | |
---|
2501 | function _db_count_c_commu_topic_comments4c_commu_topic_id($c_commu_topic_id) |
---|
2502 | { |
---|
2503 | $sql = "SELECT count(*) FROM c_commu_topic_comment" . |
---|
2504 | " WHERE c_commu_topic_id = ? AND number > 0"; |
---|
2505 | $params = array($c_commu_topic_id); |
---|
2506 | return db_get_one($sql, $params); |
---|
2507 | } |
---|
2508 | //フリーページを追加 |
---|
2509 | function db_admin_insert_c_free_page($title, $body, $auth, $type) |
---|
2510 | { |
---|
2511 | $data = array( |
---|
2512 | 'title' => strval($title), |
---|
2513 | 'body' => strval($body), |
---|
2514 | 'auth' => intval($auth), |
---|
2515 | 'type' => strval($type), |
---|
2516 | ); |
---|
2517 | return db_insert('c_free_page', $data); |
---|
2518 | } |
---|
2519 | |
---|
2520 | //フリーページを編集 |
---|
2521 | function db_admin_update_c_free_page($c_free_page_id, $title, $body, $auth, $type) |
---|
2522 | { |
---|
2523 | $data = array( |
---|
2524 | 'title' => strval($title), |
---|
2525 | 'body' => strval($body), |
---|
2526 | 'auth' => intval($auth), |
---|
2527 | 'type' => strval($type), |
---|
2528 | ); |
---|
2529 | $where = array('c_free_page_id' => intval($c_free_page_id)); |
---|
2530 | return db_update('c_free_page', $data, $where); |
---|
2531 | } |
---|
2532 | |
---|
2533 | //フリーページを削除 |
---|
2534 | function db_admin_delete_c_free_page($c_free_page_id) |
---|
2535 | { |
---|
2536 | $sql = "DELETE FROM c_free_page WHERE c_free_page_id = ?"; |
---|
2537 | $params = array(intval($c_free_page_id)); |
---|
2538 | return db_query($sql, $params); |
---|
2539 | } |
---|
2540 | |
---|
2541 | |
---|
2542 | //フリーページを全て取得(ページャー付き) |
---|
2543 | function db_admin_get_c_free_page_all($page, $page_size, &$pager) |
---|
2544 | { |
---|
2545 | $sql = 'SELECT * FROM c_free_page ORDER BY c_free_page_id DESC'; |
---|
2546 | |
---|
2547 | $list = db_get_all_page($sql, $page, $page_size, $params); |
---|
2548 | |
---|
2549 | $sql = 'SELECT count(*) FROM c_free_page'; |
---|
2550 | $total_num = db_get_one($sql, $params); |
---|
2551 | $pager = admin_make_pager($page, $page_size, $total_num); |
---|
2552 | |
---|
2553 | return $list; |
---|
2554 | } |
---|
2555 | |
---|
2556 | //フリーページを一つ取得 |
---|
2557 | function db_admin_get_c_free_page_one($c_free_page_id) |
---|
2558 | { |
---|
2559 | $sql = 'SELECT * FROM c_free_page WHERE c_free_page_id = ?'; |
---|
2560 | $params = array(intval($c_free_page_id)); |
---|
2561 | |
---|
2562 | return db_get_row($sql, $params); |
---|
2563 | } |
---|
2564 | |
---|
2565 | //APIを全て取得(ページャー付き) |
---|
2566 | function db_admin_get_c_api_all($page, $page_size, &$pager) |
---|
2567 | { |
---|
2568 | $sql = 'SELECT * FROM c_api ORDER BY c_api_id'; |
---|
2569 | |
---|
2570 | $list = db_get_all_page($sql, $page, $page_size, $params); |
---|
2571 | |
---|
2572 | $sql = 'SELECT count(*) FROM c_api'; |
---|
2573 | $total_num = db_get_one($sql, $params); |
---|
2574 | $pager = admin_make_pager($page, $page_size, $total_num); |
---|
2575 | |
---|
2576 | return $list; |
---|
2577 | } |
---|
2578 | |
---|
2579 | //APIを編集 |
---|
2580 | function db_admin_update_c_api($c_api_id, $name, $ip) |
---|
2581 | { |
---|
2582 | $data = array( |
---|
2583 | 'name' => strval($name), |
---|
2584 | 'ip' => strval($ip), |
---|
2585 | ); |
---|
2586 | $where = array('c_api_id' => intval($c_api_id)); |
---|
2587 | return db_update('c_api', $data, $where); |
---|
2588 | } |
---|
2589 | |
---|
2590 | //CMDを追加 |
---|
2591 | function db_admin_insert_c_cmd($name, $permit) |
---|
2592 | { |
---|
2593 | $data = array( |
---|
2594 | 'name' => strval($name), |
---|
2595 | 'permit' => intval($permit), |
---|
2596 | ); |
---|
2597 | return db_insert('c_cmd', $data); |
---|
2598 | } |
---|
2599 | |
---|
2600 | //CMDを編集 |
---|
2601 | function db_admin_update_c_cmd($c_cmd_id, $name, $permit) |
---|
2602 | { |
---|
2603 | $data = array( |
---|
2604 | 'name' => strval($name), |
---|
2605 | 'permit' => intval($permit), |
---|
2606 | ); |
---|
2607 | $where = array('c_cmd_id' => intval($c_cmd_id)); |
---|
2608 | return db_update('c_cmd', $data, $where); |
---|
2609 | } |
---|
2610 | |
---|
2611 | //CMDを削除 |
---|
2612 | function db_admin_delete_c_cmd($c_cmd_id) |
---|
2613 | { |
---|
2614 | $sql = "DELETE FROM c_cmd WHERE c_cmd_id = ?"; |
---|
2615 | $params = array(intval($c_cmd_id)); |
---|
2616 | return db_query($sql, $params); |
---|
2617 | } |
---|
2618 | |
---|
2619 | |
---|
2620 | //CMDを全て取得 |
---|
2621 | function db_admin_get_c_cmd_all() |
---|
2622 | { |
---|
2623 | $sql = 'SELECT * FROM c_cmd ORDER BY c_cmd_id'; |
---|
2624 | return db_get_all($sql); |
---|
2625 | } |
---|
2626 | |
---|
2627 | //CMDを一つ取得 |
---|
2628 | function db_admin_get_c_cmd_one($c_cmd_id) |
---|
2629 | { |
---|
2630 | $sql = 'SELECT * FROM c_cmd WHERE c_cmd_id = ?'; |
---|
2631 | $params = array(intval($c_cmd_id)); |
---|
2632 | |
---|
2633 | return db_get_row($sql, $params); |
---|
2634 | } |
---|
2635 | |
---|
2636 | /*** |
---|
2637 | * CMD(小窓)の設定リストを取得する |
---|
2638 | * |
---|
2639 | * @return array 小窓の設定リスト |
---|
2640 | */ |
---|
2641 | function db_admin_get_c_cmd_list4name() |
---|
2642 | { |
---|
2643 | $sql = 'SELECT * FROM c_cmd'; |
---|
2644 | return db_get_all($sql); |
---|
2645 | } |
---|
2646 | |
---|
2647 | /** |
---|
2648 | * 祝日のリストを取得 |
---|
2649 | */ |
---|
2650 | function db_admin_c_holiday_list() |
---|
2651 | { |
---|
2652 | $sql = 'SELECT * FROM c_holiday ORDER BY month'; |
---|
2653 | $holiday_list = db_get_all($sql); |
---|
2654 | |
---|
2655 | return $holiday_list; |
---|
2656 | } |
---|
2657 | |
---|
2658 | /** |
---|
2659 | * 休日を追加 |
---|
2660 | */ |
---|
2661 | function db_admin_insert_c_holiday($name, $month, $day) |
---|
2662 | { |
---|
2663 | $data = array( |
---|
2664 | 'name' => strval($name), |
---|
2665 | 'month' => intval($month), |
---|
2666 | 'day' => intval($day), |
---|
2667 | ); |
---|
2668 | return db_insert('c_holiday', $data); |
---|
2669 | } |
---|
2670 | |
---|
2671 | /** |
---|
2672 | * 休日を編集 |
---|
2673 | */ |
---|
2674 | function db_admin_update_c_holiday($c_holiday_id, $name, $month, $day) |
---|
2675 | { |
---|
2676 | $data = array( |
---|
2677 | 'name' => strval($name), |
---|
2678 | 'month' => intval($month), |
---|
2679 | 'day' => intval($day), |
---|
2680 | ); |
---|
2681 | $where = array('c_holiday_id' => intval($c_holiday_id)); |
---|
2682 | return db_update('c_holiday', $data, $where); |
---|
2683 | } |
---|
2684 | |
---|
2685 | /** |
---|
2686 | * 休日を削除 |
---|
2687 | */ |
---|
2688 | function db_admin_delete_c_holiday($c_holiday_id) |
---|
2689 | { |
---|
2690 | $sql = "DELETE FROM c_holiday WHERE c_holiday_id = ?"; |
---|
2691 | $params = array(intval($c_holiday_id)); |
---|
2692 | return db_query($sql, $params); |
---|
2693 | } |
---|
2694 | |
---|
2695 | //メッセージ送信履歴を挿入 |
---|
2696 | function db_admin_insert_c_send_messages_history($subject, $body, $send_num, $type, $c_member_ids) |
---|
2697 | { |
---|
2698 | |
---|
2699 | //配列を文字列に変換 |
---|
2700 | if($c_member_ids) { |
---|
2701 | $c_member_ids = implode("-",$c_member_ids); |
---|
2702 | } else { |
---|
2703 | return; |
---|
2704 | } |
---|
2705 | |
---|
2706 | $data = array( |
---|
2707 | 'subject' => strval($subject), |
---|
2708 | 'body' => strval($body), |
---|
2709 | 'send_num' => intval($send_num), |
---|
2710 | 'type' => strval($type), |
---|
2711 | 'c_member_ids' => strval($c_member_ids), |
---|
2712 | 'r_datetime' => db_now() |
---|
2713 | ); |
---|
2714 | |
---|
2715 | return db_insert('c_send_messages_history', $data); |
---|
2716 | |
---|
2717 | } |
---|
2718 | |
---|
2719 | //メッセージ送信履歴を全て取得(ページャー付き) |
---|
2720 | function db_admin_get_c_send_messages_history_all($page, $page_size, &$pager) |
---|
2721 | { |
---|
2722 | |
---|
2723 | $sql = 'SELECT * FROM c_send_messages_history ORDER BY c_send_messages_history_id DESC'; |
---|
2724 | |
---|
2725 | $history_list = db_get_all_page($sql, $page, $page_size, $params); |
---|
2726 | |
---|
2727 | foreach ($history_list as $key => $history) { |
---|
2728 | $history_list[$key]['c_member_ids'] = explode("-", $history['c_member_ids']); |
---|
2729 | } |
---|
2730 | |
---|
2731 | $sql = 'SELECT count(*) FROM c_send_messages_history'; |
---|
2732 | $total_num = db_get_one($sql, $params); |
---|
2733 | $pager = admin_make_pager($page, $page_size, $total_num); |
---|
2734 | |
---|
2735 | return $history_list; |
---|
2736 | } |
---|
2737 | |
---|
2738 | //メッセージ送信履歴を一つ取得 |
---|
2739 | function db_admin_get_c_send_messages_history($c_send_messages_history_id) |
---|
2740 | { |
---|
2741 | |
---|
2742 | $sql = 'SELECT * FROM c_send_messages_history WHERE c_send_messages_history_id = ?'; |
---|
2743 | |
---|
2744 | $params = array(intval($c_send_messages_history_id)); |
---|
2745 | |
---|
2746 | $history = db_get_row($sql, $params); |
---|
2747 | |
---|
2748 | $history['c_member_ids'] = explode("-", $history['c_member_ids']); |
---|
2749 | |
---|
2750 | return $history; |
---|
2751 | } |
---|
2752 | |
---|
2753 | //メッセージをキューに入れる |
---|
2754 | function db_admin_insert_c_message_queue($c_member_id_from, $c_member_id_to, $subject, $body) |
---|
2755 | { |
---|
2756 | $data = array( |
---|
2757 | 'c_member_id_from' => intval($c_member_id_from), |
---|
2758 | 'c_member_id_to' => intval($c_member_id_to), |
---|
2759 | 'subject' => strval($subject), |
---|
2760 | 'body' => strval($body), |
---|
2761 | ); |
---|
2762 | return db_insert('c_message_queue', $data); |
---|
2763 | } |
---|
2764 | |
---|
2765 | //メッセージをキューから削除 |
---|
2766 | function db_admin_delete_c_message_queue($c_message_queue_id) |
---|
2767 | { |
---|
2768 | |
---|
2769 | $sql = "DELETE FROM c_message_queue WHERE c_message_queue_id = ?"; |
---|
2770 | $params = array(intval($c_message_queue_id)); |
---|
2771 | |
---|
2772 | return db_query($sql, $params); |
---|
2773 | } |
---|
2774 | |
---|
2775 | //ランクを追加 |
---|
2776 | function db_admin_insert_c_rank($name, $image_filename, $point) |
---|
2777 | { |
---|
2778 | $data = array( |
---|
2779 | 'name' => strval($name), |
---|
2780 | 'image_filename' => strval($image_filename), |
---|
2781 | 'point' => intval($point), |
---|
2782 | ); |
---|
2783 | return db_insert('c_rank', $data); |
---|
2784 | } |
---|
2785 | |
---|
2786 | //ランクを編集 |
---|
2787 | function db_admin_update_c_rank($c_rank_id, $name, $image_filename, $point) |
---|
2788 | { |
---|
2789 | $data = array( |
---|
2790 | 'name' => strval($name), |
---|
2791 | 'image_filename' => strval($image_filename), |
---|
2792 | 'point' => intval($point), |
---|
2793 | ); |
---|
2794 | $where = array('c_rank_id' => intval($c_rank_id)); |
---|
2795 | return db_update('c_rank', $data, $where); |
---|
2796 | } |
---|
2797 | |
---|
2798 | //ランクを削除 |
---|
2799 | function db_admin_delete_c_rank($c_rank_id) |
---|
2800 | { |
---|
2801 | $sql = "DELETE FROM c_rank WHERE c_rank_id = ?"; |
---|
2802 | $params = array(intval($c_rank_id)); |
---|
2803 | return db_query($sql, $params); |
---|
2804 | } |
---|
2805 | |
---|
2806 | //ランクを全て取得 |
---|
2807 | function db_admin_get_c_rank_all() |
---|
2808 | { |
---|
2809 | $sql = 'SELECT * FROM c_rank ORDER BY point'; |
---|
2810 | return db_get_all($sql); |
---|
2811 | } |
---|
2812 | |
---|
2813 | //ランクを一つ取得 |
---|
2814 | function db_admin_get_c_rank_one($c_rank_id) |
---|
2815 | { |
---|
2816 | $sql = 'SELECT * FROM c_rank WHERE c_rank_id = ?'; |
---|
2817 | $params = array(intval($c_rank_id)); |
---|
2818 | |
---|
2819 | return db_get_row($sql, $params); |
---|
2820 | } |
---|
2821 | |
---|
2822 | //アクションを編集 |
---|
2823 | function db_admin_update_c_action($c_action_id, $point) |
---|
2824 | { |
---|
2825 | $data = array( |
---|
2826 | 'point' => intval($point), |
---|
2827 | ); |
---|
2828 | $where = array('c_action_id' => intval($c_action_id)); |
---|
2829 | return db_update('c_action', $data, $where); |
---|
2830 | } |
---|
2831 | |
---|
2832 | //アクションを全て取得 |
---|
2833 | function db_admin_get_c_action_all() |
---|
2834 | { |
---|
2835 | $sql = 'SELECT * FROM c_action ORDER BY c_action_id'; |
---|
2836 | return db_get_all($sql); |
---|
2837 | } |
---|
2838 | |
---|
2839 | /** |
---|
2840 | * 指定したファイル名のファイルへのリンクを削除する |
---|
2841 | * |
---|
2842 | * @param string $filename |
---|
2843 | */ |
---|
2844 | function db_admin_delete_c_file_link4filename($filename) |
---|
2845 | { |
---|
2846 | // c_commu_topic_comment |
---|
2847 | $tbl = 'c_commu_topic_comment'; |
---|
2848 | _db_admin_empty_image_filename($tbl, $filename, 'filename'); |
---|
2849 | |
---|
2850 | // h_message |
---|
2851 | $tbl = 'c_message'; |
---|
2852 | _db_admin_empty_image_filename($tbl, $filename, 'filename'); |
---|
2853 | } |
---|
2854 | |
---|
2855 | function db_admin_get_c_member_profile_pnepoint($c_member_id) |
---|
2856 | { |
---|
2857 | $sql = 'SELECT c_profile_id FROM c_profile where name = \'PNE_POINT\''; |
---|
2858 | $c_profile_id = db_get_one($sql); |
---|
2859 | $params = array($c_member_id , $c_profile_id); |
---|
2860 | $sql = 'SELECT * FROM c_member_profile where c_member_id = ? and c_profile_id = ?'; |
---|
2861 | $c_member_profile = db_get_row($sql, $params); |
---|
2862 | |
---|
2863 | return $c_member_profile; |
---|
2864 | } |
---|
2865 | |
---|
2866 | function db_admin_c_blacklist_list($page, $page_size) |
---|
2867 | { |
---|
2868 | $sql = 'SELECT b.c_blacklist_id,ms.c_member_id,b.info,m.nickname,b.easy_access_id ' . |
---|
2869 | ' FROM c_blacklist AS b' . |
---|
2870 | ' LEFT JOIN c_member_secure AS ms ON b.easy_access_id = ms.easy_access_id'. |
---|
2871 | ' LEFT JOIN c_member AS m ON ms.c_member_id = m.c_member_id' . |
---|
2872 | ' ORDER BY b.c_blacklist_id ASC'; |
---|
2873 | $list = db_get_all_page($sql, $page, $page_size); |
---|
2874 | |
---|
2875 | $sql = 'SELECT count(*) FROM c_blacklist'; |
---|
2876 | $total_num = db_get_one($sql); |
---|
2877 | |
---|
2878 | $total_page_num = ceil($total_num / $page_size); |
---|
2879 | $next = ($page < $total_page_num); |
---|
2880 | $prev = ($page > 1); |
---|
2881 | |
---|
2882 | return array($list, $prev, $next, $total_num, $total_page_num); |
---|
2883 | } |
---|
2884 | |
---|
2885 | function db_admin_insert_c_blacklist($easy_access_id, $info) |
---|
2886 | { |
---|
2887 | $data = array( |
---|
2888 | 'easy_access_id' => $easy_access_id, |
---|
2889 | 'info' => (string)$info, |
---|
2890 | ); |
---|
2891 | return db_insert('c_blacklist', $data); |
---|
2892 | } |
---|
2893 | |
---|
2894 | function db_admin_update_c_blacklist($c_blacklist_id, $easy_access_id, $info) |
---|
2895 | { |
---|
2896 | $data = array( |
---|
2897 | 'easy_access_id' => $easy_access_id, |
---|
2898 | 'info' => (string)$info, |
---|
2899 | ); |
---|
2900 | $where = array('c_blacklist_id' => $c_blacklist_id); |
---|
2901 | return db_update('c_blacklist', $data, $where); |
---|
2902 | } |
---|
2903 | |
---|
2904 | function db_admin_delete_c_blacklist($c_blacklist_id) |
---|
2905 | { |
---|
2906 | $sql = 'DELETE FROM c_blacklist WHERE c_blacklist_id = ?'; |
---|
2907 | $params = array(intval($c_blacklist_id)); |
---|
2908 | db_query($sql, $params); |
---|
2909 | } |
---|
2910 | |
---|
2911 | function db_admin_c_blacklist($c_blacklist_id) |
---|
2912 | { |
---|
2913 | $sql = 'SELECT b.c_blacklist_id,ms.c_member_id,b.info,m.nickname,b.easy_access_id ' . |
---|
2914 | ' FROM c_blacklist AS b' . |
---|
2915 | ' LEFT JOIN c_member_secure AS ms ON b.easy_access_id = ms.easy_access_id'. |
---|
2916 | ' LEFT JOIN c_member AS m ON ms.c_member_id = m.c_member_id' . |
---|
2917 | ' WHERE b.c_blacklist_id = ? ' |
---|
2918 | ; |
---|
2919 | $param = array($c_blacklist_id); |
---|
2920 | $blacklist = db_get_row($sql, $param); |
---|
2921 | |
---|
2922 | return $blacklist; |
---|
2923 | } |
---|
2924 | |
---|
2925 | function db_admin_enabled_module_list() |
---|
2926 | { |
---|
2927 | $sql = 'SELECT * FROM c_module WHERE is_enabled = 1'; |
---|
2928 | $module_list = db_get_all($sql); |
---|
2929 | |
---|
2930 | return $module_list; |
---|
2931 | } |
---|
2932 | |
---|
2933 | function db_admin_insert_module_enabled($module, $is_enabled) |
---|
2934 | { |
---|
2935 | $data = array( |
---|
2936 | 'name' => $module, |
---|
2937 | 'is_enabled' => $is_enabled, |
---|
2938 | ); |
---|
2939 | return db_insert('c_module', $data); |
---|
2940 | } |
---|
2941 | |
---|
2942 | function db_admin_update_module_enabled($module, $is_enabled) |
---|
2943 | { |
---|
2944 | $data = array( |
---|
2945 | 'is_enabled' => $is_enabled, |
---|
2946 | ); |
---|
2947 | $where = array( |
---|
2948 | 'name' => $module, |
---|
2949 | ); |
---|
2950 | return db_update('c_module', $data, $where); |
---|
2951 | } |
---|
2952 | |
---|
2953 | function db_admin_enabled_module_config_list() |
---|
2954 | { |
---|
2955 | $enable_module_list = db_admin_enabled_module_list(); |
---|
2956 | $configs = array(); |
---|
2957 | foreach ($enable_module_list as $module) { |
---|
2958 | $name = $module['name']; |
---|
2959 | $configs[$name] = util_get_module_config($name); |
---|
2960 | } |
---|
2961 | |
---|
2962 | return $configs; |
---|
2963 | } |
---|
2964 | |
---|
2965 | function db_admin_c_config_decoration_list() |
---|
2966 | { |
---|
2967 | $sql = 'SELECT * FROM c_config_decoration'; |
---|
2968 | $c_config_decoration_list = db_get_all($sql); |
---|
2969 | |
---|
2970 | return $c_config_decoration_list; |
---|
2971 | } |
---|
2972 | |
---|
2973 | function db_admin_update_c_config_decoration($c_config_decoration_id, $is_enabled) |
---|
2974 | { |
---|
2975 | $data = array( |
---|
2976 | 'is_enabled' => $is_enabled, |
---|
2977 | ); |
---|
2978 | $where = array('c_config_decoration_id' => $c_config_decoration_id); |
---|
2979 | return db_update('c_config_decoration', $data, $where); |
---|
2980 | } |
---|
2981 | ?> |
---|