<?php if (!defined('DC')) { die("!defined('DC')"); } $tpl['data']['credit_part_type'] = 'money_back_request'; $tpl['data']['credit_part_type_id'] = ParseData::findType($tpl['data']['credit_part_type']); $tpl['data']['time'] = time(); $tpl['data']['user_id'] = $user_id; $tpl['my_orders'] = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tSELECT *\n\t\tFROM `" . DB_PREFIX . "orders`\n\t\tWHERE `buyer` = {$user_id}\n\t\tORDER BY `time` DESC\n\t\tLIMIT 20\n\t\t", 'all_data'); $tpl['currency_list'] = get_currency_list($db); $tpl['last_tx'] = get_last_tx($user_id, types_to_ids(array('change_seller_hold_back', 'money_back')), 3); if (!empty($tpl['last_tx'])) { $tpl['last_tx_formatted'] = make_last_txs($tpl['last_tx']); } require_once ABSPATH . 'templates/arbitration_buyer.tpl';
//print_R($row); if (!$my_data['shop_callback_url']) { // отметим merchant_checked=1, чтобы больше не брать эту тр-ию $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\t\tUPDATE `" . DB_PREFIX . $MY_PREFIX . "my_dc_transactions`\n\t\t\t\t\tSET `merchant_checked` = 1\n\t\t\t\t\tWHERE `id` = {$row['id']}\n\t\t\t\t\t"); continue; } // вначале нужно проверить, точно ли есть такой перевод в блоке $binary_data = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\tSELECT `data`\n\t\t\t\tFROM `" . DB_PREFIX . "block_chain`\n\t\t\t\tWHERE `id` = {$row['block_id']}\n\t\t\t\t", 'fetch_one'); $parsedata = new ParseData($binary_data, $db); $parsedata->ParseData_tmp(); $tx_array = $parsedata->tx_array; //print_R($tx_array); for ($i = 0; $i < sizeof($tx_array); $i++) { //print "{$tx_array[$i]['type']} === ".ParseData::findType('send_dc')."\n"; // пропускаем все ненужные тр-ии if ($tx_array[$i]['type'] != ParseData::findType('send_dc')) { continue; } $tx_array[$i]['comment'] = bin2hex($tx_array[$i]['comment']); // сравнение данных из таблы my_dc_transactions с тем, что в блоке if ($tx_array[$i]['user_id'] === $row['type_id'] && $tx_array[$i]['currency_id'] === $row['currency_id'] && (double) $tx_array[$i]['amount'] === (double) $row['amount'] && $tx_array[$i]['to_user_id'] === $row['to_user_id']) { //print 'OK==============='; // расшифруем коммент if ($row['comment_status'] == 'encrypted') { $rsa = new Crypt_RSA(); $rsa->loadKey($private_key, CRYPT_RSA_PRIVATE_FORMAT_PKCS1); $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1); $decrypted_comment = $rsa->decrypt(hextobin($row['comment'])); //echo '$private_key='.$private_key."\n"; //echo 'comment='.$row['comment']."\n"; //echo '$decrypted_comment='.$decrypted_comment."\n";
debug_print($max_promised_amount_votes, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); $new_max_promised_amounts = array(); foreach ($max_promised_amount_votes as $currency_id => $amounts_and_votes) { //$valid_amounts_and_votes = ParseData::makeMaxPromisedAmount($amounts_and_votes); //$key = get_max_vote($valid_amounts_and_votes, 0, 1000, 100); //$new_max_promised_amounts[$currency_id] = ParseData::getPctValue($key); $new_max_promised_amounts[$currency_id] = get_max_vote($amounts_and_votes, 0, 165, 10); } if (get_community_users($db)) { $my_prefix = $testBlock->user_id . '_'; } else { $my_prefix = ''; } $node_private_key = get_node_private_key($db, $my_prefix); $json_data = json_encode($new_max_promised_amounts); // подписываем нашим нод-ключем данные транзакции $data_for_sign = ParseData::findType('new_max_promised_amounts') . ",{$time},{$my_user_id},{$json_data}"; $rsa = new Crypt_RSA(); $rsa->loadKey($node_private_key); $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1); $signature = $rsa->sign($data_for_sign); debug_print('$data_for_sign=' . $data_for_sign . "\n", __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); // создаем тр-ию. пишем $block_id, на момент которого были актуальны голоса в табле 'pct' $data = dec_binary(ParseData::findType('new_max_promised_amounts'), 1) . dec_binary($time, 4) . ParseData::encode_length_plus_data($my_user_id) . ParseData::encode_length_plus_data($json_data) . ParseData::encode_length_plus_data($signature); $hash = ParseData::dsha256($data); insert_tx($data, $db); $new_tx_data['data'] = $data; $new_tx_data['hash'] = hextobin(md5($data)); tx_parser($new_tx_data, true); } main_unlock();
main_unlock(); exit; } debug_print($max_other_currencies_votes, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); $total_count_currencies = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\tSELECT count(`id`)\n\t\t\tFROM `" . DB_PREFIX . "currency`\n\t\t\t", 'fetch_one'); foreach ($max_other_currencies_votes as $currency_id => $count_and_votes) { $new_max_other_currencies[$currency_id] = get_max_vote($count_and_votes, 0, $total_count_currencies, 10); } if (get_community_users($db)) { $my_prefix = $testBlock->user_id . '_'; } else { $my_prefix = ''; } $node_private_key = get_node_private_key($db, $my_prefix); $json_data = json_encode($new_max_other_currencies); // подписываем нашим нод-ключем данные транзакции $data_for_sign = ParseData::findType('new_max_other_currencies') . ",{$time},{$my_user_id},{$json_data}"; $rsa = new Crypt_RSA(); $rsa->loadKey($node_private_key); $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1); $signature = $rsa->sign($data_for_sign); debug_print('$data_for_sign=' . $data_for_sign . "\n", __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); // создаем тр-ию. пишем $block_id, на момент которого были актуальны голоса в табле 'pct' $data = dec_binary(ParseData::findType('new_max_other_currencies'), 1) . dec_binary($time, 4) . ParseData::encode_length_plus_data($my_user_id) . ParseData::encode_length_plus_data($json_data) . ParseData::encode_length_plus_data($signature); $hash = ParseData::dsha256($data); insert_tx($data, $db); $new_tx_data['data'] = $data; $new_tx_data['hash'] = hextobin(md5($data)); tx_parser($new_tx_data, true); } main_unlock();
if (!defined('DC')) { die("!defined('DC')"); } $tpl['data']['type'] = 'change_seller_hold_back'; $tpl['data']['type_id'] = ParseData::findType($tpl['data']['type']); $tpl['data']['time'] = time(); $tpl['data']['user_id'] = $user_id; $tpl['hold_back'] = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tSELECT `arbitration_days_refund`,\n\t\t\t\t\t `seller_hold_back_pct`\n\t\tFROM `" . DB_PREFIX . "users`\n\t\tWHERE `user_id` = {$user_id}\n\t\t", 'fetch_array'); $res = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tSELECT *\n\t\tFROM `" . DB_PREFIX . "orders`\n\t\tWHERE `seller` = {$user_id}\n\t\tORDER BY `time` DESC\n\t\tLIMIT 20\n\t\t"); while ($row = $db->fetchArray($res)) { if ($row['status'] == 'refund') { if (empty($_SESSION['restricted'])) { $data = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\t\tSELECT `comment`,\n\t\t\t\t\t\t\t\t `comment_status`\n\t\t\t\t\tFROM `" . DB_PREFIX . MY_PREFIX . "my_comments`\n\t\t\t\t\tWHERE `id` = {$row['id']} AND\n\t\t\t\t\t\t\t\t `type` = 'seller'\n\t\t\t\t\tLIMIT 1\n\t\t\t\t\t", 'fetch_array'); $row['comment'] = $data['comment']; $row['comment_status'] = $data['comment_status']; } } $tpl['my_orders'][] = $row; } if (empty($_SESSION['restricted'])) { $tpl['shop_data'] = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tSELECT `shop_secret_key`,\n\t\t\t\t\t `shop_callback_url`\n\t\tFROM `" . DB_PREFIX . MY_PREFIX . "my_table`\n\t\t", 'fetch_array'); } $tpl['currency_list'] = get_currency_list($db); $tpl['miner_id'] = (int) $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tSELECT `miner_id`\n\t\tFROM `" . DB_PREFIX . "miners_data`\n\t\tWHERE `user_id` = {$user_id}\n\t\tLIMIT 1\n\t\t", 'fetch_one'); $tpl['last_tx'] = get_last_tx($user_id, types_to_ids(array('change_seller_hold_back', 'money_back')), 3); if (!empty($tpl['last_tx'])) { $tpl['last_tx_formatted'] = make_last_txs($tpl['last_tx']); } $tpl['pending_tx'] = @$pending_tx[ParseData::findType('change_seller_hold_back')]; require_once ABSPATH . 'templates/arbitration_seller.tpl';
main_lock(); $my_user_id = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\t\tSELECT `user_id`\n\t\t\t\t\tFROM `" . DB_PREFIX . MY_PREFIX . "my_table`\n\t\t\t\t\t", 'fetch_one'); $node_private_key = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\t\tSELECT `private_key`\n\t\t\t\t\tFROM `" . DB_PREFIX . MY_PREFIX . "my_node_keys`\n\t\t\t\t\tWHERE `block_id` = (SELECT max(`block_id`) FROM `" . DB_PREFIX . MY_PREFIX . "my_node_keys` )\n\t\t\t\t\t", 'fetch_one'); if (!$my_user_id || !$node_private_key) { main_unlock(); exit; } require_once ABSPATH . 'phpseclib/Math/BigInteger.php'; require_once ABSPATH . 'phpseclib/Crypt/Random.php'; require_once ABSPATH . 'phpseclib/Crypt/Hash.php'; require_once ABSPATH . 'phpseclib/Crypt/RSA.php'; $rsa = new Crypt_RSA(); extract($rsa->createKey(1024)); $publickey = clear_public_key($publickey); $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\tINSERT INTO `" . DB_PREFIX . MY_PREFIX . "my_node_keys` (\n\t\t\t\t`public_key`,\n\t\t\t\t`private_key`\n\t\t\t)\n\t\t\tVALUES (\n\t\t\t\t0x{$publickey},\n\t\t\t\t'{$privatekey}'\n\t\t\t)"); $time = time(); // подписываем нашим нод-ключем данные транзакции $data_for_sign = ParseData::findType('change_node_key') . ",{$time},{$my_user_id},{$publickey}"; $rsa = new Crypt_RSA(); $rsa->loadKey($node_private_key); $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1); $signature = $rsa->sign($data_for_sign); print '$node_private_key=' . $node_private_key . "\n"; print '$data_for_sign=' . $data_for_sign . "\n"; print 'strlen($signature)=' . strlen($signature) . "\n"; print 'strlen($publickey)=' . strlen($publickey) . "\n"; // создаем новую транзакцию $bin_public_key = hextobin($publickey); $data = dec_binary(ParseData::findType('change_node_key'), 1) . dec_binary($time, 4) . encode_length(strlen($my_user_id)) . $my_user_id . encode_length(strlen($bin_public_key)) . $bin_public_key . encode_length(strlen($signature)) . $signature; insert_tx($data, $db); main_unlock();
function types_to_ids($array) { $new = array(); for ($i = 0; $i < sizeof($array); $i++) { $new[] = ParseData::findType($array[$i]); } return $new; }
} $tpl['comments'][] = $row; } } // сколько всего комментов на каждом языке $tpl['project']['lang_comments'] = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tSELECT `lang_id`,\n\t\t\t\t\t count(`id`) as `count`\n\t\tFROM `" . DB_PREFIX . "cf_comments`\n\t\tWHERE `project_id` = {$tpl['project_id']}\n\t\tGROUP BY `lang_id`\n\t\t", 'list', array('lang_id', 'count')); $tpl['project']['count_comments'] = array_sum($tpl['project']['lang_comments']); // 66 языков $tpl['cf_lng'] = get_all_cf_lng($db); // инфа об авторе проекта $tpl['project']['author'] = get_cf_author_name($db, $tpl['project']['user_id'], $tpl['cf_url']); // возможно наш юзер фундер $tpl['project']['funder'] = ''; if ($user_id) { $tpl['project']['funder'] = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\tSELECT `id`\n\t\t\tFROM `" . DB_PREFIX . "cf_funding`\n\t\t\tWHERE `project_id` = {$tpl['project_id']} AND\n\t\t\t\t\t\t `user_id` = {$user_id} AND\n\t\t\t\t\t\t `del_block_id` = 0\n\t\t\t", 'fetch_one'); } $tpl['comment_data']['type'] = 'cf_comment'; $tpl['comment_data']['type_id'] = ParseData::findType($tpl['comment_data']['type']); $tpl['data']['time'] = time(); $tpl['data']['user_id'] = $user_id; $tpl['pages_array'] = array('home', 'news', 'funders', 'comments'); $tpl['config'] = get_node_config(); $tpl['config']['cf_ps'] = json_decode($tpl['config']['cf_ps'], true); // узнаем, какие платежные системы доступны данному проекту $tpl['project']['ps'] = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tSELECT *\n\t\tFROM `" . DB_PREFIX . "cf_projects_ps`\n\t\tWHERE `project_id` = {$tpl['project_id']}\n\t\t", 'fetch_array'); // узнаем, не в блек-листе ли проект $black = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tSELECT `project_id`\n\t\tFROM `" . DB_PREFIX . "cf_blacklist`\n\t\tWHERE `project_id` = {$tpl['project_id']}\n\t\t", 'fetch_one'); if ($black) { die('project in blacklist'); } require_once ABSPATH . 'templates/cf_page_preview.tpl';
unlink($face_path); debug_print('VOTE = NO', __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); } // проходимся по всем нашим майнерам, если это пул и по одному, если это сингл-мод foreach ($intersect_my_miners as $my_miner_id) { $my_user_id = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\t\t\tSELECT `user_id`\n\t\t\t\t\t\tFROM `" . DB_PREFIX . "miners_data`\n\t\t\t\t\t\tWHERE `miner_id` = {$my_miner_id}\n\t\t\t\t\t\t", 'fetch_one'); $community = get_community_users($db); if ($community) { $my_prefix = $my_user_id . '_'; } else { $my_prefix = ''; } $node_private_key = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\t\t\tSELECT `private_key`\n\t\t\t\t\t\tFROM `" . DB_PREFIX . "{$my_prefix}my_node_keys`\n\t\t\t\t\t\tWHERE `block_id` = (SELECT max(`block_id`) FROM `" . DB_PREFIX . "{$my_prefix}my_node_keys` )\n\t\t\t\t\t\t", 'fetch_one'); $time = time(); // подписываем нашим нод-ключем данные транзакции $data_for_sign = ParseData::findType('votes_node_new_miner') . ",{$time},{$my_user_id},{$row['vote_id']},{$vote}"; $rsa = new Crypt_RSA(); $rsa->loadKey($node_private_key); $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1); $signature = $rsa->sign($data_for_sign); debug_print('$data_for_sign=' . $data_for_sign, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); // создаем новую транзакцию - подверждение, что фото скопировано и проверено. $data = dec_binary(30, 1) . dec_binary($time, 4) . ParseData::encode_length_plus_data($my_user_id) . ParseData::encode_length_plus_data($row['vote_id']) . ParseData::encode_length_plus_data($vote) . ParseData::encode_length_plus_data($signature); insert_tx($data, $db); } } // отмечаем, чтобы больше не брать эту строку $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\tUPDATE `" . DB_PREFIX . "votes_miners`\n\t\t\t\tSET `cron_checked_time` = " . time() . "\n\t\t\t\tWHERE `id` = {$row['vote_id']}\n\t\t\t\t"); } main_unlock(); sleep(1);
} $res = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, ' SELECT * FROM `' . DB_PREFIX . 'currency` '); while ($row = $db->fetchArray($res)) { if (isset($my_commission[$row['id']])) { $tpl['commission'][$row['id']] = $my_commission[$row['id']]; } else { $tpl['commission'][$row['id']] = array(0.1, $tpl['currency_min'][$row['id']], 0); } } // для CF-проектов $tpl['currency_list'][1000] = 'Crowdfunding'; if (isset($my_commission[1000])) { $tpl['commission'][1000] = $my_commission[1000]; } else { $tpl['commission'][1000] = array(0.1, 0.01, 0); } $tpl['conditions'] = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tSELECT `conditions`\n\t\tFROM `" . DB_PREFIX . "arbitrator_conditions`\n\t\tWHERE `user_id` = {$user_id}\n\t\tLIMIT 1\n\t\t", 'fetch_one'); $tpl['conditions'] = json_decode($tpl['conditions'], true); if (!$tpl['conditions']) { $tpl['conditions'][72] = array('0.01', '0', '0.01', '0', '0.1'); $tpl['conditions'][23] = array('0.01', '0', '0.01', '0', '0.1'); } $tpl['last_tx'] = get_last_tx($user_id, types_to_ids(array('change_arbitrator_conditions')), 3); if (!empty($tpl['last_tx'])) { $tpl['last_tx_formatted'] = make_last_txs($tpl['last_tx']); } $tpl['pending_tx'] = @$pending_tx[ParseData::findType('change_arbitrator_conditions')]; require_once ABSPATH . 'templates/change_arbitrator_conditions.tpl';
$row['count_rejected_refunds'] = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\tSELECT count(`id`)\n\t\t\tFROM `" . DB_PREFIX . "orders`\n\t\t\tLEFT JOIN `" . DB_PREFIX . "miners_data` ON `" . DB_PREFIX . "miners_data`.`user_id` = `" . DB_PREFIX . "orders`.`buyer`\n\t\t\tWHERE (`arbitrator0` = {$row['arbitrator_user_id']} OR `arbitrator1` = {$row['arbitrator_user_id']} OR `arbitrator2` = {$row['arbitrator_user_id']} OR `arbitrator3` = {$row['arbitrator_user_id']} OR `arbitrator4` = {$row['arbitrator_user_id']}) AND\n\t\t\t\t\t\t `" . DB_PREFIX . "orders`.`status` = 'refund' AND\n\t\t\t\t\t\t `end_time` > " . (time() - 3600 * 24 * 30) . " AND\n\t\t\t\t\t\t `end_time` < " . time() . " AND\n\t\t\t\t\t\t `voluntary_refund` = 0 AND\n\t\t\t\t\t\t `refund` = 0 AND\n\t\t\t\t\t\t `" . DB_PREFIX . "miners_data`.`status` = 'miner'\n\t\t\tGROUP BY `user_id`\n\t\t\t", 'fetch_one'); $tpl['arbitrators'][] = $row; } /* $tpl['arbitrators'] = array(); $tpl['arbitrators'][] = array('arbitrator_user_id'=>1967, 'url'=>'11111', 'count' => 1264, 'refund_data' =>array('count'=>687, 'sum'=>10250), 'count_rejected_refunds' =>12 ); $tpl['arbitrators'][] = array('arbitrator_user_id'=>2695, 'url'=>'11111', 'count' => 598, 'refund_data' =>array('count'=>212, 'sum'=>4691), 'count_rejected_refunds' =>3 ); $tpl['arbitrators'][] = array('arbitrator_user_id'=>1687, 'url'=>'11111', 'count' => 469, 'refund_data' =>array('count'=>316, 'sum'=>4269), 'count_rejected_refunds' =>26 ); $tpl['arbitrators'][] = array('arbitrator_user_id'=>256, 'url'=>'11111', 'count' => 369, 'refund_data' =>array('count'=>244, 'sum'=>2897), 'count_rejected_refunds' =>2 ); $tpl['arbitrators'][] = array('arbitrator_user_id'=>9753, 'url'=>'11111', 'count' => 122, 'refund_data' =>array('count'=>155, 'sum'=>1717), 'count_rejected_refunds' =>15 ); //print_R($tpl['arbitrators']); //print_R($tpl['my_trust_list']); $tpl['my_trust_list'] = array(); $tpl['my_trust_list'][] = array('arbitrator_user_id' => 1967, 'url' =>'111', 'count' => 1264); $tpl['my_trust_list'][] = array('arbitrator_user_id' => 2695, 'url' =>'111', 'count' => 598); $tpl['my_trust_list'][] = array('arbitrator_user_id' => 1687, 'url' =>'111', 'count' => 469); $tpl['my_trust_list'][] = array('arbitrator_user_id' => 256, 'url' =>'111', 'count' => 369); $tpl['my_trust_list'][] = array('arbitrator_user_id' => 9753, 'url' =>'111', 'count' => 122); */ // арбитр ли наш юзер $tpl['arbitrator'] = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tSELECT `conditions`\n\t\tFROM `" . DB_PREFIX . "arbitrator_conditions`\n\t\tWHERE `user_id` = {$user_id}\n\t\t", 'fetch_one'); // продавец ли $tpl['arbitration_days_refund'] = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tSELECT `arbitration_days_refund`\n\t\tFROM `" . DB_PREFIX . "users`\n\t\tWHERE `user_id` = {$user_id}\n\t\t", 'fetch_one'); $tpl['arbitration_trust_list'] = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tSELECT `arbitrator_user_id`\n\t\tFROM `" . DB_PREFIX . "arbitration_trust_list`\n\t\tWHERE `user_id` = {$user_id}\n\t\t", 'fetch_one'); $tpl['currency_list'] = get_currency_list($db); $tpl['last_tx'] = get_last_tx($user_id, types_to_ids(array('change_arbitrator_conditions', 'change_seller_hold_back', 'change_arbitrator_list', 'money_back_request', 'money_back', 'change_money_back_time')), 3); if (!empty($tpl['last_tx'])) { $tpl['last_tx_formatted'] = make_last_txs($tpl['last_tx']); } $tpl['pending_tx'] = @$pending_tx[ParseData::findType('change_arbitrator_list')]; require_once ABSPATH . 'templates/arbitration.tpl';
$tpl['user_id'] = $_SESSION['user_id']; if ($tpl['user_id'] != 'wait') { $tpl['wallets'] = get_balances($user_id); if (empty($_SESSION['restricted'])) { // получаем последние транзакции по кошелькам $res = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\tSELECT *\n\t\t\t\tFROM `" . DB_PREFIX . MY_PREFIX . "my_dc_transactions`\n\t\t\t\tORDER BY `id` DESC\n\t\t\t\tLIMIT 0, 100\n\t\t\t\t"); while ($row = $db->fetchArray($res)) { $tpl['my_dc_transactions'][] = $row; } } } //$tpl['variables'] = ParseData::get_variables ($db, array('node_commission') ); $tpl['data']['user_type'] = 'send_dc'; $tpl['data']['project_type'] = 'cf_send_dc'; $tpl['data']['user_type_id'] = ParseData::findType($tpl['data']['user_type']); $tpl['data']['project_type_id'] = ParseData::findType($tpl['data']['project_type']); $tpl['data']['time'] = time(); $tpl['data']['user_id'] = $user_id; $tpl['data']['current_block_id'] = get_block_id($db); $tpl['data']['confirmed_block_id'] = get_confirmed_block_id($db); $names = array('cash_request' => $lng['cash'], 'from_mining_id' => $lng['from_mining'], 'from_repaid' => $lng['from_repaid_mining'], 'from_user' => $lng['from_user'], 'node_commission' => $lng['node_commission'], 'system_commission' => 'system_commission', 'referral' => 'referral', 'cf_project' => 'Crowd funding', 'cf_project_refund' => 'Crowd funding refund'); $tpl['miner_id'] = (int) $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tSELECT `miner_id`\n\t\tFROM `" . DB_PREFIX . "miners_data`\n\t\tWHERE `user_id` = {$user_id}\n\t\tLIMIT 1\n\t\t", 'fetch_one'); // если юзер кликнул по кнопку "профинансировать" со страницы проекта if (!empty($_REQUEST['parameters']['project_id'])) { $tpl['cf_project_id'] = intval($_REQUEST['parameters']['project_id']); } // нужна мин. комиссия на пуле для перевода монет $tpl['config'] = get_node_config(); $tpl['config']['commission'] = json_decode($tpl['config']['commission'], true); //print_R($tpl['config']['commission']); $tpl['last_tx'] = get_last_tx($user_id, $tpl['data']['user_type_id']);
} if (!$new_admin) { main_unlock(); exit; } $testBlock = new testblock($db, true); if (get_community_users($db)) { $my_prefix = $testBlock->user_id . '_'; } else { $my_prefix = ''; } $node_private_key = get_node_private_key($db, $my_prefix); // подписываем нашим нод-ключем данные транзакции $data_for_sign = ParseData::findType('new_admin') . ",{$time},{$my_user_id},{$new_admin}"; $rsa = new Crypt_RSA(); $rsa->loadKey($node_private_key); $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1); $signature = $rsa->sign($data_for_sign); debug_print('$data_for_sign=' . $data_for_sign . "\n", __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); // создаем тр-ию. пишем $block_id, на момент которого были актуальны голоса в табле 'pct' $data = dec_binary(ParseData::findType('new_admin'), 1) . dec_binary($time, 4) . ParseData::encode_length_plus_data($my_user_id) . ParseData::encode_length_plus_data($new_admin) . ParseData::encode_length_plus_data($signature); $hash = ParseData::dsha256($data); insert_tx($data, $db); // и не закрывая main_lock переводим нашу тр-ию в verified=1, откатив все несовместимые тр-ии // таким образом у нас будут в блоке только актуальные голоса. // а если придет другой блок и станет verified=0, то эта тр-ия просто удалится. $new_tx_data['data'] = $data; $new_tx_data['hash'] = hextobin(md5($data)); tx_parser($new_tx_data, true); } main_unlock();
<?php if (!defined('DC')) { die("!defined('DC')"); } $tpl['data']['type'] = 'change_key_close'; $tpl['data']['type_id'] = ParseData::findType($tpl['data']['type']); $tpl['data']['time'] = time(); $tpl['data']['user_id'] = $user_id; require_once ABSPATH . 'templates/change_key_close.tpl';
session_start(); if (empty($_SESSION['user_id'])) { die('!user_id'); } define('DC', TRUE); define('ABSPATH', dirname(dirname(__FILE__)) . '/'); set_time_limit(0); //require_once( ABSPATH . 'includes/errors.php' ); require_once ABSPATH . 'db_config.php'; require_once ABSPATH . 'includes/autoload.php'; $db = new MySQLidb(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME, DB_PORT); define('MY_PREFIX', get_my_prefix($db)); $_REQUEST['time'] = intval($_REQUEST['time']); $_REQUEST['user_id'] = intval($_REQUEST['user_id']); $type = ParseData::findType($_REQUEST['type']); $time = intval($_REQUEST['time']); $user_id = intval($_REQUEST['user_id']); $signature1 = hextobin($_POST['signature1']); $signature2 = hextobin(@$_POST['signature2']); $signature3 = hextobin(@$_POST['signature3']); $sign = ParseData::encode_length_plus_data($signature1); if ($signature2) { $sign .= ParseData::encode_length_plus_data($signature2); } if ($signature3) { $sign .= ParseData::encode_length_plus_data($signature3); } $bin_signatures = ParseData::encode_length_plus_data($sign); switch ($_REQUEST['type']) { case 'new_user':
// хосты могут еще не успеть набраться if (!$hosts) { sleep(1); continue; } } else { // защищеннй режим $node_data = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\tSELECT `node_public_key`,\n\t\t\t\t\t\t\t `host`\n\t\t\t\tFROM `" . DB_PREFIX . "miners_data`\n\t\t\t\tWHERE `user_id` = {$my_config['static_node_user_id']}\n\t\t\t\t", 'fetch_array'); $hosts[] = array('host' => $my_config['local_gate_ip'], 'node_public_key' => $node_data['node_public_key'], 'user_id' => $my_config['static_node_user_id']); } debug_print($hosts, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); $my_users_ids = get_my_users_ids($db); $my_miners_ids = get_my_miners_ids($db, $my_users_ids); // если среди тр-ий есть смена нодовского ключа, то слать через отправку хэшей с последющей отдачей данных может не получиться // т.к. при некорректном нодовском ключе придет зашифрованый запрос на отдачу данных, а мы его не сможем расшифровать т.к. ключ у нас неверный $change_node_key = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\tSELECT count(*)\n\t\t\tFROM `" . DB_PREFIX . "transactions`\n\t\t\tWHERE `type` = " . ParseData::findType('change_node_key') . " AND\n\t\t\t\t\t\t `user_id` IN (" . implode(',', $my_users_ids) . ")\n\t\t\t", 'fetch_one'); // если я майнер и работаю в обычном режиме, то должен слать хэши if ($my_miners_ids && !$my_config['local_gate_ip'] && !$change_node_key) { // опредлим, от кого будем слать $r = array_rand($my_miners_ids); $my_miner_id = $my_miners_ids[$r]; $my_user_id = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\tSELECT `user_id`\n\t\t\t\tFROM `" . DB_PREFIX . "miners_data`\n\t\t\t\tWHERE `miner_id` = {$my_miner_id}\n\t\t\t\t", 'fetch_one'); for ($i = 0; $i < sizeof($hosts); $i++) { $urls[$i] = array('url' => $hosts[$i]['host'] . 'gate_hashes.php', 'node_public_key' => $hosts[$i]['node_public_key'], 'user_id' => $hosts[$i]['user_id']); } //main_lock(); // //возьмем хэш текущего блока и номер блока // //для теста ролбеков отключим на время $data = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\tSELECT `block_id`,\n\t\t\t\t\t\t\t `hash`,\n\t\t\t\t\t\t\t `head_hash`\n\t\t\t\tFROM `" . DB_PREFIX . "info_block`\n\t\t\t\tWHERE `sent` = 0\n\t\t\t\t", 'fetch_array'); debug_print($data, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); //$data = ''; // //для тестов
//print $reduction_pct."\n"; //print $reduction_type."\n"; //print $reduction_currency_id."\n"; if (isset($reduction_currency_id) && isset($reduction_pct)) { if (get_community_users($db)) { $my_prefix = $testBlock->user_id . '_'; } else { $my_prefix = ''; } $node_private_key = get_node_private_key($db, $my_prefix); print $my_prefix . "\n"; // подписываем нашим нод-ключем данные транзакции $data_for_sign = ParseData::findType('new_reduction') . ",{$time},{$my_user_id},{$reduction_currency_id},{$reduction_pct},{$reduction_type}"; $rsa = new Crypt_RSA(); $rsa->loadKey($node_private_key); $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1); $signature = $rsa->sign($data_for_sign); debug_print('$data_for_sign=' . $data_for_sign . "\n", __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); print $data_for_sign; print $node_private_key; // создаем тр-ию. пишем $block_id, на момент которого были актуальны голоса и статусы банкнот $reduction_tx_data = dec_binary(ParseData::findType('new_reduction'), 1) . dec_binary($time, 4) . ParseData::encode_length_plus_data($my_user_id) . ParseData::encode_length_plus_data($reduction_currency_id) . ParseData::encode_length_plus_data($reduction_pct) . ParseData::encode_length_plus_data($reduction_type) . ParseData::encode_length_plus_data($signature); insert_tx($reduction_tx_data, $db); // и не закрывая main_lock переводим нашу тр-ию в verified=1, откатив все несовместимые тр-ии // таким образом у нас будут в блоке только актуальные голоса. // а если придет другой блок и станет verified=0, то эта тр-ия просто удалится. $new_tx_data['data'] = $reduction_tx_data; $new_tx_data['hash'] = hextobin(md5($reduction_tx_data)); tx_parser($new_tx_data, true); } main_unlock();