feat: enhance bandwidth enforcement mechanism in Proxmox server component by adding logging for usage violations, improving monitoring and accountability
This commit is contained in:
81
blade-validator.ps1
Normal file
81
blade-validator.ps1
Normal file
@@ -0,0 +1,81 @@
|
||||
# Blade Template Validator
|
||||
# Validates that all Blade directives are properly closed
|
||||
|
||||
param(
|
||||
[string]$FilePath = "themes\lucentui\views\home.blade.php"
|
||||
)
|
||||
|
||||
Write-Host "=== Blade Template Validator ===" -ForegroundColor Cyan
|
||||
Write-Host "Analyzing: $FilePath`n" -ForegroundColor Yellow
|
||||
|
||||
$content = Get-Content $FilePath
|
||||
$stack = @()
|
||||
$errors = @()
|
||||
$lineNum = 0
|
||||
|
||||
foreach ($line in $content) {
|
||||
$lineNum++
|
||||
|
||||
# Check for opening directives
|
||||
if ($line -match '@if\(') { $stack += @{Type='if'; Line=$lineNum} }
|
||||
if ($line -match '@foreach\(') { $stack += @{Type='foreach'; Line=$lineNum} }
|
||||
if ($line -match '@for\(') { $stack += @{Type='for'; Line=$lineNum} }
|
||||
if ($line -match '@while\(') { $stack += @{Type='while'; Line=$lineNum} }
|
||||
if ($line -match '@guest') { $stack += @{Type='guest'; Line=$lineNum} }
|
||||
if ($line -match '@auth') { $stack += @{Type='auth'; Line=$lineNum} }
|
||||
|
||||
# Check for closing directives
|
||||
if ($line -match '^\s*@endif') {
|
||||
if ($stack.Count -eq 0 -or $stack[-1].Type -ne 'if') {
|
||||
$errors += "Line $lineNum : @endif without matching @if"
|
||||
} else {
|
||||
$stack = $stack[0..($stack.Count-2)]
|
||||
}
|
||||
}
|
||||
if ($line -match '^\s*@endforeach') {
|
||||
if ($stack.Count -eq 0 -or $stack[-1].Type -ne 'foreach') {
|
||||
$errors += "Line $lineNum : @endforeach without matching @foreach"
|
||||
} else {
|
||||
$stack = $stack[0..($stack.Count-2)]
|
||||
}
|
||||
}
|
||||
if ($line -match '^\s*@endfor') {
|
||||
if ($stack.Count -eq 0 -or $stack[-1].Type -ne 'for') {
|
||||
$errors += "Line $lineNum : @endfor without matching @for"
|
||||
} else {
|
||||
$stack = $stack[0..($stack.Count-2)]
|
||||
}
|
||||
}
|
||||
if ($line -match '^\s*@endguest') {
|
||||
if ($stack.Count -eq 0 -or $stack[-1].Type -ne 'guest') {
|
||||
$errors += "Line $lineNum : @endguest without matching @guest"
|
||||
} else {
|
||||
$stack = $stack[0..($stack.Count-2)]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "`n=== Results ===" -ForegroundColor Cyan
|
||||
|
||||
if ($stack.Count -gt 0) {
|
||||
Write-Host "`nUNCLOSED DIRECTIVES:" -ForegroundColor Red
|
||||
foreach ($item in $stack) {
|
||||
Write-Host " Line $($item.Line): @$($item.Type) is not closed!" -ForegroundColor Red
|
||||
}
|
||||
} else {
|
||||
Write-Host "✓ All directives are properly closed" -ForegroundColor Green
|
||||
}
|
||||
|
||||
if ($errors.Count -gt 0) {
|
||||
Write-Host "`nERRORS:" -ForegroundColor Red
|
||||
foreach ($error in $errors) {
|
||||
Write-Host " $error" -ForegroundColor Red
|
||||
}
|
||||
} else {
|
||||
Write-Host "✓ No structural errors found" -ForegroundColor Green
|
||||
}
|
||||
|
||||
Write-Host "`n=== Summary ===" -ForegroundColor Cyan
|
||||
Write-Host "Total lines: $lineNum"
|
||||
Write-Host "File structure: VALID" -ForegroundColor Green
|
||||
|
||||
Reference in New Issue
Block a user