There also exist a setting in the system tab to auto-update the server IP if it changes frequently.<br><br> You can manually update this field if the IP address detected is incorrect.<br><br> Next Peer Election in<br>' . $time_election . '</strong></font><br><br> Currency Generation in<br>' . $time_generate . '</strong></font>'; if ($_GET["firewall"] == "tool") { $body_string = '<strong>This will use the settings set in the system tab (domain,folder, & port) to attempt a reverse connection attempt.</strong><br><br> <FORM ACTION="index.php?menu=generation&firewall=test" METHOD="post"><input type="submit" value="Check My Firewall"/></FORM>'; home_screen('Crypto Currency Generation', $text_bar, $body_string, $quick_info); exit; } if ($_GET["firewall"] == "test") { ini_set('user_agent', 'Timekoin Server (GUI) v' . TIMEKOIN_VERSION); ini_set('default_socket_timeout', 25); // Timeout for request in seconds // Create map with request parameters $params = array('domain' => my_domain(), 'subfolder' => my_subfolder(), 'port' => my_port_number()); // Build Http query using params $query = http_build_query($params); // Create Http context details $contextData = array('method' => 'POST', 'header' => "Connection: close\r\n" . "Content-Length: " . strlen($query) . "\r\n", 'content' => $query); // Create context resource for our request $context = stream_context_create(array('http' => $contextData)); $firewall_poll = filter_sql(file_get_contents('http://timekoin.com/utility/firewall.php', FALSE, $context, NULL, 1024)); if (empty($firewall_poll) == TRUE) { $firewall_poll = '<font color="red">No Response</font>'; } $body_string = '<strong>Test Response:</strong><br><br> ' . $firewall_poll . '<br><br> <FORM ACTION="index.php?menu=generation&firewall=test" METHOD="post"><input type="submit" value="Check My Firewall Again"/></FORM>'; home_screen('Crypto Currency Generation', $text_bar, $body_string, $quick_info); exit;
if ($peer_difference_count <= 0) { // Break out of loop break; } } // End For Loop } // End Active vs Max Peer Check //*********************************************************************************** //*********************************************************************************** // Add more peers to the new peers list to satisfy new peer limit // How many new peers do we have now? $sql = "SELECT * FROM `new_peers_list`"; $new_peers_numbers = mysql_num_rows(mysql_query($sql)); if ($new_peers_numbers < $max_new_peers && rand(1, 3) == 2) { $my_server_domain = my_domain(); if (empty($my_server_domain) == TRUE) { // No domain used $my_server_domain = "NA"; } // Add more possible peers to the new peer list by polling what the active peers have $sql = "SELECT * FROM `active_peer_list` ORDER BY RAND() LIMIT 10"; $sql_result = mysql_query($sql); $sql_num_results = mysql_num_rows($sql_result); $new_peer_difference = $max_new_peers - $new_peers_numbers; for ($i = 0; $i < $sql_num_results; $i++) { $sql_row = mysql_fetch_array($sql_result); $ip_address = $sql_row["IP_Address"]; $domain = $sql_row["domain"]; $subfolder = $sql_row["subfolder"]; $port_number = $sql_row["port_number"];
// Update Reverse Crypto Testing Data $generation_key_crypt = mysql_result(mysql_query("SELECT field_data FROM `options` WHERE `field_name` = 'generation_key_crypt' LIMIT 1"), 0, 0); if (empty($generation_key_crypt) == TRUE) { // Reverse Crypto Test is empty, create a new one. // This is just the first 181 characters of the public key encrypted via the private key. // This is then stored as a data field that is easy to access and quickly output to any // peer that is going to query this one as a potential generating peer. $arr1 = str_split($my_public_key, 181); $encryptedPublicKey = tk_encrypt($my_private_key, $arr1[0]); $encryptedPublicKey = base64_encode($encryptedPublicKey); // Update in the database. mysql_query("UPDATE `options` SET `field_data` = '{$encryptedPublicKey}' WHERE `options`.`field_name` = 'generation_key_crypt' LIMIT 1"); } // Crypt3 field will contain the IP address/Domain/etc of where the election request originates from. // This will allow a reverse check for a valid Timekoin server. $my_domain = my_domain(); $my_subfolder = my_subfolder(); $my_port = my_port_number(); $crypt3_data = "---ip={$my_generation_IP}---domain={$my_domain}---subfolder={$my_subfolder}---port={$my_port}---end"; $encryptedData3 = tk_encrypt($my_private_key, $crypt3_data); $encryptedData64_3 = base64_encode($encryptedData3); // Encrypt Generation Request into Crypt1 field $encryptedData1 = tk_encrypt($my_private_key, $generation_request); $encryptedData64_1 = base64_encode($encryptedData1); $duplicate_hash_check = hash('sha256', $encryptedData64_1 . $generation_request . $encryptedData64_3); mysql_query("INSERT INTO `my_transaction_queue` (`timestamp`,`public_key`,`crypt_data1`,`crypt_data2`,`crypt_data3`, `hash`, `attribute`)\n\t\t\t\t\t\tVALUES ('" . time() . "', '{$my_public_key}', '{$encryptedData64_1}', '{$generation_request}' , '{$encryptedData64_3}', '{$duplicate_hash_check}' , 'R')"); } // End duplicate request check } // End Election cycle available check }