
&"$PSScriptRoot\vars.ps1"
&"$PSScriptRoot\check-administrator.ps1"
&"$PSScriptRoot\fn-php.ps1"

iisreset.exe /STOP

&"$PSScriptRoot\php-upgrade-DEPRECATED.ps1" $PHP_VERSION_FULL

&"$PSScriptRoot\fresh-php-sqldrv.ps1"

# Source Guardian
if ((-Not (Test-Path "$PHPdir/ext/ixed.$PHP_VERSION.win" -PathType Leaf)))
{
	&"$PSScriptRoot\fresh-php-sg.ps1"
}

# allow for live + test to be run after each other
if ((-Not (Test-Path "$PHPdir\php.ini.cedar" -PathType Leaf)))
{
    Copy-Item "$ROOT/Scripts/php.ini" "$PHPdir\php.ini.cedar"
    Copy-Item "$ROOT/Scripts/php.ini" "$PHPdir\php.ini"
}

if ((-Not (Test-Path "C:\usr\local\lib\enchant-2\libenchant2_hunspell.dll" -PathType Leaf)))
{
	New-Item -Path "C:\usr\local\lib\enchant-2\" -ItemType Directory
	New-Item -Path "C:\usr\local\share\enchant\hunspell\" -ItemType Directory
	Copy-Item -Path "C:\Program Files\PHP\v$PHP_VERSION\lib\enchant\libenchant2_hunspell.dll" -Destination "C:\usr\local\lib\enchant-2\"
	Copy-Item -Path "$ROOT\Var\Store\en_GB.aff" -Destination "C:\usr\local\share\enchant\hunspell\"
	Copy-Item -Path "$ROOT\Var\Store\en_GB.dic" -Destination "C:\usr\local\share\enchant\hunspell\"
	
	${DriveLetter} = $pwd.drive.name
	if (-not($DriveLetter -eq 'C'))
	{
		New-Item -Path "${DriveLetter}:\usr\local\lib\enchant-2\" -ItemType Directory
    	New-Item -Path "${DriveLetter}:\usr\local\share\enchant\hunspell\" -ItemType Directory
    	Copy-Item -Path "C:\Program Files\PHP\v$PHP_VERSION\lib\enchant\libenchant2_hunspell.dll" -Destination "${DriveLetter}:\usr\local\lib\enchant-2\"
    	Copy-Item -Path "$ROOT\Var\Store\en_GB.aff" -Destination "${DriveLetter}:\usr\local\share\enchant\hunspell\"
    	Copy-Item -Path "$ROOT\Var\Store\en_GB.dic" -Destination "${DriveLetter}:\usr\local\share\enchant\hunspell\"
	}
}

&"$PSScriptRoot\int\php-perm-dirs.ps1"
