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

Last change on this file since 5954 was 5954, checked in by vdigital, 14 years ago

[ 2.0.m ]

Fix: IE8 User agent could be too long
Fix: Failure on localisation (a French internet provider blocks external get_files)
Fix: Loss of previous collected data


  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
RevLine 
[3319]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{
[3695]10        global $user,$conf;
[3319]11        $query = "CREATE TABLE IF NOT EXISTS ". WHOIS_ONLINE_TABLE ." (
[3695]12  `IP` varchar(39) NOT NULL DEFAULT '',
13  `hidden_IP` enum('true','false') NOT NULL DEFAULT 'false',
[3319]14  `session_id` varchar(40) NOT NULL,
[3695]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',
[5810]18  `country` VARCHAR( 255 ) NOT NULL DEFAULT '',
[3695]19  `user_agent` VARCHAR( 160 ) NOT NULL DEFAULT '',
[5810]20  `any_previous` VARCHAR( 255 ) NOT NULL DEFAULT '',
21  `same_previous` VARCHAR( 255 ) NOT NULL DEFAULT '',
[3695]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,
[3319]33  PRIMARY KEY  (`session_id`)
34) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
35";
36        $result = pwg_query($query);
[3695]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');");
[3319]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 */
[5954]47        pwg_query('INSERT IGNORE INTO ' . WHOIS_ONLINE_TABLE . ' (`IP`, `hidden_IP`, `session_id`, `user_id`,`username`,`lang`,`permanent`,`last_access`,
[3319]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.