123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- require_once realpath(dirname(__FILE__)) . '/../common.php';
- ini_set("display_errors", "On");
- error_reporting(E_ALL & ~E_NOTICE);
- //
- //$source = '246ad50e54c6d53d2447ff15726b6d3b7ade21cbbf4c5a128723cb1ec21f2493';
- //$nums = getNum($source);
- //var_dump($nums);exit;
- $objGame3 = new TableHelper('game3', 'dw_box');
- $games = [];
- for ($i = 0; $i < 500; $i++) {
- // $cmd = "openssl rand 32 -hex";
- // $source = exec($cmd);
- $source = '';
- $cmd = "openssl rand 32 -hex";
- $rand = rand(1, 20);
- for ($k = 0; $k < $rand; $k++) {
- $source = exec($cmd);
- }
- $cmd = "echo '$source' | xxd -r -p | shasum -a 256 -b | awk '{print $1}'";
- $commitment = exec($cmd);
- $nums = getNum($source);
- $games[] = [
- 'id' => $i,
- 'ttl' => 80,
- 'game_state' => 2,
- 'source' => $source,
- 'commitment' => $commitment,
- 'num1' => $nums[0],
- 'num2' => $nums[1],
- 'num3' => $nums[2],
- 'create_time' => date('Y-m-d H:i:s'),
- 'update_time' => date('Y-m-d H:i:s'),
- ];
- if (count($games) > 10) {
- $objGame3->replaceObjects2($games);
- $games = [];
- }
- }
- if ($games) {
- $objGame3->replaceObjects2($games);
- }
- function getNum($source) {
- $nums = [];
- for ($i = 0; $i < 3; $i++) {
- $sum = 0;
- for ($n = 0; $n < 6; $n++) {
- $index = ($i * 6 + $n) * 2;
- $str = $source[$index] . $source[$index + 1];
- $sum += hexdec($str);
- }
- $nums[] = $sum % 6 + 1;
- }
- return $nums;
- }
|