Changeset View
Changeset View
Standalone View
Standalone View
src/app/Utils.php
Show First 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | public static function downloadFile($source, $target, $force = false) | ||||
unlink($target); | unlink($target); | ||||
return; | return; | ||||
} | } | ||||
curl_close($curl); | curl_close($curl); | ||||
fclose($fp); | fclose($fp); | ||||
} | } | ||||
/** | |||||
* Generate a passphrase. Not intended for use in production, so limited to environments that are not production. | |||||
* | |||||
* @return string | |||||
*/ | |||||
public static function generatePassphrase() | |||||
{ | |||||
if (\config('app.env') == 'production') { | |||||
throw new \Exception("Thou shall not pass!"); | |||||
} | |||||
if (\config('app.passphrase')) { | |||||
return \config('app.passphrase'); | |||||
} | |||||
$alphaLow = 'abcdefghijklmnopqrstuvwxyz'; | |||||
$alphaUp = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; | |||||
$num = '0123456789'; | |||||
$stdSpecial = '~`!@#$%^&*()-_+=[{]}\\|\'";:/?.>,<'; | |||||
$source = $alphaLow . $alphaUp . $num . $stdSpecial; | |||||
$result = ''; | |||||
for ($x = 0; $x < 16; $x++) { | |||||
$result .= substr($source, rand(0, (strlen($source) - 1)), 1); | |||||
} | |||||
return $result; | |||||
} | |||||
/** | /** | ||||
* Calculate the broadcast address provided a net number and a prefix. | * Calculate the broadcast address provided a net number and a prefix. | ||||
* | * | ||||
* @param string $net A valid IPv6 network number. | * @param string $net A valid IPv6 network number. | ||||
* @param int $prefix The network prefix. | * @param int $prefix The network prefix. | ||||
* | * | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 261 Lines • Show Last 20 Lines |