$new_data['type'] = binary_dec(string_shift($binary_data, 1)); if ($new_data['type'] == 0) { // ID блока, чтобы не скачать старый блок $new_data['block_id'] = binary_dec(string_shift($binary_data, 3)); // нет смысла принимать старые блоки if ($new_data['block_id'] >= $block_id) { // Это хэш для соревнования, у кого меньше хэш list(, $new_data['hash']) = unpack("H*", string_shift($binary_data, 32)); // Для доп. соревнования, если head_hash равны (шалит кто-то из майнеров и позже будет за такое забанен) list(, $new_data['head_hash']) = unpack("H*", string_shift($binary_data, 32)); $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\tINSERT IGNORE INTO `" . DB_PREFIX . "queue_blocks` (\n\t\t\t\t\t`hash`,\n\t\t\t\t\t`head_hash`,\n\t\t\t\t\t`user_id`,\n\t\t\t\t\t`block_id`\n\t\t\t\t) VALUES (\n\t\t\t\t\t0x{$new_data['hash']},\n\t\t\t\t\t0x{$new_data['head_hash']},\n\t\t\t\t\t{$new_data['user_id']},\n\t\t\t\t\t{$new_data['block_id']}\n\t\t\t\t)"); //debug_print($db->printsql(), __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); } } debug_print($new_data, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); $variables = ParseData::get_variables($db, array('max_tx_size')); $need_tx = ''; // Разбираем список транзакций do { // 1 - это админские тр-ии, 0 - юзерские $new_data['high_rate'] = binary_dec(string_shift($binary_data, 1)); list(, $new_data['tx_hash']) = unpack("H*", string_shift($binary_data, 16)); // тр-ий нету if (!$new_data['tx_hash']) { debug_print('!$new_data[tx_hash]', __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); exit; } // проверим, нет ли у нас такой тр-ии $exists = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\tSELECT count(`hash`)\n\t\t\tFROM `" . DB_PREFIX . "log_transactions`\n\t\t\tWHERE `hash` = 0x{$new_data['tx_hash']}\n\t\t\t", 'fetch_one'); if ($exists) { debug_print('!exists! continue', __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
$new_ver = @file_get_contents(ABSPATH . 'version'); if (version_compare($new_ver, $my_ver) == 1) { $new_max_ver = $new_ver; $lng['new_version'] = str_ireplace('[ver]', $new_max_ver, $lng['new_version_wo_block']); } } // для пулов и ограниченных юзеров выводим сообщение без кнопок $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);
<?php if (!defined('DC')) { die("!defined('DC')"); } $tpl['data']['type'] = 'change_host'; $tpl['data']['type_id'] = ParseData::findType($tpl['data']['type']); $tpl['data']['time'] = time(); $tpl['data']['user_id'] = $user_id; $tpl['variables'] = ParseData::get_variables($db, array('limit_change_host', 'limit_change_host_period')); if (empty($_SESSION['restricted'])) { $data = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, ' SELECT `host`, `host_status` FROM `' . DB_PREFIX . MY_PREFIX . 'my_table` ', 'fetch_array'); } $status_array = array('my_pending' => $lng['local_pending'], 'approved' => $lng['status_approved']); $tpl['host'] = $data['host']; $tpl['host_status'] = $status_array[$data['host_status']]; $tpl['limits_text'] = str_ireplace(array('[limit]', '[period]'), array($tpl['variables']['limit_change_host'], $tpl['periods'][$tpl['variables']['limit_change_host_period']]), $lng['change_host_limits_text']); require_once ABSPATH . 'templates/change_host.tpl';
<?php if (!defined('DC')) { die("!defined('DC')"); } $tpl['data']['type'] = 'abuses'; $tpl['data']['type_id'] = ParseData::findType($tpl['data']['type']); $tpl['data']['time'] = time(); $tpl['data']['user_id'] = $user_id; $tpl['variables'] = ParseData::get_variables($db, array('limit_abuses', 'limit_abuses_period')); $tpl['limits_text'] = str_ireplace(array('[limit]', '[period]'), array($tpl['variables']['limit_abuses'], $tpl['periods'][$tpl['variables']['limit_abuses_period']]), $lng['abuses_limits_text']); require_once ABSPATH . 'templates/abuse.tpl';
<?php if (!defined('DC')) { die("!defined('DC')"); } $res = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tSELECT *\n\t\tFROM `" . DB_PREFIX . "points_status`\n\t\tWHERE `user_id` = {$user_id}\n\t\tORDER BY `time_start` DESC\n\t\t"); while ($row = $db->fetchArray($res)) { $tpl['points_status'][] = $row; } $tpl['my_points'] = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tSELECT `points`\n\t\tFROM `" . DB_PREFIX . "points`\n\t\tWHERE `user_id` = {$user_id}\n\t\t", 'fetch_one'); $tpl['my_points'] = intval($tpl['my_points']); $tpl['variables'] = ParseData::get_variables($db, array('points_factor', 'limit_votes_complex_period')); // среднее значение $tpl['mean'] = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tSELECT sum(`points`)/count(`points`)\n\t\tFROM `" . DB_PREFIX . "points`\n\t\tWHERE `points` > 0\n\t\t", 'fetch_one'); $tpl['mean'] = round($tpl['mean'] * $tpl['variables']['points_factor']); // есть ли тр-ия с голосованием votes_complex за послдение 4 недели $count = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tSELECT count(`user_id`)\n\t\tFROM `" . DB_PREFIX . "votes_miner_pct`\n\t\tWHERE `user_id` = {$user_id} AND\n\t\t\t\t\t `time` > " . (time() - $tpl['variables']['limit_votes_complex_period'] * 2) . "\n\t\tLIMIT 1\n\t\t", 'fetch_one'); if ($count > 0) { $tpl['votes_ok'] = 'YES'; } else { $tpl['votes_ok'] = 'NO'; } require_once ABSPATH . 'templates/points.tpl';
$res = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, ' SELECT `id`, `name`, `full_name`, `max_other_currencies` FROM `' . DB_PREFIX . 'currency` ORDER BY `full_name` '); while ($row = $db->fetchArray($res)) { $tpl['currency_list'][$row['id']] = $row; $tpl['currency_list_name'][$row['id']] = $row['name']; } $tpl['payment_systems'] = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, ' SELECT `id`, `name` FROM `' . DB_PREFIX . 'payment_systems` ORDER BY `name` ', 'list', array('id', 'name')); $res = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tSELECT `currency_id`,\n\t\t\t\t\t `amount`\n\t\tFROM `" . DB_PREFIX . "max_promised_amounts`\n\t\tWHERE `block_id` = 1\n\t\t"); while ($row = $db->fetchArray($res)) { $tpl['max_promised_amounts'][$row['currency_id']] = $row['amount']; } $res = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tSELECT `currency_id`,\n\t\t\t\t\t `amount`\n\t\tFROM `" . DB_PREFIX . "max_promised_amounts`\n\t\tWHERE `block_id` = (SELECT max(`block_id`) FROM `" . DB_PREFIX . "max_promised_amounts` ) OR `block_id` = 0\n\t\t"); while ($row = $db->fetchArray($res)) { $tpl['max_promised_amounts'][$row['currency_id']] = $row['amount']; } $tpl['variables'] = ParseData::get_variables($db, array('limit_promised_amount', 'limit_promised_amount_period')); $tpl['limits_text'] = str_ireplace(array('[limit]', '[period]'), array($tpl['variables']['limit_promised_amount'], $tpl['periods'][$tpl['variables']['limit_promised_amount_period']]), $lng['limits_text']); // валюта, которая выбрана с селект-боксе $tpl['currency_id'] = 72; require_once ABSPATH . 'templates/promised_amount_add.tpl';
<?php if (!defined('DC')) { die("!defined('DC')"); } $tpl['data']['type'] = 'change_arbitrator_conditions'; $tpl['data']['type_id'] = ParseData::findType($tpl['data']['type']); $tpl['data']['time'] = time(); $tpl['data']['user_id'] = $user_id; $tpl['variables'] = ParseData::get_variables($db, array('limit_commission', 'limit_commission_period')); $res = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, ' SELECT `id`, `name` FROM `' . DB_PREFIX . 'currency` ORDER BY `name` '); while ($row = $db->fetchArray($res)) { $tpl['currency_list'][$row['id']] = $row['name']; //$tpl['currency_min'][$row['id']] = $min_commission_array[$row['name']]; } if (empty($_SESSION['restricted'])) { $res = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, ' SELECT * FROM `' . DB_PREFIX . MY_PREFIX . 'my_commission` '); while ($row = $db->fetchArray($res)) { $my_commission[$row['currency_id']] = array($row['pct'], $row['min'], $row['max']); } } $res = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, ' SELECT *
main_unlock(); sleep(1); continue; } // в цикле собираем блоки, пока не дойдем до максимального for ($block_id = $current_block_id + 1; $block_id < $max_block_id + 1; $block_id++) { // отметимся в БД, что мы живы. upd_deamon_time($db); // отметимся, чтобы не спровоцировать очистку таблиц upd_main_lock($db); // проверим, не нужно нам выйти, т.к. обновилась версия скрипта if (check_deamon_restart($db)) { main_unlock(); exit; } $variables = ParseData::get_variables($db, array('rollback_blocks_1', 'rollback_blocks_2', 'max_block_size', 'max_tx_size', 'max_tx_count')); $ch = curl_init(); $url = "{$max_block_id_host}/{$get_block_script_name}?id={$block_id}{$add_node_host}"; debug_print($url, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT, 120); $binary_block = curl_exec($ch); curl_close($ch); debug_print('$block_data:' . $binary_block, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); upd_deamon_time($db); if (!$binary_block) { // баним на 1 час хост, который дал нам пустой блок, хотя должен был дать все до максимального // для тестов убрал, потом вставить. //nodes_ban ($db, $max_block_id_user_id, substr($binary_block, 0, 512)."\n".__FILE__.', '.__LINE__.', '. __FUNCTION__.', '.__CLASS__.', '. __METHOD__);
<?php if (!defined('DC')) { die("!defined('DC')"); } $tpl['data']['type'] = 'change_geolocation'; $tpl['data']['type_id'] = ParseData::findType($tpl['data']['type']); $tpl['data']['time'] = time(); $tpl['data']['user_id'] = $user_id; // уведомления $tpl['alert'] = @$_REQUEST['parameters']['alert']; if (empty($_SESSION['restricted'])) { $tpl['geolocation'] = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, ' SELECT `geolocation` FROM `' . DB_PREFIX . MY_PREFIX . 'my_table` ', 'fetch_one'); } if (!$tpl['geolocation']) { $tpl['geolocation'] = '39.94887, -75.15005'; } $x = explode(', ', $tpl['geolocation']); $tpl['geolocation_lat'] = $x[0]; $tpl['geolocation_lon'] = $x[1]; $tpl['country'] = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tSELECT `country`\n\t\tFROM `" . DB_PREFIX . "miners_data`\n\t\tWHERE `user_id` = {$user_id}\n\t\t", 'fetch_one'); $tpl['countries'] = $countries; $tpl['variables'] = ParseData::get_variables($db, array('limit_change_geolocation', 'limit_change_geolocation_period')); $tpl['limits_text'] = str_ireplace(array('[limit]', '[period]'), array($tpl['variables']['limit_change_geolocation'], $tpl['periods'][$tpl['variables']['limit_change_geolocation_period']]), $lng['geolocation_limits_text']); require_once ABSPATH . 'templates/geolocation.tpl';
<?php if (!defined('DC')) { die("!defined('DC')"); } $tpl['data']['type'] = 'change_primary_key'; $tpl['data']['type_id'] = ParseData::findType($tpl['data']['type']); $tpl['data']['time'] = time(); $tpl['data']['user_id'] = $user_id; $tpl['variables'] = ParseData::get_variables($db, array('limit_primary_key', 'limit_primary_key_period')); if (empty($_SESSION['restricted'])) { // выводим все запросы $res = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, ' SELECT * FROM `' . DB_PREFIX . MY_PREFIX . 'my_keys` ORDER BY `id` DESC '); //print $db->printsql(); while ($row = $db->fetchArray($res)) { $tpl['my_keys'][] = $row; } } $status_array = array('my_pending' => $lng['local_pending'], 'approved' => $lng['status_approved']); // узнаем, когда последний раз была смена ключа, чтобы не показывать юзеру страницу смены $tpl['last_change_key_time'] = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tSELECT `time`\n\t\tFROM `" . DB_PREFIX . "log_time_primary_key`\n\t\tWHERE `user_id` = {$user_id}\n\t\tORDER BY `time` DESC\n\t\t", 'fetch_one'); $tpl['limits_text'] = str_ireplace(array('[limit]', '[period]'), array($tpl['variables']['limit_primary_key'], $tpl['periods'][$tpl['variables']['limit_primary_key_period']]), $lng['change_primary_key_limits_text']); $tpl['last_tx'] = get_last_tx($user_id, $tpl['data']['type_id']); if (!empty($tpl['last_tx'])) { $tpl['last_tx_formatted'] = make_last_tx($tpl['last_tx']); } require_once ABSPATH . 'templates/change_primary_key.tpl';
FROM `' . DB_PREFIX . 'payment_systems` ORDER BY `name` ', 'list', array('id', 'name')); // список отравленных нами запросов $res = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tSELECT *\n\t\tFROM `" . DB_PREFIX . MY_PREFIX . "my_cash_requests`\n\t\tWHERE `to_user_id` != {$user_id}\n\t\t"); while ($row = $db->fetchArray($res)) { $tpl['my_cash_requests'][] = $row; } $tpl['json_currency_wallets'] = ''; // получаем список кошельков, на которых есть FC $res = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tSELECT * FROM `" . DB_PREFIX . "wallets`\n\t\tWHERE `user_id` = {$user_id} AND\n\t\t\t\t\t `currency_id` < 1000\n\t\t"); while ($row = $db->fetchArray($res)) { if ($row['currency_id'] == 1) { continue; } $row['amount'] += calc_profit_($row['currency_id'], $row['amount'], $user_id, $db, $row['last_update'], time(), 'wallet'); $tpl['json_currency_wallets'] .= "\"{$row['currency_id']}\":[\"{$tpl['currency_list'][$row['currency_id']]}\",{$row['amount']}],"; $tpl['available_currency'][] = $row['currency_id']; } $tpl['json_currency_wallets'] = substr($tpl['json_currency_wallets'], 0, strlen($tpl['json_currency_wallets']) - 1); $tpl['code'] = md5(mt_rand()); $tpl['hash_code'] = hash('sha256', hash('sha256', $tpl['code'])); $tpl['variables'] = ParseData::get_variables($db, array('node_commission', 'limit_cash_requests_out', 'limit_cash_requests_out_period', 'min_promised_amount')); $tpl['data']['type'] = 'cash_request_out'; $tpl['data']['type_id'] = ParseData::findType($tpl['data']['type']); $tpl['data']['time'] = time(); $tpl['data']['user_id'] = $user_id; $tpl['limits_text'] = str_ireplace(array('[limit]', '[period]'), array($tpl['variables']['limit_cash_requests_out'], $tpl['periods'][$tpl['variables']['limit_cash_requests_out_period']]), $lng['cash_request_out_limits_text']); $tpl['min_promised_amount'] = $tpl['variables']['min_promised_amount']; $tpl['maxlength'] = 200; require_once ABSPATH . 'templates/cash_requests_out.tpl';
<?php if (!defined('DC')) { die("!defined('DC')"); } $status_list = array('my_pending' => 'Еще не попало в FC-сеть', 'approved' => 'Принято', 'deleted' => 'Удалено'); // уведомления $tpl['alert'] = @$_REQUEST['parameters']['alert']; if (empty($_SESSION['restricted'])) { // те, что еще не попали в Dc-сеть $res = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, ' SELECT * FROM `' . DB_PREFIX . MY_PREFIX . 'my_holidays` ORDER BY `id` DESC '); while ($row = $db->fetchArray($res)) { $tpl['holidays_list']['my_pending'][] = $row; } } $res = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tSELECT *\n\t\tFROM `" . DB_PREFIX . "holidays`\n\t\tWHERE `user_id` = {$user_id}\n\t\t"); while ($row = $db->fetchArray($res)) { $tpl['holidays_list']['accepted'][] = $row; } $tpl['variables'] = ParseData::get_variables($db, array('limit_holidays', 'limit_holidays_period')); $tpl['limits_text'] = str_ireplace(array('[limit]', '[period]'), array($tpl['variables']['limit_holidays'], $tpl['periods'][$tpl['variables']['limit_holidays_period']]), $lng['holidays_limits_text']); require_once ABSPATH . 'templates/holidays_list.tpl';
if ($tpl['result'] == 'need_promised_amount') { require_once ABSPATH . 'content/promised_amount_add.php'; } else { if ($tpl['result'] == 'need_commission') { require_once ABSPATH . 'content/change_commission.php'; } else { if ($tpl['result'] == 'full_mining_menu') { $tpl['last_tx'] = get_last_tx($user_id, types_to_ids(array('new_user', 'new_miner', 'new_promised_amount', 'change_promised_amount', 'votes_miner', 'change_geolocation', 'votes_promised_amount', 'del_promised_amount', 'cash_request_out', 'cash_request_in', 'votes_complex', 'for_repaid_fix', 'new_holidays', 'actualization_promised_amounts', 'mining', 'new_miner_update', 'change_host', 'change_commission')), 3); if (!empty($tpl['last_tx'])) { $tpl['last_tx_formatted'] = make_last_txs($tpl['last_tx']); } require_once ABSPATH . 'templates/mining_menu.tpl'; } else { // сколько у нас осталось попыток стать майнером. $count_attempt = ParseData::count_miner_attempt($db, $user_id, 'user_voting'); $variables = ParseData::get_variables($db, array('miner_votes_attempt')); $tpl['miner_votes_attempt'] = $variables['miner_votes_attempt'] - $count_attempt; // комментарии проголосовавших $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, 'SET NAMES latin1'); $res = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, ' SELECT * FROM `' . DB_PREFIX . MY_PREFIX . 'my_comments` WHERE `comment` != "null" AND `type` NOT IN ("arbitrator","seller") '); while ($row = $db->fetchArray($res)) { $tpl['my_comments'][] = $row; } require_once ABSPATH . 'templates/upgrade.tpl'; } }