Skip to content

Instantly share code, notes, and snippets.

@Akkiesoft
Last active December 15, 2015 22:39
Show Gist options
  • Save Akkiesoft/5334854 to your computer and use it in GitHub Desktop.
Save Akkiesoft/5334854 to your computer and use it in GitHub Desktop.
超簡易重複チェッカー
<?php
mb_internal_encoding('UTF-8');
if (isset($_POST['check']) && isset($_POST['src']) && $_POST['src']) {
$src = htmlspecialchars($_POST['src']);
$src_array = explode("\r\n", $src);
$cnv_array = array();
if (isset($_POST['opt_mail'])) {
// ドメイン部分は小文字に変換
foreach($src_array as $line) {
$cnv_array[] = preg_replace_callback(
"|@(.+)$|",
create_function(
'$matches', 'return strtolower($matches[0]);'
),
$line
);
}
} else {
$cnv_array = $src_array;
}
$dest_array = array_unique($cnv_array);
$dest = implode("\n", $dest_array);
$src_count = count($src_array);
$dest_count = count($dest_array);
$deduped = $src_count - $dest_count;
}
function totsuzen_no_shi($str, $retstr = "\n") {
$len = mb_strlen($str, 'UTF-8');
$line1 = '_人';
$line2 = '> '.$str.' <';
$line3 = ' ̄';
for ($i = 0; $i < $len; $i++) {
$line1 .= '人';
$line3 .= '^Y';
}
$line1 .= '_';
$line3 .= ' ̄';
return $line1 . $retstr . $line2 . $retstr . $line3;
}
?>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>重複チェック</title>
<style type="text/css">
<!--
body {margin:0 auto;width:600px;}
h1 {text-align:center;}
p {margin-bottom:50px;text-align:center;}
textarea {width:400px;height:300px;}
-->
</style>
</head>
<body>
<h1>重複チェック</h1>
<div style="width:600px;">
<form action="dedupe.php" method="post">
<p>
ここにチェックしたいデータを入れるじゃろ?<br>
( ^ω^)<br>
⊃ <textarea name="src"><?php print $src; ?></textarea> ⊂<br>
(改行区切りでどうぞ。)
</p>
<p>
必要なモードを選ぶのじゃ<br>
( ^ω^)<br>
<label for="opt_mail"><input type="checkbox" id="opt_mail" name="opt_mail">メールアドレスモード<br>
</p>
<p>
そして、これを押して<br>
( ^ω^)<br>
⊃ <input type="submit" name="check" value="押すのじゃ"> ⊂<br>
</p>
<?php
if (isset($dest) && $dest) {
?>
<p>
こうじゃ<br>
( ^ω^)<br>
⊃ <textarea name="dest"><?php print $dest; ?></textarea> ⊂<br>
</p>
<p><?php print totsuzen_no_shi($deduped.'件の重複', "<br>"); ?></p>
<?php } ?>
</form>
</div>
</body>
</html>
@inmyfree
Copy link

inmyfree commented Apr 8, 2013

hi,fist time see jp frend。。。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment