function ban_ip() { // Add the IP address to the blacklist file $bfh = fopen(SANDTRAP_BLACKLIST, "at"); fwrite($bfh, $_SERVER['REMOTE_ADDR'] . "\n"); fclose($bfh); log_ip(); show_banned_message(); halt(); }
if ($fresh_system === FALSE) { // Stop all other script activity until the user actually starts the system. // This is useful when recoving from an unknown error or crash. activate(TIMEKOINSYSTEM, 0); } // All match, set login variable and store username in cookie $_SESSION["login_username"] = $http_username; $_SESSION["valid_login"] = TRUE; header("Location: index.php?menu=home"); exit; } } // Log invalid attempts write_log("Invalid Login from IP: " . $_SERVER['REMOTE_ADDR'] . " trying Username:[" . $http_username . "] with Password:[" . $http_password . "]", "GU"); } log_ip("GU", scale_trigger(3)); // Avoid flood-brute password guessing sleep(1); // One second delay to help prevent brute force attack login_screen("Login Failed"); exit; } if ($_SESSION["valid_login"] == TRUE) { //**************************************************************************** if (mysql_connect(MYSQL_IP, MYSQL_USERNAME, MYSQL_PASSWORD) == FALSE) { home_screen('ERROR', '<font color="red"><strong>Could Not Connect To Database</strong></font>', '', ''); exit; } if (mysql_select_db(MYSQL_DATABASE) == FALSE) { home_screen('ERROR', '<font color="red"><strong>Could Not Select Database</strong></font>', '', ''); exit;
//*********************************************************************************** //*********************************************************************************** if (TREASURER_DISABLED == TRUE || TIMEKOIN_DISABLED == TRUE) { // This has been disabled exit; } //*********************************************************************************** //*********************************************************************************** mysql_connect(MYSQL_IP, MYSQL_USERNAME, MYSQL_PASSWORD); mysql_select_db(MYSQL_DATABASE); // Check for banned IP address if (ip_banned($_SERVER['REMOTE_ADDR']) == TRUE) { // Sorry, your IP address has been banned :( exit("Your IP Has Been Banned"); } log_ip("TR", 100); while (1) { set_time_limit(99); //*********************************************************************************** $loop_active = mysql_result(mysql_query("SELECT * FROM `main_loop_status` WHERE `field_name` = 'treasurer_heartbeat_active' LIMIT 1"), 0, "field_data"); // Check script status if ($loop_active === FALSE) { // Time to exit mysql_query("UPDATE `main_loop_status` SET `field_data` = '0' WHERE `main_loop_status`.`field_name` = 'balance_heartbeat_active' LIMIT 1"); exit; } else { if ($loop_active == 0) { // Set the working status of 1 mysql_query("UPDATE `main_loop_status` SET `field_data` = '1' WHERE `main_loop_status`.`field_name` = 'treasurer_heartbeat_active' LIMIT 1"); } else { if ($loop_active == 2) {
//*********************************************************************************** //*********************************************************************************** // Open persistent connection to database mysql_connect(MYSQL_IP, MYSQL_USERNAME, MYSQL_PASSWORD); mysql_select_db(MYSQL_DATABASE); // Check for banned IP address if (ip_banned($_SERVER['REMOTE_ADDR']) == TRUE) { // Sorry, your IP address has been banned :( exit; } //*********************************************************************************** //*********************************************************************************** // Answer public key balance request that match our hash code if ($_GET["action"] == "key_balance") { $hash_code = substr($_GET["hash"], 0, 256); $server_hash_code = mysql_result(mysql_query("SELECT * FROM `options` WHERE `field_name` = 'server_hash_code' LIMIT 1"), 0, "field_data"); if ($hash_code == $server_hash_code && $server_hash_code != "0") { // Grab balance for public key and return back $public_key = substr($_POST["public_key"], 0, 500); $public_key = filter_sql(base64_decode($public_key)); echo check_crypt_balance($public_key); } // Log inbound IP activity log_ip("AP"); exit; } //*********************************************************************************** //*********************************************************************************** // Log IP even when not using any functions log_ip("AP");
if (!isset($_POST['email']) || !isset($_POST['pass'])) { $err_msg = '你在搞什么?'; break; } $email = mysql_real_escape_string(strtolower($_POST['email'])); $pass = mysql_real_escape_string($_POST['pass']); //检查是密码正确性 $sql = "SELECT id FROM `user` WHERE `email` = '{$email}' AND `pass` = '{$pass}'"; $result = mysql_query($sql); if (mysql_num_rows($result) == 0) { $err_msg = '你输入的密码有误!'; break; } if ($row = mysql_fetch_array($result)) { //IP log_ip($row['id']); //密码正确保存cookie makecookie($row['id'], isset($_POST['remember'])); //做跳转 header('Location: ' . get_protocol_prefix() . "{$BASEURL}/pannel.php"); } else { $err_msg = '抱歉!发生了我们认为不可能发生的错误,请与客服联系!'; break; } } while (false); } else { if (checklogin(False) == True) { header('Location: ' . get_protocol_prefix() . "{$BASEURL}/pannel.php"); } } ?>
exit; } } $mysql_link = mysql_connect(MYSQL_IP, MYSQL_USERNAME, MYSQL_PASSWORD); mysql_select_db(MYSQL_DATABASE); $context = stream_context_create(array('http' => array('header' => 'Connection: close'))); // Force close socket after complete ini_set('user_agent', 'Timekoin Server (Main) v' . TIMEKOIN_VERSION); ini_set('default_socket_timeout', 3); // Timeout for request in seconds // Check for banned IP address if (ip_banned($_SERVER['REMOTE_ADDR']) == TRUE) { // Sorry, your IP address has been banned :( exit("Your IP Has Been Banned"); } log_ip("MA", 100); while (1) { // Set timeout set_time_limit(99); // Are we to remain active? $loop_active = mysql_result(mysql_query("SELECT * FROM `main_loop_status` WHERE `field_name` = 'main_heartbeat_active' LIMIT 1"), 0, "field_data"); if ($loop_active === FALSE) { // Database Error, try to re-establish a connection after 5 seconds mysql_close($mysql_link); sleep(5); $mysql_link = mysql_connect(MYSQL_IP, MYSQL_USERNAME, MYSQL_PASSWORD); mysql_select_db(MYSQL_DATABASE); // Keep track of errors in case this can't be recovered from $datbase_error = TRUE; $database_error_counter++; } else {
// Open connection to database mysql_connect(MYSQL_IP, MYSQL_USERNAME, MYSQL_PASSWORD); mysql_select_db(MYSQL_DATABASE); // Check for banned IP address if (ip_banned($_SERVER['REMOTE_ADDR']) == TRUE) { // Sorry, your IP address has been banned :( exit; } //*********************************************************************************** //*********************************************************************************** // Answer block hash poll if ($_GET["action"] == "block_hash" && $_GET["block_number"] >= 0) { $block_number = intval($_GET["block_number"]); echo mysql_result(mysql_query("SELECT hash FROM `transaction_foundation` WHERE `block` = {$block_number} LIMIT 1"), 0, 0); // Log inbound IP activity log_ip("FO"); exit; } //*********************************************************************************** while (1) { set_time_limit(99); //*********************************************************************************** $loop_active = mysql_result(mysql_query("SELECT * FROM `main_loop_status` WHERE `field_name` = 'foundation_heartbeat_active' LIMIT 1"), 0, "field_data"); // Check script status if ($loop_active === FALSE) { // Time to exit exit; } else { if ($loop_active == 0) { // Set the working status of 1 mysql_query("UPDATE `main_loop_status` SET `field_data` = '1' WHERE `main_loop_status`.`field_name` = 'foundation_heartbeat_active' LIMIT 1");
exit; } } $mysql_link = mysql_connect(MYSQL_IP, MYSQL_USERNAME, MYSQL_PASSWORD); mysql_select_db(MYSQL_DATABASE); $context = stream_context_create(array('http' => array('header' => 'Connection: close'))); // Force close socket after complete ini_set('user_agent', 'Timekoin Server (Main) v' . TIMEKOIN_VERSION); ini_set('default_socket_timeout', 3); // Timeout for request in seconds // Check for banned IP address if (ip_banned($_SERVER['REMOTE_ADDR']) == TRUE) { // Sorry, your IP address has been banned :( exit("Your IP Has Been Banned"); } log_ip("MA", 50); // Avoid flood loading system process while (1) { // Set timeout set_time_limit(300); // Are we to remain active? $loop_active = mysql_result(mysql_query("SELECT field_data FROM `main_loop_status` WHERE `field_name` = 'main_heartbeat_active' LIMIT 1"), 0, 0); if ($loop_active === FALSE) { // Database Error, try to re-establish a connection after 5 seconds mysql_close($mysql_link); sleep(5); $mysql_link = mysql_connect(MYSQL_IP, MYSQL_USERNAME, MYSQL_PASSWORD); mysql_select_db(MYSQL_DATABASE); // Keep track of errors in case this can't be recovered from $datbase_error = TRUE; $database_error_counter++;
} $username_hash = mysql_result(mysql_query("SELECT * FROM `options` WHERE `field_name` = 'username' LIMIT 1"), 0, "field_data"); $password_hash = mysql_result(mysql_query("SELECT * FROM `options` WHERE `field_name` = 'password' LIMIT 1"), 0, "field_data"); if (hash('sha256', $http_username) == $username_hash) { //Username match, check password if (hash('sha256', $http_password) == $password_hash) { // All match, set login variable and store username in cookie $_SESSION["login_username"] = $http_username; $_SESSION["valid_login"] = TRUE; header("Location: index.php?menu=home"); exit; } } // Log invalid attempts write_log("Invalid Login from IP: " . $_SERVER['REMOTE_ADDR'] . " trying Username:[" . filter_sql($http_username) . "] with Password:[" . filter_sql($http_password) . "]", "GU"); log_ip("GU", 50); } sleep(1); // One second delay to help prevent brute force attack login_screen("Login Failed"); exit; } if ($_SESSION["valid_login"] == TRUE) { //**************************************************************************** if (mysql_connect(MYSQL_IP, MYSQL_USERNAME, MYSQL_PASSWORD) == FALSE) { home_screen('ERROR', '<font color="red"><strong>Could Not Connect To Database</strong></font>', '', ''); exit; } if (mysql_select_db(MYSQL_DATABASE) == FALSE) { home_screen('ERROR', '<font color="red"><strong>Could Not Select Database</strong></font>', '', ''); exit;
echo "-----status=OK-----domain={$my_server_domain}-----subfolder={$my_server_subfolder}-----port_number={$my_server_port_number}-----"; } } else { // Peer not allowed to connect (invalid type) echo "-----status=FAILED-----domain"; } } // Full Server Check // Log inbound IP activity log_ip("PL", scale_trigger(200)); exit; } //*********************************************************************************** //*********************************************************************************** // External Flood Protection log_ip("PL", scale_trigger(4)); //*********************************************************************************** // First time run check $loop_active = mysql_result(mysql_query("SELECT field_data FROM `main_loop_status` WHERE `field_name` = 'peerlist_heartbeat_active' LIMIT 1"), 0, 0); $last_heartbeat = mysql_result(mysql_query("SELECT field_data FROM `main_loop_status` WHERE `field_name` = 'peerlist_last_heartbeat' LIMIT 1"), 0, 0); if ($loop_active === FALSE && $last_heartbeat == 1) { // Create record to begin loop mysql_query("INSERT INTO `main_loop_status` (`field_name` ,`field_data`)VALUES ('peerlist_heartbeat_active', '0')"); // Update timestamp for starting mysql_query("UPDATE `main_loop_status` SET `field_data` = '" . time() . "' WHERE `main_loop_status`.`field_name` = 'peerlist_last_heartbeat' LIMIT 1"); } else { // Record already exist, called while another process of this script // was already running. exit; } ini_set('user_agent', 'Timekoin Server (Peerlist) v' . TIMEKOIN_VERSION);
exit; } //*********************************************************************************** //*********************************************************************************** // Answer block hash poll if ($_GET["action"] == "block_hash" && $_GET["block_number"] >= 0) { $block_number = intval($_GET["block_number"]); echo mysql_result(mysql_query("SELECT hash FROM `transaction_foundation` WHERE `block` = {$block_number} LIMIT 1"), 0, 0); // Log inbound IP activity log_ip("FO", 1); exit; } //*********************************************************************************** //*********************************************************************************** // External Flood Protection log_ip("FO", scale_trigger(4)); //*********************************************************************************** // First time run check $loop_active = mysql_result(mysql_query("SELECT field_data FROM `main_loop_status` WHERE `field_name` = 'foundation_heartbeat_active' LIMIT 1"), 0, 0); $last_heartbeat = mysql_result(mysql_query("SELECT field_data FROM `main_loop_status` WHERE `field_name` = 'foundation_last_heartbeat' LIMIT 1"), 0, 0); if ($loop_active === FALSE && $last_heartbeat == 1) { // Create record to begin loop mysql_query("INSERT INTO `main_loop_status` (`field_name` ,`field_data`)VALUES ('foundation_heartbeat_active', '0')"); // Update timestamp for starting mysql_query("UPDATE `main_loop_status` SET `field_data` = '" . time() . "' WHERE `main_loop_status`.`field_name` = 'foundation_last_heartbeat' LIMIT 1"); } else { // Record already exist, called while another process of this script // was already running. exit; } ini_set('default_socket_timeout', 3);
echo "</div>"; echo "<div id=\"left_side\">"; $vettore = ls("*", "./db/", false); $lungh_array = count($vettore); $text = ""; $trovati = array(); $cercato = htmlspecialchars($_GET['cer']); $xss = false; //controlli sulla stringa cercata: if (strlen($cercato) <= 3) { log_ip("searched tiny=> {$cercato}"); $cercato = ""; } if (stristr($cercato, "<")) { $xss = true; log_ip("***XSStry=> {$cercato}"); $cercato = ""; } if (is_numeric($cercato)) { $cercato = ""; } if (!($cercato == "")) { for ($i = 0; $i < $lungh_array; ++$i) { //$i=1; $f = fopen("./db/" . $vettore[$i], "r"); $text .= fgets($f); fclose($f); //regexp per pulire il testo dai tag $text = preg_replace('/<(.+?)>/', " ", $text); if (stristr($text, $cercato)) { array_push($trovati, $i);
call_script("watchdog.php", 0); header("Location: index.php?menu=system&code=2"); exit; } else { header("Location: index.php?menu=system&code=89"); exit; } } $mysql_link = mysql_connect(MYSQL_IP, MYSQL_USERNAME, MYSQL_PASSWORD); mysql_select_db(MYSQL_DATABASE); // Check for banned IP address if (ip_banned($_SERVER['REMOTE_ADDR']) == TRUE) { // Sorry, your IP address has been banned :( exit("Your IP Has Been Banned"); } log_ip("WA", 25); // Avoid flood loading system process while (1) { // Set timeout set_time_limit(300); // Are we to remain active? $loop_active = mysql_result(mysql_query("SELECT field_data FROM `main_loop_status` WHERE `field_name` = 'watchdog_heartbeat_active' LIMIT 1"), 0, 0); if ($loop_active === FALSE) { // Database Error, try to re-establish a connection after 5 seconds mysql_close($mysql_link); sleep(5); $mysql_link = mysql_connect(MYSQL_IP, MYSQL_USERNAME, MYSQL_PASSWORD); mysql_select_db(MYSQL_DATABASE); // Keep track of errors in case this can't be recovered from $datbase_error = TRUE; $database_error_counter++;
} } else { write_log("More Than 100 Transactions Trying to Queue from IP: " . $_SERVER['REMOTE_ADDR'] . " for Public Key: " . base64_encode($transaction_public_key), "QC"); } } else { write_log("Invalid Transaction Queue Data Discarded from IP: " . $_SERVER['REMOTE_ADDR'] . " for Public Key: " . base64_encode($transaction_public_key), "QC"); } } else { // Respond that the transaction is already in the queue echo "DUP"; } } // End time allowed check //Direct Input Transaction get a 2x count boost //to help prevent direct Transaction spamming log_ip("QU", 2); exit; } //*********************************************************************************** while (1) { set_time_limit(99); //*********************************************************************************** $loop_active = mysql_result(mysql_query("SELECT * FROM `main_loop_status` WHERE `field_name` = 'queueclerk_heartbeat_active' LIMIT 1"), 0, "field_data"); // Check script status if ($loop_active === FALSE) { // Time to exit exit; } else { if ($loop_active == 0) { // Set the working status of 1 mysql_query("UPDATE `main_loop_status` SET `field_data` = '1' WHERE `main_loop_status`.`field_name` = 'queueclerk_heartbeat_active' LIMIT 1");
call_script("watchdog.php", 0); header("Location: index.php?menu=system&code=2"); exit; } else { header("Location: index.php?menu=system&code=89"); exit; } } $mysql_link = mysql_connect(MYSQL_IP, MYSQL_USERNAME, MYSQL_PASSWORD); mysql_select_db(MYSQL_DATABASE); // Check for banned IP address if (ip_banned($_SERVER['REMOTE_ADDR']) == TRUE) { // Sorry, your IP address has been banned :( exit("Your IP Has Been Banned"); } log_ip("WA", 50); while (1) { // Set timeout set_time_limit(300); // Are we to remain active? $loop_active = mysql_result(mysql_query("SELECT * FROM `main_loop_status` WHERE `field_name` = 'watchdog_heartbeat_active' LIMIT 1"), 0, "field_data"); if ($loop_active === FALSE) { // Database Error, try to re-establish a connection after 5 seconds mysql_close($mysql_link); sleep(5); $mysql_link = mysql_connect(MYSQL_IP, MYSQL_USERNAME, MYSQL_PASSWORD); mysql_select_db(MYSQL_DATABASE); // Keep track of errors in case this can't be recovered from $datbase_error = TRUE; $database_error_counter++; } else {
if (BALANCE_DISABLED == TRUE || TIMEKOIN_DISABLED == TRUE) { // This has been disabled exit; } //*********************************************************************************** //*********************************************************************************** mysql_connect(MYSQL_IP, MYSQL_USERNAME, MYSQL_PASSWORD); mysql_select_db(MYSQL_DATABASE); // Check for banned IP address if (ip_banned($_SERVER['REMOTE_ADDR']) == TRUE) { // Sorry, your IP address has been banned :( exit("Your IP Has Been Banned"); } //*********************************************************************************** // External Flood Protection log_ip("BA", scale_trigger(4)); //*********************************************************************************** // First time run check $loop_active = mysql_result(mysql_query("SELECT field_data FROM `main_loop_status` WHERE `field_name` = 'balance_heartbeat_active' LIMIT 1"), 0, 0); $last_heartbeat = mysql_result(mysql_query("SELECT field_data FROM `main_loop_status` WHERE `field_name` = 'balance_last_heartbeat' LIMIT 1"), 0, 0); if ($loop_active === FALSE && $last_heartbeat == 1) { // Create record to begin loop mysql_query("INSERT INTO `main_loop_status` (`field_name` ,`field_data`)VALUES ('balance_heartbeat_active', '0')"); // Update timestamp for starting mysql_query("UPDATE `main_loop_status` SET `field_data` = '" . time() . "' WHERE `main_loop_status`.`field_name` = 'balance_last_heartbeat' LIMIT 1"); } else { // Record already exist, called while another process of this script // was already running. exit; } while (1) {
//Direct Input Transaction get a count boost //to help prevent direct Transaction spamming if ($transaction_attribute == "T") { log_ip("QU", scale_trigger(100)); } else { if ($transaction_attribute == "G") { log_ip("QU", scale_trigger(3)); } else { log_ip("QU", scale_trigger(25)); } } exit; } //*********************************************************************************** // External Flood Protection log_ip("QU", scale_trigger(10)); //*********************************************************************************** // First time run check $loop_active = mysql_result(mysql_query("SELECT field_data FROM `main_loop_status` WHERE `field_name` = 'queueclerk_heartbeat_active' LIMIT 1"), 0, 0); $last_heartbeat = mysql_result(mysql_query("SELECT field_data FROM `main_loop_status` WHERE `field_name` = 'queueclerk_last_heartbeat' LIMIT 1"), 0, 0); $clone_id = $_GET["clone_id"]; if ($loop_active === FALSE && $last_heartbeat == 1) { // Create record to begin loop mysql_query("INSERT INTO `main_loop_status` (`field_name` ,`field_data`)VALUES ('queueclerk_heartbeat_active', '0')"); // Update timestamp for starting mysql_query("UPDATE `main_loop_status` SET `field_data` = '" . time() . "' WHERE `main_loop_status`.`field_name` = 'queueclerk_last_heartbeat' LIMIT 1"); } else { if (empty($clone_id) == TRUE) { // Record already exist, called while another process of this script // was already running. exit;
//*********************************************************************************** //*********************************************************************************** if (GENERATION_DISABLED == TRUE || TIMEKOIN_DISABLED == TRUE) { // This has been disabled exit; } //*********************************************************************************** //*********************************************************************************** mysql_connect(MYSQL_IP, MYSQL_USERNAME, MYSQL_PASSWORD); mysql_select_db(MYSQL_DATABASE); // Check for banned IP address if (ip_banned($_SERVER['REMOTE_ADDR']) == TRUE) { // Sorry, your IP address has been banned :( exit("Your IP Has Been Banned"); } log_ip("GE", 100); // First time run check $loop_active = mysql_result(mysql_query("SELECT field_data FROM `main_loop_status` WHERE `field_name` = 'generation_heartbeat_active' LIMIT 1"), 0, 0); $last_heartbeat = mysql_result(mysql_query("SELECT field_data FROM `main_loop_status` WHERE `field_name` = 'generation_last_heartbeat' LIMIT 1"), 0, 0); if ($loop_active === FALSE && $last_heartbeat == 1) { // Create record to begin loop mysql_query("INSERT INTO `main_loop_status` (`field_name` ,`field_data`)VALUES ('generation_heartbeat_active', '0')"); // Update timestamp for starting mysql_query("UPDATE `main_loop_status` SET `field_data` = '" . time() . "' WHERE `main_loop_status`.`field_name` = 'generation_last_heartbeat' LIMIT 1"); } else { // Record already exist, called while another process of this script // was already running. exit; } while (1) { set_time_limit(300);
//*********************************************************************************** // Answer generation peer list poll if ($_GET["action"] == "gen_peer_list") { $sql = "SELECT * FROM `generating_peer_list` ORDER BY RAND() LIMIT 50"; $sql_result = mysql_query($sql); $sql_num_results = mysql_num_rows($sql_result); $queue_number = 1; if ($sql_num_results > 0) { for ($i = 0; $i < $sql_num_results; $i++) { $sql_row = mysql_fetch_array($sql_result); echo "-----public_key{$queue_number}=", base64_encode($sql_row["public_key"]), "-----join{$queue_number}=", $sql_row["join_peer_list"], "-----last{$queue_number}=", $sql_row["last_generation"], "-----ip{$queue_number}=", $sql_row["IP_Address"], "-----END{$queue_number}"; $queue_number++; } } // Log inbound IP activity log_ip("GP"); exit; } //*********************************************************************************** while (1) { set_time_limit(99); //*********************************************************************************** $loop_active = mysql_result(mysql_query("SELECT * FROM `main_loop_status` WHERE `field_name` = 'genpeer_heartbeat_active' LIMIT 1"), 0, "field_data"); // Check script status if ($loop_active === FALSE) { // Time to exit exit; } else { if ($loop_active == 0) { // Set the working status of 1 mysql_query("UPDATE `main_loop_status` SET `field_data` = '1' WHERE `main_loop_status`.`field_name` = 'genpeer_heartbeat_active' LIMIT 1");
$transaction_info; for ($i = 0; $i < $sql_num_results; $i++) { $sql_row = mysql_fetch_row($sql_result); $public_key_from = $sql_row[0]; $public_key_to = $sql_row[1]; $crypt3 = $sql_row[2]; $attribute = $sql_row[3]; if ($attribute == "G" && $public_key_from == $public_key_to) { // Decrypt transaction information if ($GLOBALS['decrypt_mode'] == 2) { $rsa->loadKey($public_key_from); $transaction_info = $rsa->decrypt(base64_decode($crypt3)); } else { $transaction_info = tk_decrypt($public_key_from, base64_decode($crypt3), TRUE); } $transaction_amount_sent = find_string("AMOUNT=", "---TIME", $transaction_info); $crypto_balance += $transaction_amount_sent; } } echo $crypto_balance; } // End Permission Check // Log inbound IP activity log_ip("AP", scale_trigger(100)); exit; } //*********************************************************************************** //*********************************************************************************** // Log IP even when not using any functions, just in case log_ip("AP", scale_trigger(10));
//Direct Input Transaction get a count boost //to help prevent direct Transaction spamming if ($transaction_attribute == "T") { log_ip("QU", scale_trigger(100)); } else { if ($transaction_attribute == "G") { log_ip("QU", scale_trigger(3)); } else { log_ip("QU", scale_trigger(25)); } } exit; } //*********************************************************************************** // External Flood Protection log_ip("QU", scale_trigger(4)); //*********************************************************************************** // First time run check $loop_active = mysql_result(mysql_query("SELECT field_data FROM `main_loop_status` WHERE `field_name` = 'queueclerk_heartbeat_active' LIMIT 1"), 0, 0); $last_heartbeat = mysql_result(mysql_query("SELECT field_data FROM `main_loop_status` WHERE `field_name` = 'queueclerk_last_heartbeat' LIMIT 1"), 0, 0); if ($loop_active === FALSE && $last_heartbeat == 1) { // Create record to begin loop mysql_query("INSERT INTO `main_loop_status` (`field_name` ,`field_data`)VALUES ('queueclerk_heartbeat_active', '0')"); // Update timestamp for starting mysql_query("UPDATE `main_loop_status` SET `field_data` = '" . time() . "' WHERE `main_loop_status`.`field_name` = 'queueclerk_last_heartbeat' LIMIT 1"); } else { // Record already exist, called while another process of this script // was already running. exit; } ini_set('user_agent', 'Timekoin Server (Queueclerk) v' . TIMEKOIN_VERSION);
call_script("watchdog.php", 0); header("Location: index.php?menu=system&code=2"); exit; } else { header("Location: index.php?menu=system&code=89"); exit; } } $mysql_link = mysql_connect(MYSQL_IP, MYSQL_USERNAME, MYSQL_PASSWORD); mysql_select_db(MYSQL_DATABASE); // Check for banned IP address if (ip_banned($_SERVER['REMOTE_ADDR']) == TRUE) { // Sorry, your IP address has been banned :( exit("Your IP Has Been Banned"); } log_ip("WA", 100); while (1) { // Are we to remain active? $loop_active = mysql_result(mysql_query("SELECT * FROM `main_loop_status` WHERE `field_name` = 'watchdog_heartbeat_active' LIMIT 1"), 0, "field_data"); if ($loop_active === FALSE) { // Database Error, try to re-establish a connection after 5 seconds mysql_close($mysql_link); sleep(5); $mysql_link = mysql_connect(MYSQL_IP, MYSQL_USERNAME, MYSQL_PASSWORD); mysql_select_db(MYSQL_DATABASE); // Keep track of errors in case this can't be recovered from $datbase_error = TRUE; $database_error_counter++; } else { $datbase_error = 0; $database_error_counter = 0;
//*********************************************************************************** //*********************************************************************************** if (BALANCE_DISABLED == TRUE || TIMEKOIN_DISABLED == TRUE) { // This has been disabled exit; } //*********************************************************************************** //*********************************************************************************** mysql_connect(MYSQL_IP, MYSQL_USERNAME, MYSQL_PASSWORD); mysql_select_db(MYSQL_DATABASE); // Check for banned IP address if (ip_banned($_SERVER['REMOTE_ADDR']) == TRUE) { // Sorry, your IP address has been banned :( exit("Your IP Has Been Banned"); } log_ip("BA", 100); while (1) { set_time_limit(300); //*********************************************************************************** $loop_active = mysql_result(mysql_query("SELECT * FROM `main_loop_status` WHERE `field_name` = 'balance_heartbeat_active' LIMIT 1"), 0, "field_data"); // Check script status if ($loop_active === FALSE) { // Time to exit exit; } else { if ($loop_active == 0) { // Set the working status of 1 mysql_query("UPDATE `main_loop_status` SET `field_data` = '1' WHERE `main_loop_status`.`field_name` = 'balance_heartbeat_active' LIMIT 1"); } else { if ($loop_active == 2) { // Set the working status of 1
} header("Location: index.php?menu=system&code=2"); exit; } else { header("Location: index.php?menu=system&code=89"); exit; } } $mysql_link = mysql_connect(MYSQL_IP, MYSQL_USERNAME, MYSQL_PASSWORD); mysql_select_db(MYSQL_DATABASE); // Check for banned IP address if (ip_banned($_SERVER['REMOTE_ADDR']) == TRUE) { // Sorry, your IP address has been banned :( exit("Your IP Has Been Banned"); } log_ip("WA", scale_trigger(5)); // Avoid flood loading system process while (1) { // Set timeout set_time_limit(300); // Are we to remain active? $loop_active = mysql_result(mysql_query("SELECT field_data FROM `main_loop_status` WHERE `field_name` = 'watchdog_heartbeat_active' LIMIT 1"), 0, 0); if ($loop_active === FALSE) { // Database Error, try to re-establish a connection after 5 seconds mysql_close($mysql_link); sleep(5); $mysql_link = mysql_connect(MYSQL_IP, MYSQL_USERNAME, MYSQL_PASSWORD); mysql_select_db(MYSQL_DATABASE); // Keep track of errors in case this can't be recovered from $datbase_error = TRUE; $database_error_counter++;
$time2 = transaction_cycle(0 - $current_generation_block + 1 + $block_number); $sql = "SELECT * FROM `transaction_history` WHERE `timestamp` >= {$time1} AND `timestamp` < {$time2}"; $sql_result = mysql_query($sql); $sql_num_results = mysql_num_rows($sql_result); $c = 1; if ($sql_num_results > 0) { for ($i = 0; $i < $sql_num_results; $i++) { $sql_row = mysql_fetch_array($sql_result); echo "-----timestamp{$c}=", $sql_row["timestamp"], "-----public_key_from{$c}=", base64_encode($sql_row["public_key_from"]), "-----public_key_to{$c}=", base64_encode($sql_row["public_key_to"]); echo "-----crypt1data{$c}=", $sql_row["crypt_data1"], "-----crypt2data{$c}=", $sql_row["crypt_data2"], "-----crypt3data{$c}=", $sql_row["crypt_data3"], "-----hash{$c}=", $sql_row["hash"]; echo "-----attribute{$c}=", $sql_row["attribute"], "-----end{$c}"; $c++; } } // Log inbound IP activity log_ip("TC"); exit; } //*********************************************************************************** while (1) { set_time_limit(120); //*********************************************************************************** $loop_active = mysql_result(mysql_query("SELECT * FROM `main_loop_status` WHERE `field_name` = 'transclerk_heartbeat_active' LIMIT 1"), 0, "field_data"); // Check script status if ($loop_active === FALSE) { // Time to exit exit; } else { if ($loop_active == 0) { // Set the working status of 1 mysql_query("UPDATE `main_loop_status` SET `field_data` = '1' WHERE `main_loop_status`.`field_name` = 'transclerk_heartbeat_active' LIMIT 1");
echo "OK"; write_log("Accepted Inbound Transaction from IP: " . $_SERVER['REMOTE_ADDR'], "QC"); } } else { write_log("More Than 100 Transactions Trying to Queue from IP: " . $_SERVER['REMOTE_ADDR'] . " for Public Key: " . base64_encode($transaction_public_key), "QC"); } } else { write_log("Invalid Transaction Queue Data Discarded from IP: " . $_SERVER['REMOTE_ADDR'] . " for Public Key: " . base64_encode($transaction_public_key), "QC"); } } // End Duplicate & Timestamp check } // End time allowed check //Direct Input Transaction get a 10x count boost //to help prevent direct Transaction spamming log_ip("QU", 10); exit; } //*********************************************************************************** //*********************************************************************************** $loop_active = mysql_result(mysql_query("SELECT * FROM `main_loop_status` WHERE `field_name` = 'queueclerk_heartbeat_active' LIMIT 1"), 0, "field_data"); // Check if loop is already running if ($loop_active == 0) { // Set the working status of 1 mysql_query("UPDATE `main_loop_status` SET `field_data` = '1' WHERE `main_loop_status`.`field_name` = 'queueclerk_heartbeat_active' LIMIT 1"); } else { if ($loop_active == 1) { // Allow another instance to start // Set the working status of 2 mysql_query("UPDATE `main_loop_status` SET `field_data` = '2' WHERE `main_loop_status`.`field_name` = 'queueclerk_heartbeat_active' LIMIT 1"); } else {
if (TREASURER_DISABLED == TRUE || TIMEKOIN_DISABLED == TRUE) { // This has been disabled exit; } //*********************************************************************************** //*********************************************************************************** mysql_connect(MYSQL_IP, MYSQL_USERNAME, MYSQL_PASSWORD); mysql_select_db(MYSQL_DATABASE); // Check for banned IP address if (ip_banned($_SERVER['REMOTE_ADDR']) == TRUE) { // Sorry, your IP address has been banned :( exit("Your IP Has Been Banned"); } //*********************************************************************************** // External Flood Protection log_ip("TR", scale_trigger(4)); //*********************************************************************************** // First time run check $loop_active = mysql_result(mysql_query("SELECT field_data FROM `main_loop_status` WHERE `field_name` = 'treasurer_heartbeat_active' LIMIT 1"), 0, 0); $last_heartbeat = mysql_result(mysql_query("SELECT field_data FROM `main_loop_status` WHERE `field_name` = 'treasurer_last_heartbeat' LIMIT 1"), 0, 0); if ($loop_active === FALSE && $last_heartbeat == 1) { // Create record to begin loop mysql_query("INSERT INTO `main_loop_status` (`field_name` ,`field_data`)VALUES ('treasurer_heartbeat_active', '0')"); // Update timestamp for starting mysql_query("UPDATE `main_loop_status` SET `field_data` = '" . time() . "' WHERE `main_loop_status`.`field_name` = 'treasurer_last_heartbeat' LIMIT 1"); } else { // Record already exist, called while another process of this script // was already running. exit; } ini_set('user_agent', 'Timekoin Server (Treasurer) v' . TIMEKOIN_VERSION);
if ($fresh_system === FALSE) { // Stop all other script activity until the user actually starts the system. // This is useful when recoving from an unknown error or crash. activate(TIMEKOINSYSTEM, 0); } // All match, set login variable and store username in cookie $_SESSION["login_username"] = $http_username; $_SESSION["valid_login"] = TRUE; header("Location: index.php?menu=home"); exit; } } // Log invalid attempts write_log("Invalid Login from IP: " . $_SERVER['REMOTE_ADDR'] . " trying Username:[" . filter_sql($http_username) . "] with Password:[" . filter_sql($http_password) . "]", "GU"); } log_ip("GU", 100); // Avoid flood-brute password guessing sleep(1); // One second delay to help prevent brute force attack login_screen("Login Failed"); exit; } if ($_SESSION["valid_login"] == TRUE) { //**************************************************************************** if (mysql_connect(MYSQL_IP, MYSQL_USERNAME, MYSQL_PASSWORD) == FALSE) { home_screen('ERROR', '<font color="red"><strong>Could Not Connect To Database</strong></font>', '', ''); exit; } if (mysql_select_db(MYSQL_DATABASE) == FALSE) { home_screen('ERROR', '<font color="red"><strong>Could Not Select Database</strong></font>', '', ''); exit;
$sql = "INSERT INTO `active_peer_list` (`IP_Address` ,`domain` ,`subfolder` ,`port_number` ,`last_heartbeat` ,`join_peer_list` ,`failed_sent_heartbeat`)\n\tVALUES ('{$ip_address}', '{$domain}', '{$subfolder}', '{$port_number}', '" . time() . "', '" . time() . "', '0');"; if (mysql_query($sql) == TRUE) { // Exchange was saved, now output our peer information echo "-----status=OK-----domain={$my_server_domain}-----subfolder={$my_server_subfolder}-----port_number={$my_server_port_number}-----"; write_log("Peer Joined My Server {$ip_address}:{$domain}:{$port_number}/{$subfolder}", "PL"); } else { // Could not save peer, report error problem echo "-----status=FAILED-----domain"; } } else { // Already in our list, might be a re-connect, so give the other peer the OK echo "-----status=OK-----domain={$my_server_domain}-----subfolder={$my_server_subfolder}-----port_number={$my_server_port_number}-----"; } } // Log inbound IP activity log_ip("PL"); exit; } //*********************************************************************************** //*********************************************************************************** $loop_active = mysql_result(mysql_query("SELECT * FROM `main_loop_status` WHERE `field_name` = 'peerlist_heartbeat_active' LIMIT 1"), 0, "field_data"); // Check if loop is already running if ($loop_active == 0) { // Set the working status of 1 $sql = "UPDATE `main_loop_status` SET `field_data` = '1' WHERE `main_loop_status`.`field_name` = 'peerlist_heartbeat_active' LIMIT 1"; mysql_query($sql); } else { // Loop called while still working exit; } //***********************************************************************************
} } else { // Respond that the transaction is already in the queue echo "DUP"; } } // End time allowed check //Direct Input Transaction get a count boost //to help prevent direct Transaction spamming if ($transaction_attribute == "T") { log_ip("QU", 2); } else { if ($transaction_attribute == "G") { log_ip("QU", 50); } else { log_ip("QU", 1); } } exit; } //*********************************************************************************** // First time run check $loop_active = mysql_result(mysql_query("SELECT field_data FROM `main_loop_status` WHERE `field_name` = 'queueclerk_heartbeat_active' LIMIT 1"), 0, 0); $last_heartbeat = mysql_result(mysql_query("SELECT field_data FROM `main_loop_status` WHERE `field_name` = 'queueclerk_last_heartbeat' LIMIT 1"), 0, 0); if ($loop_active === FALSE && $last_heartbeat == 1) { // Create record to begin loop mysql_query("INSERT INTO `main_loop_status` (`field_name` ,`field_data`)VALUES ('queueclerk_heartbeat_active', '0')"); // Update timestamp for starting mysql_query("UPDATE `main_loop_status` SET `field_data` = '" . time() . "' WHERE `main_loop_status`.`field_name` = 'queueclerk_last_heartbeat' LIMIT 1"); } else { // Record already exist, called while another process of this script