Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

always set valid dates, to avoid errors when strict mode is enabled on mysql #96

Merged
merged 2 commits into from
Aug 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions all-in-one-wp-security/classes/wp-security-installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ static function create_db_tables()
id bigint(20) NOT NULL AUTO_INCREMENT,
user_id bigint(20) NOT NULL,
user_login VARCHAR(150) NOT NULL,
lockdown_date datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
release_date datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
lockdown_date datetime NOT NULL DEFAULT '1000-10-10 10:00:00',
release_date datetime NOT NULL DEFAULT '1000-10-10 10:00:00',
failed_login_ip varchar(100) NOT NULL DEFAULT '',
lock_reason varchar(128) NOT NULL DEFAULT '',
unlock_key varchar(128) NOT NULL DEFAULT '',
Expand All @@ -82,7 +82,7 @@ static function create_db_tables()
id bigint(20) NOT NULL AUTO_INCREMENT,
user_id bigint(20) NOT NULL,
user_login VARCHAR(150) NOT NULL,
failed_login_date datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
failed_login_date datetime NOT NULL DEFAULT '1000-10-00 10:00:00',
login_attempt_ip varchar(100) NOT NULL DEFAULT '',
PRIMARY KEY (id)
)" . $charset_collate . ";";
Expand All @@ -92,8 +92,8 @@ static function create_db_tables()
id bigint(20) NOT NULL AUTO_INCREMENT,
user_id bigint(20) NOT NULL,
user_login VARCHAR(150) NOT NULL,
login_date datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
logout_date datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
login_date datetime NOT NULL DEFAULT '1000-10-00 10:00:00',
logout_date datetime NOT NULL DEFAULT '1000-10-00 10:00:00',
login_ip varchar(100) NOT NULL DEFAULT '',
login_country varchar(150) NOT NULL DEFAULT '',
browser_type varchar(150) NOT NULL DEFAULT '',
Expand All @@ -103,7 +103,7 @@ static function create_db_tables()

$gm_tbl_sql = "CREATE TABLE " . $aiowps_global_meta_tbl_name . " (
meta_id bigint(20) NOT NULL auto_increment,
date_time datetime NOT NULL default '0000-00-00 00:00:00',
date_time datetime NOT NULL default '1000-10-10 10:00:00',
meta_key1 varchar(255) NOT NULL,
meta_key2 varchar(255) NOT NULL,
meta_key3 varchar(255) NOT NULL,
Expand All @@ -123,7 +123,7 @@ static function create_db_tables()
event_type VARCHAR(150) NOT NULL DEFAULT '',
username VARCHAR(150),
user_id bigint(20),
event_date datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
event_date datetime NOT NULL DEFAULT '1000-10-10 10:00:00',
ip_or_host varchar(100),
referer_info varchar(255),
url varchar(255),
Expand All @@ -138,7 +138,7 @@ static function create_db_tables()
blocked_ip varchar(100) NOT NULL DEFAULT '',
block_reason varchar(128) NOT NULL DEFAULT '',
country_origin varchar(50) NOT NULL DEFAULT '',
blocked_date datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
blocked_date datetime NOT NULL DEFAULT '1000-10-10 10:00:00',
unblock tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (id)
)" . $charset_collate . ";";
Expand Down
5 changes: 3 additions & 2 deletions all-in-one-wp-security/classes/wp-security-user-login.php
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ function wp_logout_action_handler()
$data = array('logout_date' => $logout_date_time);
$where = array('user_id' => $user_id,
'login_ip' => $ip_addr,
'logout_date' => '0000-00-00 00:00:00');
'logout_date' => '1000-10-10 10:00:00');
$result = $wpdb->update($login_activity_table, $data, $where);
if ($result === FALSE)
{
Expand Down Expand Up @@ -625,6 +625,7 @@ function get_unlock_request_form()
$unlock_request_form .= '<button type="submit" name="aiowps_unlock_request" id="aiowps_unlock_request" class="button">'.__('Request Unlock', 'all-in-one-wp-security-and-firewall').'</button></div></form>';
return $unlock_request_form;
}
}

/**
* Returns all logged in users for specific subsite of multisite installation
Expand All @@ -648,4 +649,4 @@ static function get_subsite_logged_in_users($blog_id=0) {
}
return $subsite_logged_in_users;
}
}
}