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

Contents of /contributions/modules/ip2cc/ip2cc.install

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


Revision 1.4 - (show annotations) (download) (as text)
Thu Oct 25 16:53:36 2007 UTC (2 years, 1 month ago) by sugree
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +15 -6 lines
File MIME type: text/x-php
merged json patch
1 <?php
2 // $Id: ip2cc.install,v 1.1.2.8 2007/10/25 16:39:30 sugree Exp $
3
4 function ip2cc_install() {
5 switch ($GLOBALS['db_type']) {
6 case 'mysql':
7 case 'mysqli':
8 db_query("CREATE TABLE {iso3166} (
9 country_code2 char(2) NOT NULL,
10 country_code3 char(3) NOT NULL,
11 country_name varchar(80) NOT NULL,
12 country_number int(3) NOT NULL default '0',
13 KEY iso3166_code3 (country_code3),
14 KEY iso3166_name (country_name),
15 PRIMARY KEY (country_code2)
16 ) TYPE=MyISAM
17 /*!40100 DEFAULT CHARACTER SET utf8 */ ;");
18
19 db_query("CREATE TABLE {ip2cc} (
20 ip_from double NOT NULL default '0',
21 ip_to double NOT NULL default '0',
22 country_code char(2) NOT NULL default '',
23 net_name char(128) NOT NULL default '',
24 as_number int(10) NOT NULL default '0',
25 PRIMARY KEY (ip_from,ip_to)
26 ) TYPE=MyISAM
27 /*!40100 DEFAULT CHARACTER SET utf8 */ ;");
28
29 db_query("CREATE TABLE {ip2cc_node} (
30 nid int(10) unsigned NOT NULL default '0',
31 hostname varchar(128) default NULL,
32 PRIMARY KEY (nid)
33 ) TYPE=MyISAM
34 /*!40100 DEFAULT CHARACTER SET utf8 */ ;");
35
36 ip2cc_batch_insert('iso3166.mysql');
37 if (!ini_get('safe_mode')) {
38 set_time_limit(0);
39 ip2cc_batch_insert('ipdb.mysql');
40 }
41 else {
42 drupal_set_message(t('Since you are in safe_mode, please manually import IP database by small range at <a href="admin/settings/ip2cc/update">update</a> page to prevent execution timeout issue.'));
43 }
44
45 break;
46 }
47 }
48
49 /*
50 function ip2cc_uninstall() {
51 db_query("DROP TABLE {iso3166}");
52 db_query("DROP TABLE {ip2cc_node}");
53 }
54 */
55
56 function ip2cc_batch_insert($filename) {
57 if ($fd = fopen(drupal_get_path('module','ip2cc').'/'.$filename, 'r')) {
58 while (!feof($fd)) {
59 if ($line = fgets($fd)) {
60 _db_query(db_prefix_tables($line));
61 }
62 $line = NULL;
63 }
64 fclose($fd);
65 }
66 }
67
68 function ip2cc_update_1() {
69 cache_clear_all(null, 'cache_menu');
70 }

  ViewVC Help
Powered by ViewVC 1.1.2