// 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__);
// 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
// Send the email out only in non-debug mode
if (isCrackerTrackerDebug()) {
// Output message
- print 'Recipient='.$recipient.'<br />Subject='.$subject.'<br />Text=<pre>' . $mail . '</pre>';
+ print 'Recipient=' . $recipient . '<br />Subject=' . $subject . '<br />Text=<pre>' . $mail . '</pre>';
// All fine
return true;
// Send it the deprecated way with constant
return mail(constant('__CTRACKER_EMAIL'), 'CTracker: Attack detected!', $mail, $GLOBALS['ctracker_header']);
}
- } // END - if
+ } elseif (isCrackerTrackerDebug()) {
+ // Output message
+ print 'Recipient=' . $recipient . '<br />Subject=' . $subject . '<br />Text=<pre>' . $mail . '</pre>';
+
+ // All fine
+ return true;
+ }
}
// Sends a detected POST attack mail