/[drupal]/contributions/modules/badbehavior/badbehavior.install
ViewVC logotype

Contents of /contributions/modules/badbehavior/badbehavior.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Tue Sep 1 21:33:58 2009 UTC (2 months, 3 weeks ago) by seanr
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +59 -51 lines
File MIME type: text/x-php
Catch head up to Drupal 6
1 <?php
2 // $Id: badbehavior.install,v 1.1.4.2 2008/04/07 15:23:50 wilco Exp $
3
4 function badbehavior_install() {
5 drupal_install_schema('badbehavior');
6 }
7
8 function badbehavior_schema() {
9 $schema['bad_behavior_log'] = array(
10 'description' => t('Stores hit logs for the Bad Behavior module.'),
11 'fields' => array(
12 'id' => array('type' => 'serial', 'disp-width' => 11, 'not null' => TRUE),
13 'ip' => array('type' => 'text', 'not null' => TRUE),
14 'date' => array('type' => 'datetime', 'not null' => TRUE, 'default' => '0000-00-00 00:00:00'),
15 'request_method' => array('type' => 'text', 'not null' => TRUE),
16 'request_uri' => array('type' => 'text', 'not null' => TRUE),
17 'server_protocol' => array('type' => 'text', 'not null' => TRUE),
18 'http_headers' => array('type' => 'text', 'not null' => TRUE),
19 'user_agent' => array('type' => 'text', 'not null' => TRUE),
20 'request_entity' => array('type' => 'text', 'not null' => TRUE),
21 'key' => array('type' => 'text', 'not null' => TRUE),
22 ),
23 'primary key' => array('id'),
24 'indexes' => array(
25 'ip' => array(array('ip', 15)),
26 'user_agent' => array(array('user_agent', 10)),
27 ),
28 );
29
30 return $schema;
31 }
32
33 function badbehavior_requirements($phase) {
34 $requirements = array();
35 if ($phase == 'runtime') {
36 if (!is_dir(BB2_CWD .'/bad-behavior')) {
37 $requirements['badbehavior'] = array(
38 'value' => t('Directory error'),
39 'severity' => REQUIREMENT_ERROR,
40 'description' => t('Bad Behavior directory not found. Please consult badbehavior/README.txt for details.'),
41 );
42 }
43 else {
44 // bad-behavior directory is present, so check for files;
45 if (file_exists(BB2_CWD .'/bad-behavior/core.inc.php') && file_exists(BB2_CWD .'/bad-behavior/version.inc.php')) {
46 $requirements['badbehavior'] = array(
47 'value' => t('Version: %version is correctly installed', array('%version' => BB2_VERSION)),
48 'severity' => REQUIREMENT_OK,
49 );
50 }
51 else {
52 $requirements['badbehavior'] = array(
53 'value' => t('Files missing'),
54 'severity' => REQUIREMENT_ERROR,
55 'description' => t('Required Bad Behavior files are not found. Please consult badbehavior/README.txt for details.'),
56 );
57 }
58 }
59 $requirements['badbehavior']['title'] = t('Bad Behavior');
60 }
61 return $requirements;
62 }
63
64 function badbehavior_uninstall() {
65 drupal_uninstall_schema('badbehavior');
66 db_query("DELETE FROM {variable} WHERE name LIKE 'badbehavior_%'");
67 cache_clear_all('variables', 'cache');
68 }

  ViewVC Help
Powered by ViewVC 1.1.2