Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#
- List-Banned.ps1 -file <file.json> [-delay <seconds>]
- V. 20201115-1132
- Where: file.json = CTBRec config file, (usually ctbrec.json or server.json)
- seconds = Delay between each Web Request, (avoid possible error 503), valid range 0.1-90
- example: List-Banned.ps1 -file server.json
- List-Banned.ps1 -file ctbrec.json -delay 3
- List models with pages that don't resolve, (error 404, etc), or CB models that are banned.
- Output will be to Model-Status.txt in the same dir as List-Banned.ps1.
- File will be overwritten in consecutive runs.
- Prints a number and the model name as it progresses, will only consign HTTP error codes 4xx
- to the output file + CB Banned rooms.
- Output file will open after it's finished.
- Tested on PowerShell 7, Windows 10 and DietPi 6.33.3, (RasPi).
- *** NOTE: Only tested with a few models on CB because I only monitor 1-3 models there, so if
- no-one tells me anything I'll assume it works on all sites.
- #>
- param (
- [Parameter(Mandatory=$true)][string]$file,
- [ValidateRange(0.1,90)][decimal]$delay
- )
- $httpErrors = @{
- 400 = 'Bad Request'
- 401 = 'Unauthorized'
- 402 = 'Payment Required'
- 403 = 'Forbidden'
- 404 = 'Not Found'
- 405 = 'Method Not Allowed'
- 406 = 'Not Acceptable'
- 407 = 'Proxy Authentication Required'
- 408 = 'Request Timeout'
- 409 = 'Conflict'
- 410 = 'Gone'
- 411 = 'Length Required'
- 412 = 'Precondition Failed'
- 413 = 'Payload Too Large'
- 414 = 'URI Too Long'
- 415 = 'Unsupported Media Type'
- 416 = 'Range Not Satisfiable'
- 417 = 'Expectation Failed'
- 418 = "I'm a teapot"
- 421 = 'Misdirected Request'
- 425 = 'Too Early'
- 426 = 'Upgrade Required'
- 428 = 'Precondition Required'
- 429 = 'Too Many Requests'
- 431 = 'Request Header Fields Too Large'
- 451 = 'Unavailable For Legal Reasons'
- }
- function Test-Url ([string] $Url) {
- $req = [system.Net.WebRequest]::Create($url)
- try {
- $res = $req.GetResponse()
- }
- catch [System.Net.WebException] {
- $res = $_.Exception.Response
- }
- return $res
- }
- function Test-Models ([string] $infile) {
- $json = (Get-Content $infile | ConvertFrom-Json)
- for ($i = 0; $i -lt $json.models.Count; $i++) {
- $statusCode = [int](Test-Url $json.models[$i].url).StatusCode
- "$($i) - $($json.models[$i].name)"
- if ($statusCode -gt 399 -and $statusCode -lt 500) {
- "$($json.models[$i].name) - $($statusCode) - $($httpErrors[$statusCode])" | Out-File -FilePath Model-Status.txt -Append
- } else {
- if ($json.models[$i].type -match 'chaturbate') {
- $data = Invoke-WebRequest -Uri $json.models[$i].url
- if ($data -match 'This room has been banned') {
- "$($json.models[$i].name) - Banned" | Out-File -FilePath Model-Status.txt -Append
- }
- }
- }
- if ($delay -gt 0) {
- Start-Sleep -Seconds $delay
- }
- }
- }
- if (Test-Path ./Model-Status.txt) {
- Remove-Item ./Model-Status.txt -Force
- }
- Get-Date -Format u | Out-File -FilePath Model-Status.txt
- Test-Models $file
- Invoke-Item .\Model-Status.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement