summaryrefslogtreecommitdiff
path: root/extensions/FunnyDot.php
blob: 81636bb437413f8490415e5d4f0a23a2577ca42d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php

if ( defined( 'MEDIAWIKI' ) ) {

global $wgHooks;
$wgHooks['ArticleSave'][] = 'checkAntiSpamHash';


function checkAntiSpamHash()
	{
	global $wgAntiSpamHash, $wgAntiSpamTimeout, $wgAntiSpamWait;

	$now = time();

	if (!empty($_COOKIE['AntiSpamTime']) && !empty($_COOKIE['AntiSpamHash']))
		{
		$time = intval($_COOKIE['AntiSpamTime']);
		$hash = $_COOKIE['AntiSpamHash'];

		if ($hash != sha1($time.$wgAntiSpamHash))
			{
			return false;
			}

		if ($now - $time > $wgAntiSpamTimeout)
			{
			return false;
			}
		elseif ($now - $time < $wgAntiSpamWait)
			{
			return false;
			}
		}
	else
		{
		return false;
		}

	return true;
	}

} # End invocation guard
?>