} } // для пулов и ограниченных юзеров выводим сообщение без кнопок $community = get_community_users($db); if (($community || !empty($_SESSION['restricted'])) && $new_max_ver) { $lng['new_version'] = str_ireplace('[ver]', $new_max_ver, $lng['new_version_pulls']); } if ($new_max_ver && $my_ver) { echo "<script>\n\t\t\t\t\$('#btn_install').bind('click', function () {\n\t\t\t\t\t\$('#new_version_text').text('Please wait');\n\t\t\t\t\t\$.post( 'ajax/install_new_version.php', {}, function(data) {\n\t\t\t\t\t\t\$('#new_version_text').text(data);\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t\t\$('#btn_upgrade').bind('click', function () {\n\t\t\t\t\t\$('#new_version_text').text('Please wait');\n\t\t\t\t\t\$.post( 'ajax/upgrade_to_new_version.php', {}, function(data) {\n\t\t\t\t\t\t\$('#new_version_text').text(data);\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t</script>\n\n\t\t\t<div class=\"alert alert-danger alert-dismissable\" style='margin-top: 30px'><button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">×</button>\n\t\t\t <h4>Warning!</h4>\n\t\t\t <div id='new_version_text'>{$lng['new_version']}</div>\n\t\t\t </div>\n\t\t\t "; } if (empty($_SESSION['restricted']) && !defined('COMMUNITY')) { $variables_ = ParseData::get_variables($db, array('alert_error_time')); $my_miner_id = get_my_miner_id($db); // если юзер уже майнер, то у него должно быть настроено точное время if ($my_miner_id) { $diff = intval(ntp_time()); if ($diff > $variables_['alert_error_time']) { $lng['alert_time'] = str_ireplace('[sec]', $diff, $lng['alert_time']); echo "\n\t\t\t\t\t <div class=\"alert alert-danger alert-dismissable\" style='margin-top: 30px'><button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">×</button>\n\t\t\t\t <h4>Warning!</h4>\n\t\t\t\t <div>{$lng['alert_time']}</div>\n\t\t\t\t </div>\n\t\t\t\t "; } } } if (empty($_SESSION['restricted'])) { // после обнуления таблиц my_node_key будет пуст // получим время из последнего блока $last_block_bin = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\tSELECT `data`\n\t\t\tFROM `" . DB_PREFIX . "block_chain`\n\t\t\tORDER BY `id` DESC\n\t\t\tLIMIT 1\n\t\t\t", 'fetch_one'); ParseData::string_shift($last_block_bin, 5); $block_time = ParseData::binary_dec_string_shift($last_block_bin, 4); // дождемся загрузки свежих блоков // if (time() - $block_time < 600) { закомменчено, т.к. при ручном откате до какого-то блока время будет старое $my_node_key = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\tSELECT `private_key`\n\t\t\t\tFROM `" . DB_PREFIX . MY_PREFIX . "my_node_keys`\n\t\t\t\tWHERE `block_id` > 0\n\t\t\t\tLIMIT 1\n\t\t\t\t", 'fetch_one');
socket_connect($sock, $host, $port); // Send request $msg = "" . str_repeat("", 47); socket_send($sock, $msg, strlen($msg), 0); // Receive response and close socket socket_recv($sock, $recv, 48, MSG_WAITALL); socket_close($sock); // Interpret response $data = unpack('N12', $recv); $timestamp = sprintf('%u', $data[9]); // NTP is number of seconds since 0000 UT on 1 January 1900 // Unix time is seconds since 0000 UT on 1 January 1970 $timestamp -= 2208988800; return $timestamp; } echo ntp_time(ntp_config::$server, ntp_config::$port); /* function query_time_server ($timeserver, $socket, $timeout){ $fp = fsockopen($timeserver,$socket,$err,$errstr,$timeout); # parameters: server, socket, error code, error text, timeout if($fp){ fputs($fp, "\n"); $timevalue = fread($fp, 49); } else{ $timevalue = " "; } fclose($fp); # close the connection $ret = array();
// "utcnist.colorado.edu"); // $time_server = "nist1.datum.com"; // I'm in California and the clock will be set to -0800 UTC [8 hours] for PST $fp = fsockopen($time_server, 37, $errno, $errstr, 30); // you will need to change this value for your region (seconds) if (!$fp) { return FALSE; } else { $data = NULL; while (!feof($fp)) { $data .= fgets($fp, 128); } fclose($fp); if (strlen($data) != 4) { // we have a response...is it valid? (4 char string -> 32 bits) echo "NTP Server {$time_server} returned an invalid response.\n"; return FALSE; } else { $NTPtime = ord($data[0]) * pow(256, 3) + ord($data[1]) * pow(256, 2) + ord($data[2]) * 256 + ord($data[3]); $TimeFrom1990 = $NTPtime - 2840140800.0; // convert the seconds to the present date & time $TimeNow = $TimeFrom1990 + 631152000; // 2840140800 = Thu, 1 Jan 2060 00:00:00 UTC return $TimeNow; } } } // end function ntp_time() print "NIST date/time is " . date("m/d/Y H:i:s", ntp_time()); echo "\n<BR />System date and time is " . date("m/d/Y H:i:s");
$pool_admin_user_id = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\t\t\tSELECT `pool_admin_user_id`\n\t\t\t\t\t\tFROM `" . DB_PREFIX . "config`\n\t\t\t\t\t\t", 'fetch_one'); $admin_user_id = $pool_admin_user_id; } else { // проверим, нода ли мы $my_table = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\t\t\tSELECT *\n\t\t\t\t\t\tFROM `" . DB_PREFIX . "my_table`\n\t\t\t\t\t\t", 'fetch_array'); if (!$my_table['miner_id']) { break; } $admin_user_id = $my_table['user_id']; } $email_sms = $notification_info[$admin_user_id]; $my_data = $user_email_sms_data[$admin_user_id]; $my_data['subj'] = $subj; if ($my_data) { $my_data['subj'] = $subj; $t = ntp_time(); if ($t > 5 || !is_int($t)) { if (is_int($t)) { $my_data['text'] = "Divergence time {$t} sec"; } else { $my_data['text'] = "Time error: {$t}"; } if ($email_sms['email']) { send_mail($my_data); } if ($email_sms['sms']) { send_sms($my_data['sms_http_get_request'], $my_data['text']); } } } break;
$TimeNow = $TimeFrom1990 + 631152000; // set the system time $TheDate = date("m/d/Y H:i:s", $TimeNow + $time_adjustment); // set the hardware clock (optional) - you may want to comment this out echo "The server's date and time was set to" . $TheDate . "\n"; } else { echo "The system time could not be updated. No time servers available.\n"; } // -------------- NTP -------------- (RFC 1305) $ntp_srvr = "pool.ntp.org"; function ntp_time($host) { // Create a socket and connect to NTP server $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); socket_connect($sock, $host, 123); // Send request $msg = "" . str_repeat("", 47); socket_send($sock, $msg, strlen($msg), 0); // Receive response and close socket socket_recv($sock, $recv, 48, MSG_WAITALL); socket_close($sock); // Interpret response $data = unpack('N12', $recv); $timestamp = sprintf('%u', $data[9]); // NTP is number of seconds since 0000 UT on 1 January 1900 // Unix time is seconds since 0000 UT on 1 January 1970 $timestamp -= 2208988800; return $timestamp; } $wtit = ntp_time($ntp_srvr); print "\r\n" . $wtit;