Last active
October 6, 2019 10:56
-
-
Save chikuwa24/b99f70fc6483df6721d74e58e2da7c33 to your computer and use it in GitHub Desktop.
Get access user's ua info and send mail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// 豆地雷 UA情報取得&メール通知 | |
// URLパラメータ a=mail account d=mail domain | |
function get_uainfo(){ | |
ini_set("display_errors", 0); | |
ini_set("display_startup_errors", 0); | |
error_reporting(E_ALL); | |
$subject = "豆地雷-アクセス通知"; | |
// アカウント判定 | |
if (!isset($_GET['a'])) { | |
$act = ""; | |
} elseif (!is_string($_GET['a'])) { | |
$act = ""; | |
} else { | |
$act = $_GET['a']; | |
} | |
// ドメイン判定 | |
if (!isset($_GET['d'])) { | |
$dmn = ""; | |
} elseif (!is_string($_GET['d'])) { | |
$dmn = ""; | |
} else { | |
$dmn = $_GET['d']; | |
} | |
// ドメイン省略 | |
switch($dmn){ | |
case "y": | |
$dmn = "yahoo.co.jp"; | |
break; | |
case "g": | |
$dmn = "gmail.com"; | |
break; | |
case "o": | |
$dmn = "outlool.com"; | |
break; | |
default: | |
break; | |
} | |
$ua = $_SERVER['HTTP_USER_AGENT']; | |
//$browser_name = $browser_version = $webkit_version = $platform = NULL; | |
$is_webkit = false; | |
// 判定するのに小文字にする | |
$browser = strtolower($_SERVER['HTTP_USER_AGENT']); | |
// ユーザーエージェントの情報を基に判定 | |
if (strstr($browser , 'edge')) { | |
$browser_name = "Edge"; | |
} elseif (strstr($browser , 'trident') || strstr($browser , 'msie')) { | |
$browser_name = "Internet Explorer"; | |
} elseif (strstr($browser , 'hrome')) { | |
$browser_name = "Chrome"; | |
} elseif (strstr($browser , 'firefox')) { | |
$browser_name = "Firefox"; | |
} elseif (strstr($browser , 'safari')) { | |
$browser_name = "Safari"; | |
} elseif (strstr($browser , 'opera')) { | |
$browser_name = "Opera"; | |
} else { | |
echo('unknown'); | |
} | |
//Platform | |
if(preg_match('/ipod/i', $ua)){ | |
$platform = 'iPod'; | |
}elseif(preg_match('/iphone/i', $ua)){ | |
$platform = 'iPhone'; | |
}elseif(preg_match('/ipad/i', $ua)){ | |
$platform = 'iPad'; | |
}elseif(preg_match('/android/i', $ua)){ | |
$platform = 'Android'; | |
}elseif(preg_match('/windows phone/i', $ua)){ | |
$platform = 'Windows Phone'; | |
}elseif(preg_match('/linux/i', $ua)){ | |
$platform = 'Linux'; | |
}elseif(preg_match('/macintosh|mac os/i', $ua)) { | |
$platform = 'Mac'; | |
}elseif(preg_match('/windows/i', $ua)){ | |
$platform = 'Windows'; | |
} | |
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']); | |
// HTTPリファラーが設定されている場合は取得して、そうでない場合はnullを設定する。 | |
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; | |
$message = "Date : ". date_i18n("Y-n-j H:i:s").PHP_EOL.PHP_EOL; | |
$message .= "IP : " .$_SERVER["REMOTE_ADDR"].PHP_EOL.PHP_EOL; | |
$message .= "位置情報 : " ."https://www.ip-adress.com/ip-address/ipv4/".$_SERVER["REMOTE_ADDR"].PHP_EOL.PHP_EOL; | |
$message .= "Browser : " . $browser_name.PHP_EOL; | |
//$message .= "browser_version: " . $browser_version.PHP_EOL; | |
$message .= "Platform : " . $platform.PHP_EOL.PHP_EOL; | |
$message .= "Referer : " . $referer.PHP_EOL; | |
$message .= "Host : " . $hostname.PHP_EOL.PHP_EOL; | |
$message .= "User Agent : " . $_SERVER["HTTP_USER_AGENT"].PHP_EOL.PHP_EOL; | |
$message .= "UA解析 : " . "http://cya.sakura.ne.jp/java/browser/useragent.htm".PHP_EOL.PHP_EOL; | |
$message .= "★豆地雷 "."http://bit.ly/mame_jirai".PHP_EOL; | |
// メール通知 | |
if($act != "" && $dmn != ""){ | |
if (wp_mail( $act."@".$dmn, $subject, $message )) | |
{ | |
// echo "thanks"; | |
} | |
} | |
add_shortcode('uainfo', 'get_uainfo'); | |
// 豆地雷 UA情報取得&メール通知 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment