Completed
Pull Request — master (#257)
by Matthew
03:28
created

ClearOldData.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
if (isset($_SERVER['REQUEST_METHOD'])) {
3
	die();
4
} // Web clients die.
5
6
ini_set('display_errors', 1);
7
8
require_once 'config.inc.php';
9
require_once 'includes/PdoDatabase.php';
10
11
$db = gGetDb( );
12
13
$db->transactionally(function() use ($db)
14
{
15
	global $cDataClearIp, $cDataClearEmail, $dataclear_interval;
16
    
17
	$query = $db->prepare("UPDATE request SET ip = :ip, forwardedip = null, email = :mail, useragent = '' WHERE date < DATE_SUB(curdate(), INTERVAL $dataclear_interval);");
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 169 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
18
	$success = $query->execute(array( 
19
		":ip" => $cDataClearIp,
20
		":mail" => $cDataClearEmail
21
	));
22
	
23
	if (!$success) {
24
		throw new TransactionException("Error in transaction: Could not clear data.");
25
	}
26
});
27
28
echo "Deletion complete.";
29