代码拉取完成,页面将自动刷新
同步操作将从 Yeelight/lottery 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
<?php
/**
* Created by PhpStorm.
* User: sheldon
* Date: 18-1-22
* Time: 下午1:55
*/
$users = json_decode(file_get_contents('data/users.json'), true);
$prizes = json_decode(file_get_contents('data/prizes.json'), true);
$winners = json_decode(file_get_contents('data/winners.json'), true);
$ignores = json_decode(file_get_contents('data/ignore.json'), true);
function getPrizeNameById($prizes, $id) {
if (!empty($prizes)) {
foreach ($prizes as $index => $prize) {
if ($prize['id'] == $id) {
return $prize['name'];
}
}
}
return "";
}
function userNotExist($users, $name) {
if (!empty($users)) {
foreach ($users as $index => $user) {
if ($user == $name) {
return false;
}
}
}
return true;
}
/**
* 根据范围取范围内随机数
* @param $max
* @return int
*/
function my_random($max) {
if ($max < 2) {
return 1;
}
return getRandom(1, $max);
$url = "https://www.random.org/integers/?num=1&min=1&max={$max}&col=1&base=10&format=plain&rnd=new";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$data = curl_exec($curl);
curl_close($curl);
list($header, $body) = explode("\r\n\r\n", $data, 2);
preg_match_all("/HTTP\/1\.1 ([\d]{3})/", $header, $matches);
if (isset($matches[1][0]) && $matches[1][0] == 200) {
return $body;
} else {
return getRandom(1, $max);
}
}
/**
* 调用系统 /dev/urandom 获取随机数
* @param int $min
* @param int $max
* @return int
*/
function getRandom($min = 0, $max = 0x7FFFFFFF)
{
$diff = $max - $min;
if ($diff > PHP_INT_MAX) {
throw new RuntimeException('Bad Range');
}
$fh = fopen('/dev/urandom', 'r');
stream_set_read_buffer($fh, PHP_INT_SIZE);
$bytes = fread($fh, PHP_INT_SIZE );
if ($bytes === false || strlen($bytes) != PHP_INT_SIZE ) {
//throw new RuntimeException("nable to get". PHP_INT_SIZE . "bytes");
return 0;
}
fclose($fh);
if (PHP_INT_SIZE == 8) { // 64-bit versions
list($higher, $lower) = array_values(unpack('N2', $bytes));
$value = $higher << 32 | $lower;
}
else { // 32-bit versions
list($value) = array_values(unpack('Nint', $bytes));
}
$val = $value & PHP_INT_MAX;
$fp = (float)$val / PHP_INT_MAX; // convert to [0,1]
return (int)(round($fp * $diff) + $min);
}
$error = $success = $warning = "";
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。