forked from Cynjut/SCCP_Manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.php
212 lines (188 loc) · 9.5 KB
/
install.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<?php
global $db;
$autoincrement = (($amp_conf["AMPDBENGINE"] == "sqlite") || ($amp_conf["AMPDBENGINE"] == "sqlite3")) ? "AUTOINCREMENT":"AUTO_INCREMENT";
if (!$db->getAll('SHOW COLUMNS FROM sccpdevmodel WHERE FIELD = "loadimage"')) {
$sql = "CREATE TABLE IF NOT EXISTS `sccpdevmodel` (
`model` varchar(20) NOT NULL DEFAULT '',
`vendor` varchar(40) DEFAULT '',
`dns` int(2) DEFAULT '1',
`buttons` int(2) DEFAULT '0',
`loadimage' varchar(40) DEFAULT '',
PRIMARY KEY (`model`),
KEY `model` (`model`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1";
$check = $db->query($sql);
if(db::IsError($check)) {
die_freepbx("Can not create sccpdevmodel table\n");
}
}
if (!$db->getAll('SHOW COLUMNS FROM sccpdevmodel WHERE FIELD = "loadinformationid"')) {
$sql = "ALTER TABLE 'sccpdevmodel' ADD loadinformationid charchar(30);";
$check = $db->query($sql);
if(DB::IsError($check)) {
die_freepbx("Can not add loadinformationid into sccpdevmodel table\n");
}
}
$sql = "REPLACE INTO `sccpdevmodel` VALUES ('7925','CISCO',1,1,'',''),('7902','CISCO',1,1,'CP7902080002SCCP060817A','loadInformation30008'),('7905','CISCO',1,1,'CP7905080003SCCP070409A','loadInformation20000'),('7906','CISCO',1,1,'SCCP11.8-3-1S','loadInformation369'),('7910','CISCO',1,1,'P00405000700','loadInformation6'),('7911','CISCO',1,1,'SCCP11.8-3-1S','loadInformation307'),('7912','CISCO',1,1,'CP7912080003SCCP070409A','loadInformation30007'),('7914','CISCO',0,14,'S00105000300','loadInformation124'),('7920','CISCO',1,1,'cmterm_7920.4.0-03-02','loadInformation30002'),('7921','CISCO',1,1,'CP7921G-1.0.3','loadInformation365'),('7931','CISCO',1,1,'SCCP31.8-3-1S','loadInformation348'),('7936','CISCO',1,1,'cmterm_7936.3-3-13-0','loadInformation30019'),('7937','CISCO',1,1,'','loadInformation431'),('7940','CISCO',1,2,'P00308000500','loadInformation8'),('Digital Access+','CISCO',1,1,'D00303010033','loadInformation42'),('7941','CISCO',1,2,'P00308000500','loadInformation115'),('7941G-GE','CISCO',1,2,'P00308000500','loadInformation309'),('7942','CISCO',1,2,'P00308000500','loadInformation434'),('Digital Access','CISCO',1,1,'D001M022','loadInformation40'),('7945','CISCO',1,2,'P00308000500','loadInformation435'),('7960','CISCO',3,6,'P00308000500','loadInformation7'),('7961','CISCO',3,6,'P00308000500','loadInformation30018'),('7961G-GE','CISCO',3,6,'P00308000500','loadInformation308'),('7962','CISCO',3,6,'P00308000500','loadInformation404'),('7965','CISCO',3,6,'P00308000500','loadInformation436'),('7970','CISCO',3,8,'SCCP70.8-3-1S','loadInformation30006'),('7971','CISCO',3,8,'SCCP70.8-3-1S','loadInformation119'),('7975','CISCO',3,8,'SCCP70.8-3-1S','loadInformation437'),('7985','CISCO',3,8,'cmterm_7985.4-1-4-0','loadInformation302'),('ATA 186','CISCO',1,1,'ATA030203SCCP051201A','loadInformation12'),('IP Communicator','CISCO',1,1,'','loadInformation30016'),('12 SP','CISCO',1,1,'','loadInformation3'),('12 SP+','CISCO',1,1,'','loadInformation2'),('30 SP+','CISCO',1,1,'','loadInformation1'),('30 VIP','CISCO',1,1,'','loadInformation5'),('7914,7914','CISCO',0,28,'S00105000300','loadInformation124'),('7915','CISCO',0,14,'',''),('7916','CISCO',0,14,'',''),('7915,7915','CISCO',0,28,'',''),('7916,7916','CISCO',0,28,'',''),('CN622','MOTOROLA',1,1,'','loadInformation335'),('ICC','NOKIA',1,1,'',''),('E-Series','NOKIA',1,1,'',''),('3911','CISCO',1,1,'','loadInformation446'),('3951','CISCO',1,1,'','loadInformation412');";
$check = $db->query($sql);
if(DB::IsError($check)) {
die_freepbx("Can not REPLACE defaults into sccpdevmodel table\n");
}
if (!$db->getAll('SHOW COLUMNS FROM sccpline WHERE FIELD = "id"')) {
$sql = "CREATE TABLE IF NOT EXISTS `sccpline` (
`id` varchar(45) default NULL,
`pin` varchar(45) default NULL,
`label` varchar(45) default NULL,
`description` varchar(45) default NULL,
`context` varchar(45) default NULL,
`incominglimit` varchar(45) default NULL,
`transfer` varchar(45) default NULL,
`mailbox` varchar(45) default NULL,
`vmnum` varchar(45) default NULL,
`cid_name` varchar(45) default NULL,
`cid_num` varchar(45) default NULL,
`trnsfvm` varchar(45) default NULL,
`secondary_dialtone_digits` varchar(45) default NULL,
`secondary_dialtone_tone` varchar(45) default NULL,
`musicclass` varchar(45) default NULL,
`language` varchar(45) default NULL,
`accountcode` varchar(45) default NULL,
`echocancel` varchar(45) default NULL,
`silencesuppression` varchar(45) default NULL,
`callgroup` varchar(45) default NULL,
`pickupgroup` varchar(45) default NULL,
`amaflags` varchar(45) default NULL,
`dnd` varchar(5) default 'on',
`setvar` varchar(50) default NULL,
`name` varchar(45) NOT NULL default '',
PRIMARY KEY (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;";
$check = $db->query($sql);
if(DB::IsError($check)) {
die_freepbx("Can not add sccpline table\n");
}
$sql = "ALTER TABLE sccpline
ALTER COLUMN incominglimit SET DEFAULT '2',
ALTER COLUMN transfer SET DEFAULT 'on',
ALTER COLUMN vmnum SET DEFAULT '*97',
ALTER COLUMN musicclass SET DEFAULT 'default',
ALTER COLUMN echocancel SET DEFAULT 'on',
ALTER COLUMN silencesuppression SET DEFAULT 'off',
ALTER COLUMN dnd SET DEFAULT 'off'
" ;
$check = $db->query($sql);
if(DB::IsError($check)) {
die_freepbx("Can not modify sccpline table\n");
}
}
if (!$db->getAll('SHOW COLUMNS FROM sccpdevice WHERE FIELD = "type"')) {
$sql = "CREATE TABLE IF NOT EXISTS `sccpdevice` (
`type` varchar(45) default NULL,
`addon` varchar(45) default NULL,
`description` varchar(45) default NULL,
`tzoffset` varchar(5) default NULL,
`transfer` varchar(5) default 'on',
`cfwdall` varchar(5) default 'on',
`cfwdbusy` varchar(5) default 'on',
`dtmfmode` varchar(10) default NULL,
`imageversion` varchar(45) default NULL,
`deny` varchar(45) default NULL,
`permit` varchar(45) default NULL,
`dndFeature` varchar(5) default 'on',
`directrtp` varchar(3) default 'off',
`earlyrtp` varchar(8) default 'off',
`mwilamp` varchar(5) default 'on',
`mwioncall` varchar(5) default 'off',
`pickupexten` varchar(5) default 'on',
`pickupcontext` varchar(100) default '',
`pickupmodeanswer` varchar(5) default 'on',
`private` varchar(5) default 'off',
`privacy` varchar(100) default 'full',
`nat` varchar(15) default 'off',
`softkeyset` varchar(100) default '',
`audio_tos` varchar(11) default NULL,
`audio_cos` varchar(1) default NULL,
`video_tos` varchar(11) default NULL,
`video_cos` varchar(1) default NULL,
`conf_allow` varchar(3) default 'on',
`conf_play_general_announce` varchar(3) default 'on',
`conf_play_part_announce` varchar(3) default 'on',
`conf_mute_on_entry` varchar(3) default 'off',
`conf_music_on_hold_class` varchar(80) default 'default',
`setvar` varchar(100) default NULL,
`disallow` varchar(255) DEFAULT NULL,
`allow` varchar(255) DEFAULT NULL,
`backgroundImage` varchar(255) DEFAULT NULL,
`ringtone` varchar(255) DEFAULT NULL,
`name` varchar(15) NOT NULL default '',
PRIMARY KEY (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;";
$check = $db->query($sql);
if(DB::IsError($check)) {
die_freepbx("Can not add sccpdevice table\n");
}
$sql = "ALTER TABLE sccpdevice
ALTER COLUMN transfer SET DEFAULT 'on',
ALTER COLUMN cfwdall SET DEFAULT 'on',
ALTER COLUMN cfwdbusy SET DEFAULT 'on',
ALTER COLUMN dtmfmode SET DEFAULT 'outofband',
ALTER COLUMN dndFeature SET DEFAULT 'on',
ALTER COLUMN directrtp SET DEFAULT 'off',
ALTER COLUMN earlyrtp SET DEFAULT 'progress',
ALTER COLUMN mwilamp SET DEFAULT 'on',
ALTER COLUMN mwioncall SET DEFAULT 'on',
ALTER COLUMN pickupexten SET DEFAULT 'on',
ALTER COLUMN pickupmodeanswer SET DEFAULT 'on',
ALTER COLUMN private SET DEFAULT 'on',
ALTER COLUMN privacy SET DEFAULT 'off',
ALTER COLUMN nat SET DEFAULT 'off',
ALTER COLUMN softkeyset SET DEFAULT 'softkeyset'
" ;
$check = $db->query($sql);
if(DB::IsError($check)) {
die_freepbx("Can not modify sccpdevice table\n");
}
}
if (!$db->getAll('SHOW COLUMNS FROM buttonconfig WHERE FIELD = "device"')) {
$sql = "CREATE TABLE IF NOT EXISTS `buttonconfig` (
`device` varchar(15) NOT NULL default '',
`instance` tinyint(4) NOT NULL default '0',
`type` enum('line','speeddial','service','feature','empty') NOT NULL default 'empty',
`name` varchar(36) default NULL,
`options` varchar(100) default NULL,
PRIMARY KEY (`device`,`instance`),
KEY `device` (`device`),
FOREIGN KEY (device) REFERENCES sccpdevice(name) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=MyISAM DEFAULT CHARSET=latin1;";
$check = $db->query($sql);
if(DB::IsError($check)) {
die_freepbx("Can not add buttonconfig table\n");
}
}
if (!$db->getAll('SHOW COLUMNS FROM sccpsettings WHERE FIELD = "keyword"')) {
$sql = "CREATE TABLE IF NOT EXISTS `sccpsettings` (
`keyword` varchar(50) NOT NULL default '',
`data` varchar(255) NOT NULL default '',
`seq` tinyint(1) NOT NULL default '0',
`type` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`keyword`,`seq`,`type`),
KEY `keyword` (`keyword`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;";
$check = $db->query($sql);
if(DB::IsError($check)) {
die_freepbx("Can not add sccpsettings table\n");
}
}
$sql = "CREATE OR REPLACE
ALGORITHM = MERGE
VIEW sccpdeviceconfig AS
SELECT GROUP_CONCAT( CONCAT_WS( ',', buttonconfig.type,
buttonconfig.name, buttonconfig.options )
ORDER BY instance ASC
SEPARATOR ';' ) AS button, sccpdevice.*
FROM sccpdevice
LEFT JOIN buttonconfig ON ( buttonconfig.device = sccpdevice.name )
GROUP BY sccpdevice.name; ";
$check = $db->query($sql);
if(DB::IsError($check)) {
die_freepbx("Can not create sccpdeviceconfig view\n");
}