1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
<# .Synopsis Check file header if it is a JPG file .EXAMPLE Check one file: Test-JPGHeader -File c:\temp\myPicture.jpg .EXAMPLE Check all jpeg files in one folder (ls c:\pictures\*.jpg ).FullName | % {if ((Test-JPGHeader -File $_) -eq $false) {Write-Host "$_ is not real JPG"}} .NOTES If file doesn't exists, function returns false #> Function Test-JPGHeader { Param ([Parameter(Mandatory=$true, Position=0)] [String]$File) $Result = $false if ((Test-Path $File) -eq $false) { Return $Result Break; } [String]$JPG = "255216255" [Byte[]]$RAWHeader = Get-Content $File -TotalCount 3 -Encoding Byte [String]$Header += $RAWHeader $Header = $Header.Replace(" ","") $Result = $JPG -contains $Header Return $Result } |
Syntax:
Get-ChildItemPlus [-Path] <string> [-Level] <integer> [-Type] <string>
Example 1:
Get-ChildItemPlus c:\temp 2 Folder
This command retrieves all of the folders in the c:\temp path till second level.
Example 2:
Get-ChildItemPlus c:\temp 3 Files
This command retrieves all of the files in the c:\temp path till third level.
Parameters:
- Path
Specifies a path to location
- Level
Specifies a depth to search - e.g. c:\windows\system32 is level 2
- Type
The type of object that Get-ChildItem returns: File, Folder, Both
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
Function Get-ChildItemPlus { Param ([Parameter(Mandatory = $true, ValueFromPipeline = $false, Position = 0)] [string]$Path = ".", [Parameter(Mandatory = $true, ValueFromPipeline = $false, Position = 1)] [int]$Level = 99, [Parameter(Mandatory = $true, ValueFromPipeline = $false, Position = 2)] [string]$Type = "") switch ($Type) { "Folder" {$Data = Get-ChildItem -Path "$Path" -Recurse | Where-Object {$_.psIsContainer -eq $True}} "File" {$Data = Get-ChildItem -Path "$Path" -Recurse | Where-Object {! $_.psIsContainer}} default {$Data = Get-ChildItem -Path "$Path" -Recurse} } if ($Data -eq $Null) {Break} $Level++ $Output = @() foreach ($Item in $Data) { $Folder = $Item.FullName.ToString() if ($Folder.Split("\").Count -le "$Level") { $Output += "$Folder" } } return $Output } |
Jednoduchý plugin na logování IP adres návštěvníků. Po aktivaci vytvoří v databázi tabulku „wp_iplog_v1“, do které zapisuje: $_SERVER["REMOTE_ADDR"] //IP v4
$_SERVER["REQUEST_URI"] // cílová stránka
$_SERVER["HTTP_HOST"] // cílový web
$_SERVER["HTTP_USER_AGENT"] // user agent (os, browser, bot)
$_SERVER["HTTP_REFERER"] // referer
Plugin nemá žádné rozhraní, data jsou dostupná pouze z databáze.
Otestován na verzi WordPress 3.2.
Stáhnout IPLog verze 1
Za případné chyby neručím :)