} // End empty poll check } // End if/then record count check } // Random chance check } // End else //*********************************************************************************** } // End if/then check for processing for more than 3 records - live database //*********************************************************************************** } // End if/then time check //*********************************************************************************** //*********************************************************************************** // Script finished, set status to 0 mysql_query("UPDATE `main_loop_status` SET `field_data` = '0' WHERE `main_loop_status`.`field_name` = 'transclerk_heartbeat_active' LIMIT 1"); // Record when this script finished mysql_query("UPDATE `main_loop_status` SET `field_data` = '" . time() . "' WHERE `main_loop_status`.`field_name` = 'transclerk_last_heartbeat' LIMIT 1"); //********** //Launch another instance right away when getting //transaction history in sync with the network if ($transaction_multi == TRUE) { $main_loop_status = mysql_result(mysql_query("SELECT * FROM `main_loop_status` WHERE `field_name` = 'main_heartbeat_active' LIMIT 1"), 0, "field_data"); if ($main_loop_status == 1 || $main_loop_status == 2) { call_script("transclerk.php"); } exit; } //***********************************************************************************
activate(TIMEKOINSYSTEM, 1); // In case this was disabled from a emergency stop call in the server GUI } } // Check watchdog script to make sure it is still running $script_loop_active = mysql_result(mysql_query("SELECT * FROM `main_loop_status` WHERE `field_name` = 'watchdog_heartbeat_active' LIMIT 1"), 0, "field_data"); $script_last_heartbeat = mysql_result(mysql_query("SELECT * FROM `main_loop_status` WHERE `field_name` = 'watchdog_last_heartbeat' LIMIT 1"), 0, "field_data"); if ($script_loop_active > 0) { // Watchdog should still be active if (time() - $script_last_heartbeat > 100) { // Watchdog stop was unexpected write_log("Watchdog has Failed, going to try an Ambient Peer Restart", "PL"); mysql_query("UPDATE `main_loop_status` SET `field_data` = '" . time() . "' WHERE `main_loop_status`.`field_name` = 'watchdog_last_heartbeat' LIMIT 1"); // Set loop at active now mysql_query("UPDATE `main_loop_status` SET `field_data` = '1' WHERE `main_loop_status`.`field_name` = 'watchdog_heartbeat_active' LIMIT 1"); call_script("watchdog.php", 0); } } } // End Ambient Peer Restart Active Check } // End Randomize Check // Log inbound IP activity log_ip("PL"); exit; } //*********************************************************************************** //*********************************************************************************** // Answer poll challenge if ($_GET["action"] == "polltime") { echo time();
call_script("peerlist.php"); } $script_loop_active = mysql_result(mysql_query("SELECT * FROM `main_loop_status` WHERE `field_name` = 'queueclerk_heartbeat_active' LIMIT 1"), 0, "field_data"); // Check if script is already running if ($script_loop_active == 0) { call_script("queueclerk.php"); } $script_loop_active = mysql_result(mysql_query("SELECT * FROM `main_loop_status` WHERE `field_name` = 'balance_heartbeat_active' LIMIT 1"), 0, "field_data"); // Check if script is already running if ($script_loop_active == 0) { call_script("balance.php", 0); } $script_loop_active = mysql_result(mysql_query("SELECT * FROM `main_loop_status` WHERE `field_name` = 'genpeer_heartbeat_active' LIMIT 1"), 0, "field_data"); // Check if script is already running if ($script_loop_active == 0) { call_script("genpeer.php"); } if (rand(1, 3) == 2) { // Check watchdog script to make sure it is still running $script_loop_active = mysql_result(mysql_query("SELECT * FROM `main_loop_status` WHERE `field_name` = 'watchdog_heartbeat_active' LIMIT 1"), 0, "field_data"); $watchdog_last_heartbeat = mysql_result(mysql_query("SELECT * FROM `main_loop_status` WHERE `field_name` = 'watchdog_last_heartbeat' LIMIT 1"), 0, "field_data"); if ($script_loop_active > 0) { // Watchdog should still be active if (time() - $watchdog_last_heartbeat > 60) { // Watchdog stop was unexpected write_log("Watchdog is Stalled...", "MA"); } } } //***************************************************************************************************** //*****************************************************************************************************
if ($watchdog_heartbeat_active === FALSE) { mysql_query("INSERT INTO `main_loop_status` (`field_name` ,`field_data`)VALUES ('watchdog_heartbeat_active', '0')"); } mysql_query("UPDATE `main_loop_status` SET `field_data` = '" . time() . "' WHERE `main_loop_status`.`field_name` = 'watchdog_last_heartbeat' LIMIT 1"); // Set loop at active now mysql_query("UPDATE `main_loop_status` SET `field_data` = '1' WHERE `main_loop_status`.`field_name` = 'watchdog_heartbeat_active' LIMIT 1"); // CLI Mode selection $cli_mode = intval(mysql_result(mysql_query("SELECT field_data FROM `options` WHERE `field_name` = 'cli_mode' LIMIT 1"), 0, 0)); // Start main system script if ($cli_mode == TRUE) { call_script("watchdog.php", 0); } else { session_name("tkwatchcli"); session_start(); ini_set('default_socket_timeout', 1); call_script("watchdog.php", NULL, NULL, TRUE); } 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"); }
if (empty($find_php[0]) == TRUE) { // Could not find it anywhere :( } else { // Found it! Save location and start Timekoin mysql_query("UPDATE `options` SET `field_data` = '" . addslashes($find_php[0]) . "' WHERE `options`.`field_name` = 'php_location' LIMIT 1"); } } // Check if php-win.exe exist check } // Windows OS Check } // End Database Check for custom PHP location mysql_query("UPDATE `main_loop_status` SET `field_data` = '" . time() . "' WHERE `main_loop_status`.`field_name` = 'main_last_heartbeat' LIMIT 1"); // Set loop at active now mysql_query("UPDATE `main_loop_status` SET `field_data` = '1' WHERE `main_loop_status`.`field_name` = 'main_heartbeat_active' LIMIT 1"); call_script("main.php"); // Start main.php process activate(TIMEKOINSYSTEM, 1); // In case this was disabled from a stop call in the server GUI // Use uPNP to map inbound ports for Windows systems if (getenv("OS") == "Windows_NT" && file_exists("utils\\upnpc.exe") == TRUE) { $server_port_number = mysql_result(mysql_query("SELECT * FROM `options` WHERE `field_name` = 'server_port_number' LIMIT 1"), 0, "field_data"); $server_IP = gethostbyname(trim(`hostname`)); pclose(popen("start /B utils\\upnpc.exe -e Timekoin -a {$server_IP} {$server_port_number} {$server_port_number} TCP", "r")); } } // End active main.php process check } // End DB check } // End Autostart check
$_SESSION["login_username"] = $http_username; $_SESSION["valid_login"] = TRUE; initialization_database(); // Do any required data upgrades // Start any plugins $sql = "SELECT * FROM `options` WHERE `field_name` LIKE 'installed_plugins%' ORDER BY `options`.`field_name` ASC"; $sql_result = mysql_query($sql); $sql_num_results = mysql_num_rows($sql_result); for ($i = 0; $i < $sql_num_results; $i++) { $sql_row = mysql_fetch_array($sql_result); $plugin_file = find_string("---file=", "---enable", $sql_row["field_data"]); $plugin_enable = intval(find_string("---enable=", "---show", $sql_row["field_data"])); $plugin_service = find_string("---service=", "---end", $sql_row["field_data"]); if ($plugin_enable == TRUE && empty($plugin_service) == FALSE) { // Start Plugin Service call_script($plugin_file, 0, TRUE); // Log Service Start write_log("Started Plugin Service: {$plugin_service}", "GU"); } } // Finish Starting Plugin Services header("Location: index.php"); 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"); } sleep(1); // One second delay to help prevent brute force attack login_screen("Login Failed");
$script_loop_active = mysql_result(mysql_query("SELECT field_data FROM `main_loop_status` WHERE `field_name` = 'balance_heartbeat_active' LIMIT 1"), 0, 0); // Check if script is already running if ($script_loop_active == 0) { if ($cli_mode == TRUE) { call_script("balance.php", 0); } else { call_script("balance.php", NULL, NULL, TRUE); } } $script_loop_active = mysql_result(mysql_query("SELECT field_data FROM `main_loop_status` WHERE `field_name` = 'genpeer_heartbeat_active' LIMIT 1"), 0, 0); // Check if script is already running if ($script_loop_active == 0) { if ($cli_mode == TRUE) { call_script("genpeer.php"); } else { call_script("genpeer.php", NULL, NULL, TRUE); } } if (rand(1, 4) == 3) { // Check watchdog script to make sure it is still running $script_loop_active = mysql_result(mysql_query("SELECT field_data FROM `main_loop_status` WHERE `field_name` = 'watchdog_heartbeat_active' LIMIT 1"), 0, 0); $watchdog_last_heartbeat = mysql_result(mysql_query("SELECT field_data FROM `main_loop_status` WHERE `field_name` = 'watchdog_last_heartbeat' LIMIT 1"), 0, 0); if ($script_loop_active > 0) { // Watchdog should still be active if (time() - $watchdog_last_heartbeat > 90) { // Watchdog stop was unexpected write_log("Watchdog is Stalled...", "MA"); } } } //*****************************************************************************************************