<?php

require_once('../../php/definitions.php');


$mysqli = new mysqli(PACKAGE_LOG_DB_SERVER, PACKAGE_LOG_DB_USER, PACKAGE_LOG_DB_PASS, PACKAGE_LOG_DB_NAME);
if ($mysqli->connect_errno) {
    echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}

if (!$mysqli->query("DROP PROCEDURE IF EXISTS Login_AgentIPAttempts") ||
    !$mysqli->query("
	
	CREATE PROCEDURE Login_AgentIPAttempts(IN ipaddress VARCHAR(17))
	BEGIN

	UPDATE `signature` SET `failedattempts` = 0 WHERE (`loggedip` = ipaddress) LIMIT 1;

	END;
	
	")) {
    echo "Stored procedure creation failed: (" . $mysqli->errno . ") " . $mysqli->error;
}else{
	echo "Stored Procedure Login_AgentIPAttempts created successfully.";
}

?>