機能追加 #80
不正対策(連続同一IP登録チェック)
| ステータス: | 進行中 | 開始日: | 2014/08/02 | |
|---|---|---|---|---|
| 優先度: | 今すぐ | 期日: | 2014/08/02 | |
| 担当者: | - | 進捗 %: | 100% | |
| カテゴリ: | 成果通知 | 予定工数: | 5.00時間 | |
| 対象バージョン: | - | 作業時間の記録: | - |
説明
<エラーとする条件>
・登録日が直近1時間以内
・同一広告
・同一IP
・ASPのみ
・6件以上
・PCは除く
・除外IP (社内、店舗)
履歴
#1 山本 義治 が11年以上前に更新
/www/aff_test_new/ad/www/ac/action.php
[admin@web1 ac]$ diff action.php /www/aff/ad/www/ac/
551,571d524
< //連続同一IPチェック
< if(!count($err) && $asp_id){
< //除外IPリスト
< $accept_ip_list = array(
< '220.97.54.22', //社内
< '49.212.134.209', //店舗
< );
< if(!in_array($ip, $accept_ip_list) && get_career_id_by_agent($agent) != 'pc' ){
< //直近1時間以内
< $tsql = "select count(*) from $action_log_table where c_id = '$c_id' and asp_id = '$asp_id' and ip = '$ip' and order_date > date_sub(now(), interval 1 hour)";
< $tres = __mysql_query_ex( $tsql );
< list($duplicate_count) = mysql_fetch_array($tres);
< //6件以上重複する場合はエラー
< if($duplicate_count >= 6){
< $err["status"] = 3;
< $err["msg"] = "duplicate ip error";
< $err["error_message"] = "連続同一IP通知エラー";
< }
< }
< }
#2 山本 義治 が11年以上前に更新
テスト環境動作テスト
①社内wifiに繋ぐ
②スマホのUAにする
③クリック
http://web1.i-generation.jp:8000/action/click_asp.php?cid=1050&asid=193&guid=ON
④登録
http://web1.i-generation.jp:8000/action/conversion.php?c=1050
→6回連続登録されることを確認
⑤社外wifiに繋ぐ
③、④を繰り返す
→6回目でエラーとなることを確認
#4 山本 義治 が11年以上前に更新
動作確認
①社内wifiに繋ぐ
②スマホのUAにする
③クリック
http://i-generation.jp/action/click_asp.php?cid=1&asid=1
④登録
http://i-generation.jp/action/conversion.php?c=1
→6回連続登録されることを確認
⑤社外wifiに繋ぐ
③、④を繰り返す
→6回目でエラーとなることを確認
#5 山本 義治 が11年以上前に更新
確認用SQLクエリー
select ac.c_id,ac.asp_id,ct.content_name,ac.agent,date_format(ac.order_date,'%Y%m%d%H') date,ac.ip,count(*) cnt from action_log_201407 ac left join content ct on ac.c_id = ct.c_id group by ac.c_id,ac.asp_id,date,ac.ip having cnt > 5 and ac.ip != '49.212.134.209' and ac.asp_id > 0 and (ac.agent like '%iPhone%' or ac.agent like '%Android%') order by ac.c_id,cnt desc
#10 山本 義治 がほぼ11年前に更新
[admin@web1 ac]$ diff action.php /www/aff/ad/www/ac/
602c622
< $tsql = "select asp_name,action_url,action_url2,action_tag,action_tag2 from asp where asp_id = '$asp_id'";
---
> $tsql = "select action_url,action_url2,action_tag,action_tag2 from asp where asp_id = '$asp_id'";
605c625
< list($asp_name,$action_url,$action_url2,$action_tag,$action_tag2) = mysql_fetch_array($tres);
---
> list($action_url,$action_url2,$action_tag,$action_tag2) = mysql_fetch_array($tres);
608c628
< $tsql = "select asp_cid,duplicate_flg from asp_list where asp_id = '$asp_id' and c_id = '$c_id'";
---
> $tsql = "select asp_cid from asp_list where asp_id = '$asp_id' and c_id = '$c_id'";
611c631
< list($asp_cid,$duplicate_flg) = mysql_fetch_array($tres);
---
> list($asp_cid) = mysql_fetch_array($tres);
613,654d632
< print("duplicate_flg: $duplicate_flg<br>¥n");
< //連続同一IPチェック
< if(!count($err) && !$duplicate_flg){
< //除外IPリスト
< $accept_ip_list = array(
< '220.97.54.22', //社内
< '49.212.134.209', //店舗
< );
< if(!in_array($ip, $accept_ip_list) && get_career_id_by_agent($agent) != 'pc'){
< //直近10分以内
< $tsql = "select count(*) from $action_log_table where c_id = '$c_id' and asp_id = '$asp_id' and ip = '$ip' and agent = '$agent' and order_date > date_sub(now(), interval 10 minute)";
< print($tsql);
< $tres = __mysql_query_ex( $tsql );
< list($duplicate_count) = mysql_fetch_array($tres);
< //3件以上重複する場合はエラー
< if($duplicate_count >= 2){
< $tsql = "update asp_list set duplicate_flg = 1 where c_id = '$c_id' and asp_id = '$asp_id'";
< print($tsql);
< $tres = __mysql_query_ex( $tsql );
<
< $duplicate_flg = 1;
<
< //アラートメール送信
< include_once("$SERVER_PATH/mail/mail.inc");
< //タイトル取得--------------------
< $mailsubject = __file_read("$SERVER_PATH/mail/subject/duplicate.dat");
< //本文取得------------------------
< $mailbody = __file_read("$SERVER_PATH/mail/body/duplicate.dat");
<
< //本文,タイトル,ヘッダ,文字列置き換え
< $mailbody = preg_replace("/###SERVICE_NAME###/",$From_Name,$mailbody);
< $mailbody = preg_replace("/###WW_SERVER_DOMAIN###/",$WW_SERVER_DOMAIN,$mailbody);
< $mailbody = preg_replace("/###ASP_ID###/",$asp_id,$mailbody);
< $mailbody = preg_replace("/###ASP_NAME###/",$asp_name,$mailbody);
< $mailbody = preg_replace("/###CONTENT_ID###/",$c_id,$mailbody);
< $mailbody = preg_replace("/###CONTENT_NAME###/",$content_name,$mailbody);
<
< send_mail_mobile("haltyt@gmail.com",$mailsubject,$mailbody);
< }
< }
< }
#13 山本 義治 がほぼ11年前に更新
/www/aff_test_new/admin/www/asp/search/duplicate_ex.php
/www/aff_test_new/admin/www/content/search/asp_list.php
/www/aff_test_new/admin/www/content/search/duplicate_rm.php
/www/aff_test_new/admin/www/content/search/duplicate_rm.inc
/www/aff_test_new/admin/www/content/search/duplicate_rm_db.php
#19 山本 義治 がほぼ11年前に更新
/www/aff_test_new/ad/www/ac/action.php
[admin@web1 ac]$ diff action.php /www/aff/ad/www/ac/ 640c640 < $tsql = "update asp_list set duplicate_flg = 1,duplicate_date = now() where c_id = '$c_id' and asp_id = '$asp_id'"; --- > $tsql = "update asp_list set duplicate_flg = 1 where c_id = '$c_id' and asp_id = '$asp_id'";
#20 山本 義治 がほぼ11年前に更新
/www/aff_test_new/admin/cron/action_duplicate_check.php
[admin@web1 cron]$ cat action_duplicate_check.php
#!/usr/bin/php -q
<?
//連続不正登録フラグチェック
//毎分実行
require_once("/www/aff_test_new/admin/const.inc");
//チェック時間(分)
$interval = 60;
$mysql_id = __mysql_con_ex();
//チェック時間経過していたら不正登録フラグリセット
$sql = "update asp_list set duplicate_flg = 0 where duplicate_date < (now() - interval $interval minute)";
print("$sql¥n");
$res = __mysql_query_ex( $sql );
mysql_close($mysql_id);
?>
#21 山本 義治 がほぼ11年前に更新
alter table asp_list add duplicate_auto tinyint default 1
alter table asp_list add duplicate_type tinyint default 3
alter table asp_list add duplicate_action_period int default 10
alter table asp_list add duplicate_reset_period int default 1
alter table asp_list add index duplicate_auto (duplicate_auto)
alter table asp_list add index duplicate_type (duplicate_type)
alter table asp_list add index duplicate_action_period (duplicate_action_period)
alter table asp_list add index duplicate_reset_period (duplicate_reset_period)
#22 山本 義治 がほぼ11年前に更新
/www/aff_test_new/ad/www/ac/action.php
[admin@web1 ac]$ diff action.php /www/aff/ad/www/ac/
608c608
< $tsql = "select asp_cid,duplicate_flg,duplicate_auto,duplicate_type,duplicate_action_period from asp_list where asp_id = '$asp_id' and c_id = '$c_id'";
---
> $tsql = "select asp_cid,duplicate_flg from asp_list where asp_id = '$asp_id' and c_id = '$c_id'";
611c611
< list($asp_cid,$duplicate_flg,$duplicate_auto,$duplicate_type,$duplicate_action_period) = mysql_fetch_array($tres);
---
> list($asp_cid,$duplicate_flg) = mysql_fetch_array($tres);
620a621,624
> //除外ASP
> $accept_asp_list = array(
> '33',
> );
623c627,628
< && $duplicate_auto == 1
---
> && !in_array($ip, $accept_asp_list)
> && !($asp_id == 11 && $c_id == 1253)
625,631c630,631
<
< //デフォルト直近10分
< if(!$duplicate_action_period)
< $duplicate_action_period = 10;
<
< //不正チェック
< $tsql = "select count(*) from $action_log_table where c_id = '$c_id' and asp_id = '$asp_id' and ip = '$ip' and agent = '$agent' and order_date > date_sub(now(), interval $duplicate_action_period minute)";
---
> //直近10分以内
> $tsql = "select count(*) from $action_log_table where c_id = '$c_id' and asp_id = '$asp_id' and ip = '$ip' and agent = '$agent' and order_date > date_sub(now(), interval 10 minute)";
634d633
<
637,640c636,640
<
< //成果保留フラグを立てる
< if($duplicate_type == 2 || $duplicate_type == 3){
< $tsql = "update asp_list set duplicate_flg = 1,duplicate_date = now() where c_id = '$c_id' and asp_id = '$asp_id'";
---
> if($asp_id == 151
> || $asp_id == 209
> || $asp_id == 210
> ){
> $tsql = "update asp_list set duplicate_flg = 1 where c_id = '$c_id' and asp_id = '$asp_id'";
643c643
< //不正フラグ
---
>
#23 山本 義治 がほぼ11年前に更新
/www/aff_test_new/admin/cron/action_duplicate_check.php
[admin@web1 cron]$ cat action_duplicate_check.php
#!/usr/bin/php -q
<?
//連続不正登録フラグチェック
//毎分実行
require_once("/www/aff_test_new/admin/const.inc");
$mysql_id = __mysql_con_ex();
//チェック時間経過していたら不正登録フラグリセット
$sql = "update asp_list set duplicate_flg = 0 where duplicate_auto = 1 and duplicate_type = 3 and duplicate_date < (now() - interval duplicate_reset_period hour)";
print("$sql¥n");
$res = __mysql_query_ex( $sql );
mysql_close($mysql_id);
?>
#24 山本 義治 がほぼ11年前に更新
/www/aff_test_new/admin/www/content/search/asp_list.php
/www/aff_test_new/admin/www/content/search/tag.php
/www/aff_test_new/admin/www/content/search/duplicate_set.php
/www/aff_test_new/admin/www/content/search/duplicate_set.inc
/www/aff_test_new/admin/www/content/search/duplicate_set_db.php
/www/aff_test_new/admin/www/asp/search/asp_list.php