function badbehavior_install in Bad Behavior 5.2
Same name and namespace in other branches
- 6.2 badbehavior.install \badbehavior_install()
- 6 badbehavior.install \badbehavior_install()
- 7.2 badbehavior.install \badbehavior_install()
Implementation of hook_install().
File
- ./
badbehavior.install, line 6
Code
function badbehavior_install() {
if (!is_dir(BB2_CWD . '/bad-behavior')) {
drupal_set_message(t('Bad Behavior directory not found. Please consult badbehavior/README.txt for details.'), 'error');
}
else {
// bad-behavior directory is present, so check for files;
if (file_exists(BB2_CWD . '/bad-behavior/core.inc.php') && file_exists(BB2_CWD . '/bad-behavior/version.inc.php')) {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
if (variable_get('badbehavior_db_installed', 0) != BB2_VERSION) {
bb2_db_query(bb2_table_structure(db_prefix_tables('{bad_behavior_log}')));
variable_set('badbehavior_db_installed', BB2_VERSION);
}
/*
db_query("CREATE TABLE {bad_behavior_log} (
id INT(11) NOT NULL auto_increment,
ip TEXT NOT NULL,
date DATETIME NOT NULL default '0000-00-00 00:00:00',
request_method TEXT NOT NULL,
request_uri TEXT NOT NULL,
server_protocol TEXT NOT NULL,
http_headers TEXT NOT NULL,
user_agent TEXT NOT NULL,
request_entity TEXT NOT NULL,
key TEXT NOT NULL,
INDEX (ip(15)),
INDEX (user_agent(10)),
PRIMARY KEY (id)
);"
);
*/
drupal_set_message(t('The installation of the badbehavior was successful'), 'status');
break;
default:
drupal_set_message(t('Unsupported database.'), 'error');
}
}
else {
watchdog('badbehavior', t('The required third-party bad-behavior files are not installed. Please consult badbehavior/README.txt for details.'), WATCHDOG_ERROR);
drupal_set_message(t('The required Bad Behavior files are not installed. Please consult badbehavior/README.txt for details.'), 'error');
}
}
}