badbehavior.install in Bad Behavior 5.2
Same filename and directory in other branches
File
badbehavior.installView source
<?php
/**
* Implementation of hook_install().
*/
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');
}
}
}
/**
* Implementation of hook_uninstall().
*/
function badbehavior_uninstall() {
db_query("DROP TABLE {bad_behavior_log}");
// Delete all the badbehavior variables and then clear the variable cache
db_query("DELETE FROM {variable} WHERE name LIKE 'badbehavior_%'");
cache_clear_all('variables', 'cache');
}
Functions
Name![]() |
Description |
---|---|
badbehavior_install | Implementation of hook_install(). |
badbehavior_uninstall | Implementation of hook_uninstall(). |