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