2 // $Id: spam_pickup.php,v 1.9 2006/11/01 14:45:25 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 // $array[0] => $array['name']
27 function array_rename_key(& $array, $from, $to, $force = FALSE, $default = '')
29 if (isset($array[$from])) {
30 $array[$to] = & $array[$from];
33 $array[$to] = $default;
40 function show_form($string)
42 $base = basename(__FILE__);
43 $string = htmlspecialchars($string);
45 <form action="$base" method="post">
46 <textarea name="msg" rows="8" cols="80">$string</textarea><br />
47 <input type="submit" name="write" value="Submit" />
54 // ---- Show form and result
55 echo basename(__FILE__) . '<br />';
56 $msg = isset($_POST['msg']) ? $_POST['msg'] : '';
60 $results = spam_pickup($msg);
63 $count = count($results);
65 foreach($results as $result)
66 if (isset($result['area']))
67 $area += $result['area'];
68 $average = $count ? ($area / $count) : 'NULL';
70 echo "TOTAL = $count URIs, AREA_TOTAL = $area, AREA_AVERAGE = " . $average . "</br >" . "</br >";