2 // $Id: spam_pickup.php,v 1.8 2006/10/28 14:08:58 henoheno Exp $
3 // Concept-work of spam-uri metrics
4 // Copyright (C) 2006 PukiWiki Developers Team
5 // License: GPL v2 or (at your option) any later version
7 error_reporting(E_ALL); // Debug purpose
11 // Recursive array_map()
12 // e.g. Sanitilze ALL values (Debug purpose): var_dump(recursive_map('htmlspecialchars', $array));
13 function recursive_map($func, $array)
15 if (is_array($array)) {
16 if (! empty($array)) {
17 $array = array_map('recursive_map',
18 array_fill(0, count($array), $func), $array);
21 $array = $func($array);
26 function show_form($string)
28 $base = basename(__FILE__);
29 $string = htmlspecialchars($string);
31 <form action="$base" method="post">
32 <textarea name="msg" rows="8" cols="80">$string</textarea><br />
33 <input type="submit" name="write" value="Submit" />
40 // ---- Show form and result
41 echo basename(__FILE__) . '<br />';
42 $msg = isset($_POST['msg']) ? $_POST['msg'] : '';
46 $results = spam_pickup($msg);
49 $count = count($results);
51 foreach($results as $result)
52 if (isset($result['area']))
53 $area += $result['area'];
54 $average = $count ? ($area / $count) : 'NULL';
56 echo "TOTAL = $count URIs, AREA_TOTAL = $area, AREA_AVERAGE = " . $average . "</br >" . "</br >";