source: extensions/whois_online/maintain.inc.php @ 3956

Last change on this file since 3956 was 3695, checked in by vdigital, 15 years ago

Minor release: 2009-07-28 2.0.j

Minor changes in Config management
Additionnal flags (Ireland, Armenia, Estonia, Kazakhstan, Belarus,
Andorra, Turkey, Albania, Bosnia and Herzegovina, Azerbaijan, Iceland, European Union,
Israel, Morocco, New Caledonia and some other revised)
Search Engine trapping

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1<?php
2
3global $prefixeTable, $conf;
4if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
5if (!defined('IN_ADMIN') or !IN_ADMIN) die('Hacking attempt!');
6if (!defined('WHOIS_ONLINE_TABLE')) define('WHOIS_ONLINE_TABLE', $prefixeTable.'whois_online');
7
8function plugin_activate()
9{
10        global $user,$conf;
11        $query = "CREATE TABLE IF NOT EXISTS ". WHOIS_ONLINE_TABLE ." (
12  `IP` varchar(39) NOT NULL DEFAULT '',
13  `hidden_IP` enum('true','false') NOT NULL DEFAULT 'false',
14  `session_id` varchar(40) NOT NULL,
15  `user_id` smallint(5) NOT NULL DEFAULT '0',
16  `username` varchar(100) character set utf8 collate utf8_bin NOT NULL DEFAULT '',
17  `lang` char(2) character set utf8 collate utf8_bin NOT NULL DEFAULT 'en',
18  `country` VARCHAR( 256 ) NOT NULL DEFAULT '',
19  `user_agent` VARCHAR( 160 ) NOT NULL DEFAULT '',
20  `any_previous` VARCHAR( 256 ) NOT NULL DEFAULT '',
21  `same_previous` VARCHAR( 256 ) NOT NULL DEFAULT '',
22  `permanent` enum('true','false') NOT NULL DEFAULT 'false',
23  `last_access` varchar(12) NOT NULL DEFAULT '',
24  `last_elm_ids` varchar(75) NOT NULL DEFAULT '',
25  `last_cat_ids` varchar(75) NOT NULL DEFAULT '',
26  `last_tag_ids` varchar(75) NOT NULL DEFAULT '',
27  `last_sch_ids` varchar(75) NOT NULL DEFAULT '',
28  `first_access_date` varchar(45) NOT NULL DEFAULT '',
29  `last_dates` varchar(110) character set utf8 collate utf8_bin NOT NULL DEFAULT '',
30  `elm_hits` int(10) unsigned NOT NULL DEFAULT '0',
31  `pag_hits` int(10) unsigned NOT NULL DEFAULT '0',
32  `db_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
33  PRIMARY KEY  (`session_id`)
34) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
35";
36        $result = pwg_query($query);
37        if (!isset($conf['Whois Online'])) {
38                $conf['Whois Online'] = serialize(Array());
39                pwg_query('REPLACE INTO ' . CONFIG_TABLE . " (param,value,comment)
40                VALUES ('Whois Online','". $conf['Whois Online'] ."','Whois Online configuration');");
41        }
42        if (isset($conf_whois['Keep data']) and !$conf_whois['Keep data']) {
43                pwg_query('DELETE FROM ' . WHOIS_ONLINE_TABLE);
44        }
45        list($hits) = mysql_fetch_row(pwg_query('SELECT SUM(hit) FROM '.IMAGES_TABLE.';'));
46        $pags = floor($hits * 1.69); /* estimate : 1.69 is a frequent ratio between images hits and pages hits */
47        pwg_query('REPLACE INTO ' . WHOIS_ONLINE_TABLE . ' (`IP`, `hidden_IP`, `session_id`, `user_id`,`username`,`lang`,`permanent`,`last_access`,
48        `last_elm_ids`, `last_cat_ids`, `last_tag_ids`, `last_sch_ids`,
49        `first_access_date`, `last_dates`, `elm_hits`, `pag_hits`)
50                VALUES (\'global\', \'true\',\'global\', 0, \'Administrator\', \'--\', \'true\', \''
51                . time() .'\', \''. implode(' ',array_fill(0, 12, 0))
52                . '\', \''. implode(' ',array_fill(0, 14, 0))
53                . '\', \''. implode(' ',array_fill(0, 14, 0))
54                . '\', \''. implode(' ',array_fill(0, 14, 0))
55                . '\', \'' 
56                . date('Y-m-d') . '\', \'\', \'' 
57                . $hits . '\', \'' . $pags . '\');');
58}
59
60function plugin_deactivate()
61{
62        global $conf;
63        if (isset($conf['Whois Online'])) $conf_whois = unserialize($conf['Whois Online']);
64        if (isset($conf_whois['Keep data']) and !$conf_whois['Keep data']) 
65                pwg_query('DROP TABLE IF EXISTS ' . WHOIS_ONLINE_TABLE);
66}
67
68function plugin_uninstall()
69{
70        global $conf;
71        if (isset($conf['Whois Online'])) $conf_whois = unserialize($conf['Whois Online']);
72        if (isset($conf_whois['Keep data']) and !$conf_whois['Keep data']) {
73                pwg_query('DELETE FROM ' . CONFIG_TABLE . ' WHERE param = ' . "'Whois Online'");
74                pwg_query('DROP TABLE IF EXISTS ' . WHOIS_ONLINE_TABLE);
75                unset($conf['Whois Online']);
76        }
77}
78?>
Note: See TracBrowser for help on using the repository browser.