*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 3.0.0
- * @copyright Copyright (c) 2009, 2010 Cracker Tracker Team
+ * @copyright Copyright (c) 2009 - 2011 Cracker Tracker Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
// Function to aquire a database link
function aquireCrackerTrackerDatabaseLink () {
// Is the link up?
- if (!isCrackerTrackerDatabaseLinkUp()) {
+ if ((!isCrackerTrackerDatabaseLinkUp()) && (!empty($GLOBALS['ctracker_host'])) && (!empty($GLOBALS['ctracker_dbname'])) && (!empty($GLOBALS['ctracker_user']))) {
// Then connect to the database
$GLOBALS['ctracker_link'] = mysql_connect($GLOBALS['ctracker_host'], $GLOBALS['ctracker_user'], $GLOBALS['ctracker_password']) or crackerTrackerDatabaseError(__FUNCTION__, __LINE__);
// Load the config
crackerTrackerLoadConfig();
}
- } // END - if
+ } else {
+ // Init fake config
+ crackerTrackerInitFakeConfig();
+ }
+}
+
+// Inits a fake configurtation
+function crackerTrackerInitFakeConfig () {
+ // Set the array
+ $GLOBALS['ctracker_config'] = array(
+ 'ctracker_alert_user' => 'Y',
+ );
}
// Checks if the link is up
// Inserts given array, if IP/check_worm combination was not found
function crackerTrackerInsertArray ($table, $rowData) {
+ // Is there a link up?
+ if (!isCrackerTrackerDatabaseLinkUp()) {
+ // Abort silently here
+ return false;
+ } // END - if
+
// Is it found?
if (!isCrackerTrackerEntryFound($rowData)) {
// Prepare SQL
$SQL = 'SELECT `id` FROM `ctracker_data` WHERE `remote_addr`="' . crackerTrackerEscapeString($rowData['remote_addr']) . '" AND `check_worm` = "' . crackerTrackerEscapeString($rowData['check_worm']) . '" AND `server_name`="' . crackerTrackerEscapeString($rowData['server_name']) . '" LIMIT 1';
// Run the SQL and check if we have one line
- return (mysql_num_rows(runCrackerTrackerSql($SQL, __FUNCTION__, __LINE__)) == 1);
+ return ((isCrackerTrackerDatabaseLinkUp()) && (mysql_num_rows(runCrackerTrackerSql($SQL, __FUNCTION__, __LINE__)) == 1));
}
// Escapes the string
// Updates the database scheme automatically
function crackerTrackerUpdateDatabaseScheme () {
+ // Is a link there?
+ if (!isCrackerTrackerDatabaseLinkUp()) {
+ // Abort here silently
+ return;
+ } // END - if
+
// Is the main config table there?
if (!isCrackerTrackerTableCreated('ctracker_config')) {
// Then do it for us
// Did the current IP already generated blocked attempts?
function isCrackerTrackerIpSuspicious () {
+ // Skip this silently if we have not config
+ if (!isCrackerTrackerDatabaseLinkUp()) {
+ // Skip this step silently, all is not suspicious
+ return false;
+ } // END - if
+
// We only need the very last attempt to get!
$result = runCrackerTrackerSql("SELECT * FROM `ctracker_data` WHERE `remote_addr`='" . determineCrackerTrackerRealRemoteAddress() . "' ORDER BY `last_attempt` DESC LIMIT 1", __FUNCTION__, __LINE__);