| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
global $db; |
|---|
| 4 |
global $amp_conf; |
|---|
| 5 |
|
|---|
| 6 |
if (! function_exists("out")) { |
|---|
| 7 |
function out($text) { |
|---|
| 8 |
echo $text."<br />"; |
|---|
| 9 |
} |
|---|
| 10 |
} |
|---|
| 11 |
|
|---|
| 12 |
if (! function_exists("outn")) { |
|---|
| 13 |
function outn($text) { |
|---|
| 14 |
echo $text; |
|---|
| 15 |
} |
|---|
| 16 |
} |
|---|
| 17 |
|
|---|
| 18 |
$autoincrement = (($amp_conf["AMPDBENGINE"] == "sqlite") || ($amp_conf["AMPDBENGINE"] == "sqlite3")) ? "AUTOINCREMENT":"AUTO_INCREMENT"; |
|---|
| 19 |
|
|---|
| 20 |
// create the tables |
|---|
| 21 |
$sql = "CREATE TABLE IF NOT EXISTS cidroute_cidlist ( |
|---|
| 22 |
country varchar(2) NOT NULL default '', |
|---|
| 23 |
state varchar(10) NOT NULL default '', |
|---|
| 24 |
region varchar(50) NOT NULL default '', |
|---|
| 25 |
localarea varchar(50) NOT NULL default '', |
|---|
| 26 |
areacode int(11) unsigned NOT NULL, |
|---|
| 27 |
min_numb int(11) unsigned NOT NULL, |
|---|
| 28 |
max_numb int(11) unsigned NOT NULL, |
|---|
| 29 |
postcode varchar(12) default '', |
|---|
| 30 |
KEY idx_country (country), |
|---|
| 31 |
KEY idx_numb (min_numb,max_numb) |
|---|
| 32 |
);"; |
|---|
| 33 |
|
|---|
| 34 |
$check = $db->query($sql); |
|---|
| 35 |
if (DB::IsError($check)) { |
|---|
| 36 |
die_freepbx( "Can not create `cid` table: " . $check->getMessage() . "\n"); |
|---|
| 37 |
} |
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
$sql = "CREATE TABLE IF NOT EXISTS cidroute_matches ( |
|---|
| 41 |
name varchar(50) default '', |
|---|
| 42 |
country varchar(2) NOT NULL default '', |
|---|
| 43 |
areacode int(11) unsigned NOT NULL, |
|---|
| 44 |
min_numb int(11) unsigned NOT NULL, |
|---|
| 45 |
max_numb int(11) unsigned NOT NULL, |
|---|
| 46 |
dest varchar(12) default '', |
|---|
| 47 |
KEY idx_country (country), |
|---|
| 48 |
KEY idx_numb (min_numb,max_numb) |
|---|
| 49 |
|
|---|
| 50 |
);"; |
|---|
| 51 |
$check = $db->query($sql); |
|---|
| 52 |
if (DB::IsError($check)) { |
|---|
| 53 |
die_freepbx( "Can not create `cidroute_matches` table: " . $check->getMessage() . "\n"); |
|---|
| 54 |
} |
|---|
| 55 |
|
|---|
| 56 |
$sql = "CREATE TABLE IF NOT EXISTS cidroute_override ( |
|---|
| 57 |
name varchar(20) NOT NULL default '', |
|---|
| 58 |
number int(11) unsigned NOT NULL, |
|---|
| 59 |
dest varchar(12) default '' |
|---|
| 60 |
);"; |
|---|
| 61 |
$check = $db->query($sql); |
|---|
| 62 |
if (DB::IsError($check)) { |
|---|
| 63 |
die_freepbx( "Can not create `cidroute_override` table: " . $check->getMessage() . "\n"); |
|---|
| 64 |
} |
|---|
| 65 |
|
|---|
| 66 |
$sql = "CREATE TABLE IF NOT EXISTS cidroute_config ( |
|---|
| 67 |
trunk varchar(20) NOT NULL default '', |
|---|
| 68 |
enabled boolean NOT NULL |
|---|
| 69 |
);"; |
|---|
| 70 |
$check = $db->query($sql); |
|---|
| 71 |
if (DB::IsError($check)) { |
|---|
| 72 |
die_freepbx( "Can not create `cidroute_override` table: " . $check->getMessage() . "\n"); |
|---|
| 73 |
} |
|---|
| 74 |
|
|---|
| 75 |
$sql = "CREATE TABLE IF NOT EXISTS cidroute_dests ( |
|---|
| 76 |
destid int(11) not null auto_increment, |
|---|
| 77 |
name varchar(50) NOT NULL default '', |
|---|
| 78 |
dest varchar(50) NOT NULL default '', |
|---|
| 79 |
primary key (destid) |
|---|
| 80 |
);"; |
|---|
| 81 |
$check = $db->query($sql); |
|---|
| 82 |
if (DB::IsError($check)) { |
|---|
| 83 |
die_freepbx( "Can not create `cidroute_override` table: " . $check->getMessage() . "\n"); |
|---|
| 84 |
} |
|---|
| 85 |
|
|---|
| 86 |
?> |
|---|