This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require('path_check.php'); | |
function path_rename ($from, $to) { | |
if (is_dir($from)) { | |
path_check($to, 0777); | |
foreach (glob($from . DIRECTORY_SEPARATOR . '*') as $item) { | |
path_rename($item, $to . DIRECTORY_SEPARATOR . basename($item)); | |
} | |
rmdir($from); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function path_check ($path, $mode = null) { | |
if (!is_dir($path)) { | |
if (!empty($mode)) { | |
if (is_file($path)) { | |
unlink($path); | |
} | |
return mkdir($path, $mode, true); | |
} | |
return false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function cif_validation ($cif) { | |
$cif = strtoupper($cif); | |
if (preg_match('~(^[XYZ\d]\d{7})([TRWAGMYFPDXBNJZSQVHLCKE]$)~', $cif, $parts)) { | |
$control = 'TRWAGMYFPDXBNJZSQVHLCKE'; | |
$nie = array('X', 'Y', 'Z'); | |
$parts[1] = str_replace(array_values($nie), array_keys($nie), $parts[1]); | |
$cheksum = substr($control, $parts[1] % 23, 1); | |
return ($parts[2] == $cheksum); | |
} elseif (preg_match('~(^[ABCDEFGHIJKLMUV])(\d{7})(\d$)~', $cif, $parts)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function rd ($path) { | |
if (is_file($path)) { | |
unlink($path); | |
} else { | |
array_map('rd', glob($path . DIRECTORY_SEPARATOR . '*')); | |
rmdir($path); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
App::uses('Controller', 'Controller'); | |
class AppController extends Controller { | |
protected function get_controllers () { | |
$controllers = null; | |
$app_controller = get_class_methods('AppController'); | |
$controller_classes = App::objects('controller'); | |
foreach ($controller_classes as $controller_class) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function SetDrawColor() { | |
$args = func_get_args(); | |
if (count($args) and is_array($args[0])) { | |
$args = $args[0]; | |
} | |
switch (count($args)) { | |
case 1: | |
$this->DrawColor = sprintf('%.3f G', $args[0] / 100); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-Environment { | |
param ( | |
[parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()]$Name, | |
[String] $DefaultValue = $null, | |
[ValidateSet("None", "DoNotExpandEnvironmentNames")] [String] $Options = "None" | |
) | |
([Microsoft.Win32.Registry]::LocalMachine.OpenSubKey("SYSTEM\CurrentControlSet\Control\Session Manager\Environment", $true)).GetValue($Name, $DefaultValue, $Options) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-Type -Namespace Win32 -Name NativeMethods -MemberDefinition @" | |
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] | |
public static extern IntPtr SendMessageTimeout(IntPtr hWnd, uint Msg, UIntPtr wParam, string lParam, uint fuFlags, uint uTimeout, out UIntPtr lpdwResult); | |
"@ | |
function Send-SettingChange { | |
$HWND_BROADCAST = [IntPtr] 0xffff; | |
$WM_SETTINGCHANGE = 0x1a; | |
$result = [UIntPtr]::Zero |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class nvram { | |
public static function dump (string $nvramfile) { | |
$nvram = file_get_contents($nvramfile); | |
$header = unpack('a6header/v1record_count', $nvram); | |
if ($header['header'] !== 'DD-WRT') { | |
die('nvram format is not compatible); | |
} | |
$record_count = $header['record_count']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function ntp_time ($host) { | |
$msg = hex2bin('e30004fa000100000001000000000000000000000000000000000000000000000000000000000000'); | |
$data = false; | |
if ($sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP)) { | |
if (@socket_connect($sock, $host, 123)) { | |
list($xmt['time2'], $xmt['time1']) = explode(' ', microtime()); | |
$xmt['time1'] += 2208988800; | |
$xmt['time2'] *= 4294967296; | |
$msg .= pack('N*', $xmt['time1'], $xmt['time2']); |
OlderNewer