Changeset 11025
- Timestamp:
- Mar 16, 2009, 4:03:43 PM (14 years ago)
- Location:
- OpenPNE/trunk
- Files:
-
- 4 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
OpenPNE/trunk/config.php.sample
r10988 r11025 603 603 define('IS_PASSWORD_QUERY_ANSWER', true); 604 604 605 // 連続投稿確認用 606 // 607 // 連続投稿のチェック対象とするアクション 608 $GLOBALS['CHECK_POST_ACTIONS'] = array( 609 'pc' => array( 610 'do_h_diary_add_insert_c_diary', 611 'do_fh_diary_insert_c_diary_comment', 612 'do_h_com_add_insert_c_commu', 613 'do_c_topic_add_insert_c_commu_topic', 614 'do_c_topic_write_insert_c_commu_topic_comment', 615 'do_c_event_add_insert_c_commu_topic', 616 'do_c_event_write_insert_c_commu_topic_comment', 617 'do_f_message_send_insert_c_message', 618 'do_f_link_request_insert_c_friend_confirm', 619 )); 620 621 // 連続投稿と判断する間隔(秒) 622 // 0を指定した場合、チェックしない 623 define('POST_INTERVAL_UNFAIR_SECOND', 0); 624 625 // 前回から[POST_INTERVAL_UNFAIR_SECOND]秒以内の投稿が、 626 // 何回行われた時に、連続投稿と判断するか 627 define('POST_INTERVAL_UNFAIR_COUNT', 10); 628 629 // 前回投稿から何秒以上あいていたら、連続投稿回数をリセットするか 630 // 0を指定した場合、リセットしない 631 define('POST_INTERVAL_UNFAIR_COUNT_RESET_SECOND', 60*60); 632 633 // 前回投稿時刻と投稿回数の保存先 634 // 0:セッション 635 // 1:データベース 636 define('POST_INFO_STORAGE', 0); 637 605 638 ?> -
OpenPNE/trunk/webapp/lib/db/etc.php
r9020 r11025 949 949 } 950 950 951 /** 952 * DBから前回POST情報を取得する 953 * 954 * @params : $u 955 * 956 * @return array(); 957 **/ 958 function db_etc_get_post_info($u) 959 { 960 $sql = 'SELECT * FROM c_post_info WHERE c_member_id = ?'; 961 $params = array($u); 962 $result = db_get_row($sql, $params); 963 return array($result['last_post_time'], $result['last_post_count']); 964 } 965 966 /** 967 * DBにPOST情報を設定する 968 * 969 * @params : $u 970 * @params : $post_time 971 * @params : $post_count 972 * 973 **/ 974 function db_etc_set_post_info($u, $post_time, $post_count) 975 { 976 $data = array('last_post_time' => $post_time, 977 'last_post_count' => $post_count, 978 'r_datetime' => db_now(), 979 ); 980 981 // update 982 $where = "c_member_id = $u"; 983 if (db_update('c_post_info', $data, $where) && db_affected_rows()) { 984 return true; 985 } 986 987 // insert 988 $data['c_member_id'] = $u; 989 return (bool)db_insert('c_post_info', $data); 990 } 991 951 992 ?> -
OpenPNE/trunk/webapp/lib/util/util.php
r11008 r11025 1057 1057 } 1058 1058 1059 /** 1060 * 連続投稿チェック用の情報を取得する 1061 * 1062 * @return array 1063 */ 1064 function util_get_post_info($u) 1065 { 1066 $last_post_time = ''; 1067 $post_count = 0; 1068 1069 switch (POST_INFO_STORAGE) { 1070 case 0 : 1071 $last_post_time = $_SESSION['last_post_time']; 1072 $post_count = $_SESSION['post_count']; 1073 break; 1074 case 1 : 1075 list($last_post_time, $post_count) = db_etc_get_post_info($u); 1076 break; 1077 } 1078 1079 return array($last_post_time, $post_count); 1080 } 1081 1082 /** 1083 * 連続投稿チェック用の情報を設定する 1084 * 1085 * @return array 1086 */ 1087 function util_set_post_info($u, $post_time, $post_count) 1088 { 1089 switch (POST_INFO_STORAGE) { 1090 case 0 : 1091 $_SESSION['last_post_time'] = $post_time; 1092 $_SESSION['post_count'] = $post_count; 1093 break; 1094 case 1 : 1095 db_etc_set_post_info($u, $post_time, $post_count); 1096 break; 1097 } 1098 1099 return true; 1100 } 1101 1102 /** 1103 * 連続投稿確認用 1104 * 1105 * @params $action : Check Action 1106 * @params $u : operation c_member_id 1107 * @return true : post OK 1108 * false : post NG 1109 **/ 1110 function util_do_post_interval_ok($action, $u = 0) 1111 { 1112 $result = true; 1113 1114 if (!POST_INTERVAL_UNFAIR_SECOND) { 1115 // チェックしない 1116 } else if (in_array($action, $GLOBALS['CHECK_POST_ACTIONS']['pc'])) { 1117 //保持している情報 1118 list($last_post_time, $post_count) = util_get_post_info($u); 1119 1120 //連続投稿チェック 1121 $now_time = time(); 1122 if ($last_post_time) { 1123 if (($now_time - $last_post_time) < POST_INTERVAL_UNFAIR_SECOND) { 1124 // 設定時間内の場合カウントアップ 1125 $post_count ++; 1126 } else if (!POST_INTERVAL_UNFAIR_COUNT_RESET_SECOND) { 1127 // リセットしない 1128 } else if (($now_time - $last_post_time) > POST_INTERVAL_UNFAIR_COUNT_RESET_SECOND) { 1129 //前回投稿から指定時間以上あいていれば、カウントをリセットする 1130 $post_count = 1; 1131 } 1132 1133 if ($post_count > POST_INTERVAL_UNFAIR_COUNT) { 1134 //連続投稿とみなす 1135 $result = false; 1136 } 1137 } else { 1138 $post_count = 1; 1139 } 1140 //情報更新 1141 util_set_post_info($u, $now_time, $post_count); 1142 } 1143 1144 return $result; 1145 } 1146 1059 1147 ?> -
OpenPNE/trunk/webapp/modules/pc/init.inc
r8857 r11025 15 15 } 16 16 //> 17 18 17 function init_pc_page(&$smarty) 19 18 { … … 85 84 } 86 85 } 86 87 // 連続投稿確認 88 if ($is_secure) { 89 $u = $GLOBALS['AUTH']->uid(); 90 $action = 'do_' . $GLOBALS['__Framework']['current_action']; 91 92 if (!util_do_post_interval_ok($action, $u)) { 93 openpne_display_error(); 94 } 95 } 96 87 97 } 88 98
Note: See TracChangeset
for help on using the changeset viewer.