<?php
require_once(dirname(__FILE__).'/../../../mssqlupgrade.php');
class create_userlogin_table extends MSSQLUPGRADE 
{
	/**
	* IsAlreadyUpgraded
	* Do we need to run this classes upgrade script or not ?
	*
	* @return bool true if the upgrade has already run, otherwise false
	*/
	function IsAlreadyUpgraded()
	{
		return $this->TableExists($GLOBALS['tablePrefix'].'userlogin');
	}

	/**
	* Upgrade
	* Do the actual upgrade of this component. If this is successful all
	* subsequent calls to IsAlreadyUpgraded should return true
	*
	* @return void
	*/
	function Upgrade()
	{
		$query = "
		CREATE TABLE ".$GLOBALS['tablePrefix']."userlogin (
		  ipaddress varchar(255) NOT NULL,
		  attemptnum int NOT NULL,
		  tslogin datetime NOT NULL
		)
		";			
		$result = $GLOBALS['AKB_DB']->Query($query);

		$query = "
		CREATE  UNIQUE  INDEX idx_".$GLOBALS['tablePrefix']."_userlogin_ui_ip ON ".$GLOBALS['tablePrefix']."pageindex(ipaddress);
		";			
		$result = $GLOBALS['AKB_DB']->Query($query);
	}

}
?>
