2 // $Id: spam_pickup.php,v 1.24 2006/12/16 01:55:15 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'] : '';
62 $progress = check_uri_spam(array('a', $msg, 'b'), array(), FALSE);
64 if (! empty($progress)) {
65 $action = 'Metrics: ' . summarize_spam_progress($progress, FALSE);
67 if (! empty($progress['is_spam'])) {
68 $action = 'Blocked by: ' . summarize_spam_progress($progress, TRUE);
74 $results = spam_uri_pickup($msg);
75 $results = uri_array_normalize($results, TRUE);
76 var_dump('$results', $results);