function get_links($user_level, $connection, $visible, $child_of = -1, $sub_menu_only = false) { /* TODO: make language selectable */ require "config/db_config.php"; if (!mysqli_is_table($db_host, $db_user, $db_pass, $db_name, "menu_items")) { $retval[0][] = "Login"; $retval[1][] = "login.php"; return $retval; } if ($sub_menu_only == true) { $result = mysqli_query($connection, "SELECT * FROM menu_items WHERE security_level <= " . sanitize($user_level) . " and language = 'en' and visible = " . sanitize($visible) . " ORDER BY menu_order"); } else { if ($visible == "1") { $result = mysqli_query($connection, "SELECT * FROM menu_items WHERE security_level <= " . sanitize($user_level) . " and language = 'en' and child_of = " . sanitize($child_of) . " and visible = " . sanitize($visible) . " ORDER BY menu_order"); } else { $result = mysqli_query($connection, "SELECT * FROM menu_items WHERE security_level <= " . sanitize($user_level) . " and language = 'en' and visible = " . sanitize($visible) . " ORDER BY menu_order"); } } if (mysqli_num_rows($result) > 0) { while ($row = mysqli_fetch_assoc($result)) { $menu_names[] = $row['menu_text']; if ($row['use_iframe'] == 1) { $menu_links[] = "show_page.php?id=" . $row['id']; } else { $menu_links[] = $row['link']; } $ids[] = $row['id']; $icons[] = $row['icon']; } } $retval[0] = $menu_names; $retval[1] = $menu_links; $retval[2] = $ids; $retval[3] = $icons; return $retval; }
function create_missing_tables($db_host, $db_user, $db_pass) { $link = mysqli_connect($db_host, $db_user, $db_pass) or die(mysql_error()); /*====================================================================== names Table ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "names")) { include "admin/db_config.php"; $sql = "CREATE TABLE `names` (\n `campaignid` int(200) NOT NULL default '0',\n `phonenumber` varchar(50) NOT NULL default '',\n `name` varchar(50) NOT NULL default '',\n `datetime` timestamp NULL default NULL on update CURRENT_TIMESTAMP,\n PRIMARY KEY (`campaignid`,`phonenumber`)\n )"; $result = mysqli_query($link, $sql, $link) or die(mysql_error()); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Created names Table')"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== Schedule Table ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "schedule")) { $sql = "CREATE TABLE `schedule` (\n `id` int(10) unsigned NOT NULL auto_increment,\n `name` varchar(255) default NULL,\n `description` varchar(255) default NULL,\n `campaignid` int default NULL,\n `start_hour` tinyint(2) zerofill default NULL,\n `start_minute` tinyint(2) zerofill default NULL,\n `end_hour` tinyint(2) zerofill default NULL,\n `end_minute` tinyint(2) zerofill default NULL,\n `regularity` varchar(255) default NULL,\n `username` varchar(255) default NULL,\n PRIMARY KEY (`id`)\n )"; $result = mysqli_query($link, $sql, $link) or die(mysql_error()); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Created Schedule Table')"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== Web_config Table ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "web_config")) { $sql = "\n CREATE TABLE `web_config` (\n `url` varchar(250) default NULL,\n `LANG` varchar(250) default NULL,\n `language` varchar(250) default NULL,\n `colour` varchar(250) default NULL,\n `title` varchar(250) default NULL,\n `logo` varchar(250) default NULL,\n `contact_text` text,\n `sox` varchar(250) default NULL,\n `userid` varchar(250) default NULL,\n `licence` varchar(250) default NULL,\n `cdr_host` varchar(250) default NULL,\n `cdr_user` varchar(250) default NULL,\n `cdr_pass` varchar(250) default NULL,\n `cdr_db` varchar(250) default NULL,\n `cdr_table` varchar(250) default NULL,\n `menu_home` varchar(250) default NULL,\n `menu_campaigns` varchar(250) default NULL,\n `menu_numbers` varchar(250) default NULL,\n `menu_dnc` varchar(250) default NULL,\n `menu_messages` varchar(250) default NULL,\n `menu_schedules` varchar(250) default NULL,\n `menu_customers` varchar(250) default NULL,\n `menu_queues` varchar(250) default NULL,\n `menu_servers` varchar(250) default NULL,\n `menu_trunks` varchar(250) default NULL,\n `menu_admin` varchar(250) default NULL,\n `menu_logout` varchar(250) default NULL,\n `date_colour` varchar(250) default NULL,\n `main_page_text` text,\n `main_page_username` varchar(250) default NULL,\n `main_page_password` varchar(250) default NULL,\n `main_page_login` varchar(250) default NULL,\n `currency_symbol` varchar(250) default NULL,\n `per_minute` varchar(250) default NULL,\n `use_billing` varchar(250) default NULL,\n `front_page_billing` varchar(250) default NULL,\n `spare1` varchar(250) default NULL,\n `spare2` varchar(250) default NULL,\n `spare3` varchar(250) default NULL,\n `spare4` varchar(250) default NULL,\n `spare5` varchar(250) default NULL,\n `st_mysql_host` varchar(250) default NULL,\n `st_mysql_user` varchar(250) default NULL,\n `st_mysql_pass` varchar(250) default NULL,\n `add_campaign` varchar(250) default NULL,\n `view_campaign` varchar(250) default NULL,\n `per_page` varchar(250) default NULL,\n `numbers_view` varchar(250) default NULL,\n `numbers_system` varchar(250) default NULL,\n `numbers_generate` varchar(250) default NULL,\n `numbers_manual` varchar(250) default NULL,\n `numbers_upload` varchar(250) default NULL,\n `numbers_export` varchar(250) default NULL,\n `numbers_search` varchar(250) default NULL,\n `numbers_title` varchar(250) default NULL,\n `billing_text` varchar(250) default NULL,\n `cdr_text` varchar(250) default NULL,\n `use_generate` varchar(250) default NULL,\n `dnc_numbers_title` varchar(250) default NULL,\n `dnc_view` varchar(250) default NULL,\n `dnc_search` varchar(250) default NULL,\n `dnc_upload` varchar(250) default NULL,\n `dnc_add` varchar(250) default NULL,\n `per_lead` varchar(250) default NULL,\n `smtp_host` varchar(250) default NULL,\n `smtp_user` varchar(250) default NULL,\n `smtp_pass` varchar(250) default NULL,\n `smtp_from` varchar(250) default NULL,\n `use_separate_dnc` varchar(250) default NULL,\n `allow_numbers_manual` varchar(250) default NULL\n )\t\t "; $result = mysqli_query($link, $sql, $link) or die(mysql_error()); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Created Web_config Table')"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== test_results Table ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "test_results")) { $sql = "CREATE TABLE `test_results` (\n `id` int(11) unsigned NOT NULL auto_increment,\n `camaignid` int(11) unsigned NOT NULL,\n `description` varchar(255) default NULL,\n `channels` int(10) unsigned default NULL,\n `avg_busy` varchar(255) default NULL,\n `timespent` varchar(255) default NULL,\n `dialed` varchar(255) default NULL,\n `avg_cps` varchar(255) default NULL,\n `tot_cps` varchar(255) default NULL,\n `overs` varchar(255) default NULL,\n PRIMARY KEY (`id`)\n )"; $result = mysqli_query($link, $sql, $link) or die(mysql_error()); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Created test_results Table')"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== Log Table ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "log")) { $sql = "CREATE TABLE `log` (\n `timestamp` timestamp NULL default NULL on update CURRENT_TIMESTAMP,\n `activity` varchar(255) default NULL,\n `username` varchar(255) default NULL\n )"; $result = mysqli_query($link, $sql, $link); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Attempted login')"; $result = mysqli_query($link, $sql, $link); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Created Log Table')"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== System Billing Table ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "system_billing")) { include "admin/db_config.php"; $sql = "CREATE TABLE `system_billing` (\n `id` int(10) unsigned NOT NULL auto_increment,\n `groupid` int(11) default NULL,\n `totalcost` double default '0',\n `timestamp` timestamp NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n PRIMARY KEY (`id`)\n )"; $result = mysqli_query($link, $sql, $link); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Created System Timestamp Billing Table')"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== campaign Table ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "campaign")) { include "admin/db_config.php"; $sql = "CREATE TABLE `campaign` (\n `id` int(200) NOT NULL auto_increment,\n `description` varchar(250) default NULL,\n `name` varchar(200) NOT NULL default '',\n `groupid` int(200) NOT NULL default '0',\n `messageid` int(200) NOT NULL default '0',\n `campaignconfigid` int(11) NOT NULL default '0',\n `messageid2` int(200) unsigned NOT NULL default '0',\n `messageid3` int(200) unsigned NOT NULL default '0',\n `astqueuename` varchar(255) default NULL,\n `mode` int(11) default '0',\n `clid` varchar(255) default 'nocallerid <>',\n `trclid` varchar(255) default 'nocallerid',\n `maxagents` int(11) default '30',\n `did` varchar(255) default 'nodid',\n `context` varchar(255) default 'ls3',\n `cost` varchar(10) default NULL,\n PRIMARY KEY (`id`)\n )"; $result = mysqli_query($link, $sql, $link); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Created campaign Table')"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== campaigngroup Table ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "campaigngroup")) { include "admin/db_config.php"; $sql = "CREATE TABLE `campaigngroup` (\n `id` int(11) NOT NULL auto_increment,\n `name` varchar(200) NOT NULL default '',\n `description` varchar(200) default NULL,\n PRIMARY KEY (`id`)\n )"; $result = mysqli_query($link, $sql, $link); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Created campaigngroup Table')"; $result = mysqli_query($link, $sql, $link); $sql = "insert into campaigngroup values\n (1, 'VentureVoIP', 'A demonstation group which contains a single demo campaign')"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== campaignmessage Table ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "campaignmessage")) { include "admin/db_config.php"; $sql = "CREATE TABLE `campaignmessage` (\n `id` int(11) NOT NULL auto_increment,\n `filename` varchar(250) NOT NULL default '',\n `name` varchar(200) NOT NULL default '',\n `description` varchar(250) NOT NULL default '',\n `customer_id` int(11) default '0',\n `length` varchar(255) default NULL,\n PRIMARY KEY (`id`)\n )"; $result = mysqli_query($link, $sql, $link); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Created campaignmessage Table')"; $result = mysqli_query($link, $sql, $link); $sql = "insert into campaignmessage values\n (27, 'fax-33e5c3b94674a138bc5b390c06e2dba2e7488cb6.tiff', 'New Test Fax', 'A fax broadcasting test', 1, ''),\n (14, 'x-afa871459b4fff189d78420ad7f3158918ca8333.sln', 'Ringin', 'The windows ring in sound', 1, '0.905500'),\n (13, 'x-aba93245ef688df351b4c1765307c1e00a7d3b2e.sln', 'Chord', 'The windows chord sound', 1, '1.099000'),\n (19, 'x-02c4778bdf0e525aa5bbfc5190a9ff7b184136b2.sln', 'Popcorn', 'Popcorn song', 1, '28.585125'),\n (21, 'x-df6efd23c65b97ae1920ceb5ad7b2ee2a2732431.sln', 'Tada', 'The windows tada sound', 26, '1.939000'),\n (24, 'x-d91f8f58dd14d004a31780540d34bba034f3bb1c.sln', 'Transfer 1 -Great', 'Great -here we go', 26, '1.656625'),\n (28, 'x-f9036629b654fffe0bdee6db47521dcd2ceb84b1.sln', 'Ding', 'The windows ding alert sound', 85, '0.915750')"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== cdr Table ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "cdr")) { include "admin/db_config.php"; $sql = "CREATE TABLE `cdr` (\n `calldate` datetime NOT NULL default '0000-00-00 00:00:00',\n `clid` varchar(80) NOT NULL default '',\n `src` varchar(80) NOT NULL default '',\n `dst` varchar(80) NOT NULL default '',\n `dcontext` varchar(80) NOT NULL default '',\n `channel` varchar(80) NOT NULL default '',\n `dstchannel` varchar(80) NOT NULL default '',\n `lastapp` varchar(80) NOT NULL default '',\n `lastdata` varchar(80) NOT NULL default '',\n `duration` int(11) NOT NULL default '0',\n `billsec` int(11) NOT NULL default '0',\n `disposition` varchar(45) NOT NULL default '',\n `amaflags` int(11) NOT NULL default '0',\n `accountcode` varchar(20) NOT NULL default '',\n `userfield` varchar(255) NOT NULL default '',\n `userfield2` varchar(2) NOT NULL default '',\n KEY (`dcontext`,`userfield`,`userfield2`),\n KEY `calldate` (`calldate`),\n KEY `dst` (`dst`),\n KEY `accountcode` (`accountcode`)\n )"; $result = mysqli_query($link, $sql, $link); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Created cdr Table')"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== config Table ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "config")) { include "admin/db_config.php"; $sql = "CREATE TABLE `config` (\n `parameter` varchar(255) NOT NULL default '0',\n `value` varchar(255) NOT NULL,\n PRIMARY KEY (`parameter`)\n ) "; $result = mysqli_query($link, $sql, $link); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Created config Table')"; $result = mysqli_query($link, $sql, $link); $sql = "insert into config values\n ('backend', '0'),\n ('userid', 'VentureVoIP'),\n ('licencekey', 'DRFHUJWQIWU')"; $result = mysqli_query($link, $sql, $link); } /* Check if the length of the parameter field is 255 - if not make it so */ $result = mysqli_query($link, "SELECT parameter, value FROM config"); $param_length = mysql_field_len($result, 0); $value_length = mysql_field_len($result, 1); if ($param_length != 255) { $sql = "ALTER TABLE config MODIFY parameter VARCHAR(255)"; $result = mysqli_query($link, $sql, $link); $sql = "ALTER TABLE config MODIFY value VARCHAR(255)"; $result = mysqli_query($link, $sql, $link); } /* Check if there is a primary key on the config table - if not create it */ $result = mysqli_query($link, "SHOW INDEXES FROM config"); if (mysqli_num_rows($result) == 0) { $sql = "ALTER TABLE config ADD PRIMARY KEY (parameter)"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== rates Table ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "rates")) { include "admin/db_config.php"; $sql = "CREATE TABLE `rates` (\n `campaignid` int(11) NOT NULL,\n `idx` int(11) NOT NULL,\n `value` double NOT NULL,\n UNIQUE KEY `c_i` (`campaignid`,`idx`),\n KEY `campaignid` (`campaignid`)\n ) ENGINE=MyISAM DEFAULT CHARSET=latin1;\n "; $result = mysqli_query($link, $sql, $link); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Created rates Table')"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== engine_stats Table ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "engine_stats")) { include "admin/db_config.php"; $sql = "\n CREATE TABLE `engine_stats` (\n `stat` varchar(250) NOT NULL,\n `value` varchar(250) NOT NULL default 'null',\n PRIMARY KEY (`stat`)\n ) ENGINE=MyISAM DEFAULT CHARSET=latin1;\n "; $result = mysqli_query($link, $sql, $link); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Created profracs Table')"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== profracs Table ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "profracs")) { include "admin/db_config.php"; $sql = "\n CREATE TABLE `profracs` (\n `campaignid` int(11) NOT NULL,\n `idx` int(11) NOT NULL,\n `value` double NOT NULL,\n UNIQUE KEY `c_i` (`campaignid`,`idx`),\n KEY `campaignid` (`campaignid`)\n ) ENGINE=MyISAM DEFAULT CHARSET=latin1;\n "; $result = mysqli_query($link, $sql, $link); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Created profracs Table')"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== sleeps Table ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "sleeps")) { include "admin/db_config.php"; $sql = "\n CREATE TABLE `sleeps` (\n `campaignid` int(11) NOT NULL,\n `idx` int(11) NOT NULL,\n `value` double NOT NULL,\n UNIQUE KEY `c_i` (`campaignid`,`idx`),\n KEY `campaignid` (`campaignid`)\n ) ENGINE=MyISAM DEFAULT CHARSET=latin1;\n "; $result = mysqli_query($link, $sql, $link); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Created sleeps Table')"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== campaign_stats Table ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "campaign_stats")) { include "admin/db_config.php"; $sql = "\n CREATE TABLE `campaign_stats` (\n `campaignid` int(11) NOT NULL,\n `min_agents` int(11) default NULL,\n `busy_agents` int(11) default NULL,\n `total_agents` int(11) default NULL,\n `dialed` int(11) default NULL,\n `speed_multiplyer` double default NULL,\n `max_running_speed` double default NULL,\n `adjuster` int(11) default NULL,\n `time_spent` bigint(20) default NULL,\n `weighted` double default NULL,\n `cummulative_area_diff` double default NULL,\n `ms_sleep` double default NULL,\n `max_delay_calc` double default NULL,\n `overs_1` int(11) default NULL,\n `overs_2` double default NULL,\n PRIMARY KEY (`campaignid`)\n ) ENGINE=MyISAM DEFAULT CHARSET=latin1;\n \n "; $result = mysqli_query($link, $sql, $link); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Created campaign_stats Table')"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== customer Table ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "customer")) { include "admin/db_config.php"; $sql = "CREATE TABLE `customer` (\n `id` int(10) unsigned NOT NULL auto_increment,\n `username` varchar(30) NOT NULL default '',\n `password` varchar(200) NOT NULL default '',\n `campaigngroupid` int(10) unsigned NOT NULL default '0',\n `address1` varchar(250) default NULL,\n `address2` varchar(250) default NULL,\n `city` varchar(250) default NULL,\n `country` varchar(250) default NULL,\n `phone` varchar(250) default NULL,\n `email` varchar(250) default NULL,\n `fax` varchar(250) default NULL,\n `website` varchar(250) default NULL,\n `security` int(3) unsigned default '0',\n `company` varchar(250) default NULL,\n `trunkid` int(11) default '-1',\n `zip` varchar(25) default NULL,\n `state` varchar(250) default NULL,\n `maxcps` int(11) default '1',\n `maxchans` int(11) default '100',\n `do_not_call` int(1) default '0',\n `do_not_call_reason` text default NULL,\n `adminlists` varchar(2555) default NULL,\n `didlogin` varchar(255) default NULL,\n `interface_type` VARCHAR(255) default 'default',\n PRIMARY KEY (`id`)\n ) "; $result = mysqli_query($link, $sql, $link) or die(mysql_error()); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Created customer Table')"; $result = mysqli_query($link, $sql, $link); $sql = "insert into customer (id, username, password, campaigngroupid, maxcps, maxchans, security)\n values (2, 'admin', '" . sha1("adminpass") . "', 1, 1000, 1001, 100)"; $result = mysqli_query($link, $sql, $link) or die(mysql_error()); } /*====================================================================== dncnumber Table ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "dncnumber")) { include "admin/db_config.php"; $sql = "CREATE TABLE `dncnumber` (\n `campaignid` int(200) NOT NULL default '0',\n `phonenumber` varchar(50) NOT NULL default '',\n `status` varchar(50) NOT NULL default '',\n `type` int(5) NOT NULL default '0',\n PRIMARY KEY (`campaignid`,`phonenumber`),\n KEY `test` (`phonenumber`,`campaignid`)\n ) "; $result = mysqli_query($link, $sql, $link); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Created dncnumber Table')"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== number Table ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "number")) { include "admin/db_config.php"; $sql = "CREATE TABLE `number` (\n `campaignid` int(200) NOT NULL default '0',\n `phonenumber` varchar(50) NOT NULL default '',\n `status` varchar(50) NOT NULL default '',\n `type` int(5) NOT NULL default '0',\n `datetime` timestamp NULL default NULL on update CURRENT_TIMESTAMP,\n `random_sort` int(10) NOT NULL default '0',\n PRIMARY KEY (`campaignid`,`phonenumber`),\n KEY `status` (`campaignid`,`status`),\n KEY `randomize` (`random_sort`,`campaignid`, `status`),\n KEY `status2` (`status`)\n )"; $result = mysqli_query($link, $sql, $link); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Created number Table')"; $result = mysqli_query($link, $sql, $link); } $fields = mysql_list_fields('SineDialer', 'number'); $columns = mysql_num_fields($fields); for ($i = 0; $i < $columns; $i++) { $field_array[] = mysql_field_name($fields, $i); } if (!in_array('random_sort', $field_array)) { echo "Please wait, updating system...this may take a while - please don't stop it<br />"; flush(); sleep(1); echo "Starting with adding the random sort field to the numbers table<br />"; flush(); sleep(1); $result = mysqli_query($link, 'ALTER TABLE number ADD random_sort int(10)') or die(mysql_error()); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Added number random_sort field')"; $result = mysqli_query($link, $sql, $link); echo "Added field - now updating the numbers to give them each a random value<br />"; flush(); sleep(1); $result = mysqli_query($link, 'UPDATE number SET random_sort = ROUND(RAND() * 999999999)') or die(mysql_error()); $result = mysqli_query($link, "ALTER TABLE number ADD INDEX randomize (random_sort, campaignid, status)") or die(mysql_error()); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'randomized existing number field')"; echo "Update complete - please log back in"; ?> <META HTTP-EQUIV=REFRESH CONTENT="0; URL=/index.php"><?php exit(0); } /*====================================================================== number_done Table ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "number_done")) { include "admin/db_config.php"; $sql = "CREATE TABLE `number_done` (\n `campaignid` int(200) NOT NULL default '0',\n `phonenumber` varchar(50) NOT NULL default '',\n `status` varchar(50) NOT NULL default '',\n `type` int(5) NOT NULL default '0',\n `datetime` timestamp NULL default NULL on update CURRENT_TIMESTAMP,\n PRIMARY KEY (`campaignid`,`phonenumber`),\n KEY `status` (`campaignid`,`status`),\n KEY `status2` (`status`)\n )"; $result = mysqli_query($link, $sql, $link); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Created number_done Table')"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== queue Table ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "queue")) { include "admin/db_config.php"; $sql = "CREATE TABLE `queue` (\n `queueID` int(11) NOT NULL auto_increment,\n `queuename` varchar(100) default NULL,\n `status` tinyint(4) NOT NULL default '0',\n `campaignID` int(11) NOT NULL default '0',\n `details` varchar(250) default NULL,\n `flags` int(11) NOT NULL default '0',\n `transferclid` varchar(20) default '0',\n `starttime` time default NULL,\n `endtime` time default NULL,\n `startdate` date default NULL,\n `enddate` date default NULL,\n `did` varchar(20) default NULL,\n `clid` varchar(20) default NULL,\n `context` int(1) NOT NULL default '0',\n `maxcalls` int(11) default '100',\n `maxchans` int(11) default '100',\n `maxretries` int(11) default '0',\n `retrytime` int(11) default '30',\n `waittime` int(11) default '30',\n `timespent` varchar(20) default '0',\n `progress` varchar(20) default '0',\n `expectedRate` float NOT NULL default '100',\n `mode` varchar(120) default '0',\n `astqueuename` varchar(20) default '',\n `trunk` varchar(255) default 'Local/s@\${EXTEN}',\n `accountcode` varchar(255) default 'noaccount',\n `trunkid` int(11) default '-1',\n `customerID` int(11) default '-1',\n `maxcps` int(11) default '31',\n PRIMARY KEY (`queueID`)\n ) "; $result = mysqli_query($link, $sql, $link); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Created queue Table')"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== campaignconfig Table ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "campaignconfig")) { include "admin/db_config.php"; $sql = "CREATE TABLE `campaignconfig` (\n `id` int(10) unsigned NOT NULL auto_increment,\n `type` int(11) default '0',\n `astqueuename` varchar(255) default NULL,\n `did` varchar(255) default NULL,\n `clid` varchar(255) default NULL,\n `trclid` varchar(255) default NULL,\n `maxchans` int(11) default '10',\n `numagents` int(11) default '10',\n PRIMARY KEY (`id`)\n ) "; $result = mysqli_query($link, $sql, $link); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Created campaignconfig Table')"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== Billing Table ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "billing")) { include "admin/db_config.php"; $sql = "CREATE TABLE `billing` (\n `customerid` int(11) unsigned NOT NULL default '0',\n `accountcode` varchar(250) NOT NULL default '',\n `priceperminute` double(10,5) default '0.00000',\n `firstperiod` int(10) unsigned default '1',\n `increment` int(10) unsigned default '1',\n `credit` double(100,10) default '0.0000000000',\n `pricepercall` double(10,5) default '0.00000',\n `priceperconnectedcall` double(10,5) default '0.00000',\n `priceperpress1` double(10,5) default '0.00000',\n `creditlimit` double(100,10) default '0.0000000000',\n PRIMARY KEY (`customerid`,`accountcode`)\n )"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== Billing Log Table ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "billinglog")) { include "admin/db_config.php"; $sql = "CREATE TABLE `billinglog` (\n `timestamp` timestamp NULL default NULL on update CURRENT_TIMESTAMP,\n `activity` varchar(255) default NULL,\n `receipt` varchar(255) default NULL,\n `paymentmode` varchar(255) default NULL,\n `username` varchar(255) default NULL,\n `addedby` varchar(255) default NULL\n )"; $result = mysqli_query($link, $sql, $link); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Created Billing Log Table')"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== Realtime SIP ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "sip_buddies")) { //echo "Not there"; include "admin/db_config.php"; $sql = "CREATE TABLE `sip_buddies` (\n `id` int(11) NOT NULL auto_increment,\n `name` varchar(80) NOT NULL default '',\n `accountcode` varchar(20) default NULL,\n `callerid` varchar(80) default NULL,\n `canreinvite` char(3) default 'no',\n `context` varchar(80) default 'internal',\n `dtmfmode` varchar(7) default 'rfc2833',\n `host` varchar(31) default 'dynamic',\n `language` char(2) default 'it',\n `nat` varchar(5) default 'yes',\n `port` varchar(5) default '5060',\n `qualify` char(3) default NULL,\n `secret` varchar(80) default NULL,\n `type` varchar(6) NOT NULL default 'friend',\n `username` varchar(80) NOT NULL default '',\n `disallow` varchar(100) default 'all',\n `allow` varchar(100) default 'gsm;ulaw;alaw',\n `regseconds` int(11) NOT NULL default '0',\n `ipaddr` varchar(150) NOT NULL default '',\n `regexten` varchar(80) NOT NULL default '',\n `cancallforward` char(3) default 'yes',\n `setvar` varchar(100) NOT NULL default '',\n `clientid` int(13) default NULL,\n `description` varchar(100) default NULL,\n `fullcontact` varchar(250) default NULL,\n `visible` varchar(11) default NULL,\n `isagent` tinyint(3) unsigned NOT NULL default '0',\n `regserver` varchar(250) default NULL,\n `email` varchar(250) default NULL,\n `lastname` varchar(250) default NULL,\n `firstname` varchar(250) default NULL,\n `country` varchar(250) default NULL,\n `hasaccount` int(11) default NULL,\n `dateadded` datetime default NULL,\n `transfer` varchar(250) default NULL,\n `lastms` varchar(250) default NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY `name` (`name`),\n KEY `name_2` (`name`)\n );"; $result = mysqli_query($link, $sql, $link) or die(mysql_error()); } /*====================================================================== Realtime IAX2 ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "iax_buddies")) { include "admin/db_config.php"; $sql = "CREATE TABLE `iax_buddies` (\n `id` int(10) unsigned NOT NULL auto_increment,\n `name` varchar(32) NOT NULL default '',\n `username` varchar(30) default NULL,\n `type` varchar(6) NOT NULL default 'friend',\n `secret` varchar(50) default NULL,\n `transfer` varchar(10) default 'mediaonly',\n `accountcode` varchar(100) default NULL,\n `callerid` varchar(100) default NULL,\n `context` varchar(100) default 'freevoip',\n `host` varchar(31) NOT NULL default 'dynamic',\n `language` varchar(5) default 'it',\n `mailbox` varchar(50) default NULL,\n `qualify` varchar(4) default '400',\n `disallow` varchar(100) default 'all',\n `allow` varchar(100) default 'gsm,ulaw,alaw',\n `ipaddr` varchar(15) default NULL,\n `port` int(11) default '0',\n `regseconds` int(11) default '0',\n `clientid` int(13) unsigned default NULL,\n `description` varchar(100) default NULL,\n `visible` varchar(11) default NULL,\n `encryption` varchar(40) default NULL,\n `auth` varchar(10) default NULL,\n `isagent` tinyint(3) unsigned NOT NULL default '0',\n `firstname` varchar(255) default NULL,\n `lastname` varchar(255) default NULL,\n `email` varchar(255) default NULL,\n `country` varchar(255) default NULL,\n `hasaccount` int(11) default NULL,\n `dateadded` datetime default NULL,\n `trunk` char(3) default 'no',\n `sendmail` int(3) default '1',\n `regcontext` varchar(60) default 'iaxregs',\n `jitterbuffer` varchar(4) default 'no',\n PRIMARY KEY (`id`)\n );"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== Campaign ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "campaign")) { include "admin/db_config.php"; $sql = "Create table `campaign` (\n\t\t\t`id` int(200) NOT NULL auto_increment,\n\t\t\t`description` varchar(250) default NULL,\n\t\t\t`name` varchar(200) NOT NULL default '',\n\t\t\t`groupid` int(200) NOT NULL default '0',\n\t\t\t`messageid` int(200) NOT NULL default '0',\n\t\t\t`campaignconfigid` int(11) NOT NULL default '0',\n\t\t\t`messageid2` INT(200) NOT NULL unsigned default '0',\n\t\t\t`messageid3` INT(200) NOT NULL unsigned default '0',\n\t\t\t`astqueuename` VARCHAR(255) default NULL,\n\t\t\t`mode` INT(11) default '0',\n\t\t\t`clid` varchar(255) default 'nocallerid <>',\n\t\t\t`trclid` varchar(255) default 'nocallerid',\n\t\t\t`maxagents` int(11) default '30',\n\t\t\t`did` varchar(255) default 'nodid',\n\t\t\t`context` varchar(255) default 'ls3',\n\t\t\t`cost` varchar(10) default NULL,\n\t\t\tPRIMARY KEY (`id`)\n\t\t\t);"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== Campaign Config ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "campaignconfig")) { include "admin/db_config.php"; $sql = "Create table `campaignconfig` (\n\t\t\t`id` int(10) unsigned not null auto_increment,\n\t\t\t`type` int (11) default '0',\n\t\t\t`astqueuename` varchar(255) default NULL,\n\t\t\t`did` varchar(255) default NULL,\n\t\t\t`clid` varchar(255) default NULL,\n\t\t\t`trclid` varchar(255) default NULL,\n\t\t\t`maxchans` int(11) default 10,\n\t\t\t`numagents` int(11) default 10,\n\t\t\tPRIMARY KEY(`id`)\n );"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== Campaign Message ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "campaignconfig")) { include "admin/db_config.php"; $sql = "Create table `campaignmessage` (\n `id` int(10) unsigned not null auto_increment,\n\t\t\t`filename` varchar(250) not null,\n\t\t\t`name` varchar(200) not null,\n\t\t\t`description` varchar(250) not null,\n\t\t\t`customer_id` int(11),\n\t\t\tprimary key(`id`)\n );"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== CDR ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "cdr")) { include "admin/db_config.php"; $sql = "Create table `cdr` (\n `calldate` datetime NOT NULL default '0000-00-00 00:00:00',\n `clid` varchar(80) NOT NULL default '',\n `src` varchar(80) NOT NULL default '',\n `dst` varchar(80) NOT NULL default '',\n `dcontext` varchar(80) NOT NULL default '',\n `channel` varchar(80) NOT NULL default '',\n `dstchannel` varchar(80) NOT NULL default '',\n `lastapp` varchar(80) NOT NULL default '',\n `lastdata` varchar(80) NOT NULL default '',\n `duration` int(11) NOT NULL default '0',\n `billsec` int(11) NOT NULL default '0',\n `disposition` varchar(45) NOT NULL default '',\n `amaflags` int(11) NOT NULL default '0',\n `accountcode` varchar(20) NOT NULL default '',\n `userfield` varchar(255) NOT NULL default '',\n `userfield2` varchar(255) NOT NULL default '',\n `userfield3` varchar(255) NOT NULL default '',\n `userfield4` varchar(255) NOT NULL default '',\n `userfield5` varchar(255) NOT NULL default '',\n KEY `calldate` (`calldate`),\n KEY `dst` (`dst`),\n KEY `accountcode` (`accountcode`)\n );"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== Config ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "config")) { include "admin/db_config.php"; $sql = "Create table `config` (\n `parameter` varchar(11) NOT NULL default '0',\n `value` varchar(110) NOT NULL\n );"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== Customer ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "customer")) { include "admin/db_config.php"; $sql = "Create table `customer` (\n `id` int(10) unsigned NOT NULL auto_increment,\n `username` varchar(30) NOT NULL default '',\n `password` varchar(200) NOT NULL default '',\n `campaigngroupid` int(10) unsigned NOT NULL default '0',\n `address1` varchar(250) default NULL,\n `address2` varchar(250) default NULL,\n `city` varchar(250) default NULL,\n `country` varchar(250) default NULL,\n `phone` varchar(250) default NULL,\n `email` varchar(250) default NULL,\n `fax` varchar(250) default NULL,\n `website` varchar(250) default NULL,\n `security` int(3) unsigned default '0',\n `company` varchar(250) default NULL,\n `trunkid` int(11) default '-1',\n `zip` varchar(25) default NULL,\n `state` varchar(250) default NULL,\n `maxcps` int(11) default '10',\n `maxchans` int(11) default '100',\n `adminlists` varchar(2555) default NULL,\n PRIMARY KEY (`id`)\n );"; $result = mysqli_query($link, $sql, $link); $result = mysqli_query($link, "INSERT INTO customer (`username`,`password`,`security`) VALUES ('admin'," . sha1("adminpass") . ",100)", $link); } /*====================================================================== DNC Number ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "dncnumber")) { include "admin/db_config.php"; $sql = "Create table `dncnumber` (\n `campaignid` int(200) NOT NULL default '0',\n `phonenumber` varchar(50) NOT NULL default '',\n `status` varchar(50) NOT NULL default '',\n `type` int(5) NOT NULL default '0',\n PRIMARY KEY (`campaignid`,`phonenumber`),\n KEY `test` (`phonenumber`,`campaignid`)\n );"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== Number ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "number")) { include "admin/db_config.php"; $sql = "Create table `number` (\n `campaignid` int(200) NOT NULL default '0',\n `phonenumber` varchar(50) NOT NULL default '',\n `status` varchar(50) NOT NULL default '',\n `type` int(5) NOT NULL default '0',\n `datetime` timestamp NULL default NULL on update CURRENT_TIMESTAMP,\n PRIMARY KEY (`campaignid`,`phonenumber`),\n KEY `test` (`phonenumber`,`campaignid`)\n KEY `status` (`campaignid`,`status`),\n KEY `status2` (`status`)\n );"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== Queue ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "queue")) { include "admin/db_config.php"; $sql = "Create table `queue` (\n `queueID` int(11) NOT NULL auto_increment,\n `queuename` varchar(100) default NULL,\n `status` tinyint(4) NOT NULL default '0',\n `campaignID` int(11) NOT NULL default '0',\n `details` varchar(250) default NULL,\n `flags` int(11) NOT NULL default '0',\n `transferclid` varchar(20) default '0',\n `starttime` time default NULL,\n `endtime` time default NULL,\n `startdate` date default NULL,\n `enddate` date default NULL,\n `did` varchar(20) default NULL,\n `clid` varchar(20) default NULL,\n `context` int(1) NOT NULL default '0',\n `maxcalls` int(11) default '100',\n `maxchans` int(11) default '100',\n `maxretries` int(11) default '0',\n `retrytime` int(11) default '30',\n `waittime` int(11) default '30',\n `timespent` varchar(20) default '0',\n `progress` varchar(20) default '0',\n `expectedRate` float NOT NULL default '100',\n `mode` varchar(120) default '0',\n `astqueuename` varchar(20) default '',\n `trunk` varchar(255) default 'Local/s@\${EXTEN}',\n `accountcode` varchar(255) default 'noaccount',\n `trunkid` int(11) default '-1',\n `customerID` int(11) default '-1',\n `maxcps` int(11) default '31',\n PRIMARY KEY (`queueID`)\n );"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== servers Table ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "servers")) { include "admin/db_config.php"; $sql = "CREATE TABLE `servers` (\n `id` int(11) NOT NULL auto_increment,\n `address` varchar(250) NOT NULL default '',\n `name` varchar(200) NOT NULL default '',\n `username` varchar(250) NOT NULL default '',\n `password` varchar(250) NOT NULL default '',\n `status` int(10) default '0',\n `readonly` int(10) default '0',\n PRIMARY KEY (`id`)\n )"; $result = mysqli_query($link, $sql, $link); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Created servers Table')"; $result = mysqli_query($link, $sql, $link); } $fields = mysql_list_fields('SineDialer', 'servers'); $columns = mysql_num_fields($fields); for ($i = 0; $i < $columns; $i++) { $field_array[] = mysql_field_name($fields, $i); } if (!in_array('readonly', $field_array)) { $result = mysqli_query($link, 'ALTER TABLE servers ADD readonly int(10)'); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Added server readonly field')"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== stage Table ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "stage")) { include "admin/db_config.php"; $sql = "CREATE TABLE `stage` (\n `id` int(10) unsigned NOT NULL auto_increment,\n `phonenumber` varchar(50) NOT NULL default '',\n `stage` int(3) NOT NULL default '0',\n `campaignid` int(3) NOT NULL default '0',\n `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n PRIMARY KEY (`id`)\n ) "; $result = mysqli_query($link, $sql, $link); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Created stage Table')"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== trunk Table ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "trunk")) { include "admin/db_config.php"; $sql = "CREATE TABLE `trunk` (\n `id` int(15) unsigned NOT NULL auto_increment,\n `name` varchar(250) NOT NULL default '',\n `dialstring` varchar(250) NOT NULL default '',\n `current` int(1) NOT NULL default '0',\n `maxchans` int(11) unsigned default '100',\n `maxcps` varchar(255) default '30',\n PRIMARY KEY (`id`)\n ) "; $result = mysqli_query($link, $sql, $link); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Created trunk Table')"; $result = mysqli_query($link, $sql, $link); $sql = "insert into trunk values\n (1, 'Load Test', 'Local/s@staff/\${EXTEN}', 1, 300, '10'),\n (11, 'Local Hardware', 'Zap/g1/\${EXTEN}', 0, 10, '3'),\n (13, 'Dialplan', 'Local/\${EXTEN}@my_context', 0, 1000, '3'),\n (16, 'IAX2 Trunk', 'IAX2/my-provider/\${EXTEN}', 0, 100, '10'),\n (17, 'SIP Trunk', 'SIP/\${EXTEN}@my-provider', 0, 100, '5')"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== Queue_Member_Table ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "queue_member_table")) { include "admin/db_config.php"; $sql = "Create table `queue_member_table` (\n `uniqueid` int(10) unsigned NOT NULL auto_increment,\n `membername` varchar(40) default NULL,\n `queue_name` varchar(128) default NULL,\n `interface` varchar(128) default NULL,\n `penalty` int(11) default NULL,\n `paused` tinyint(1) default NULL,\n PRIMARY KEY (`uniqueid`),\n UNIQUE KEY `queue_interface` (`queue_name`,`interface`)\n );"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== Queue_Table ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "queue_table")) { include "admin/db_config.php"; $sql = "Create table `queue_table` (\n `name` varchar(128) NOT NULL,\n `musiconhold` varchar(128) default 'default',\n `announce` varchar(128) default NULL,\n `context` varchar(128) default NULL,\n `timeout` int(11) default NULL,\n `monitor_join` tinyint(1) default NULL,\n `monitor_format` varchar(128) default NULL,\n `queue_youarenext` varchar(128) default 'queue-youarenext',\n `queue_thereare` varchar(128) default 'queue-thereare',\n `queue_callswaiting` varchar(128) default 'queue-callswaiting',\n `queue_holdtime` varchar(128) default 'queue-holdtime',\n `queue_minutes` varchar(128) default 'queue-minutes',\n `queue_seconds` varchar(128) default 'queue-seconds',\n `queue_lessthan` varchar(128) default 'queue-less-than',\n `queue_thankyou` varchar(128) default 'queue-thankyou',\n `queue_reporthold` varchar(128) default NULL,\n `announce_frequency` int(11) default 0,\n `announce_round_seconds` int(11) default NULL,\n `announce_holdtime` varchar(128) default NULL,\n `retry` int(11) default NULL,\n `wrapuptime` int(11) default NULL,\n `maxlen` int(11) default NULL,\n `servicelevel` int(11) default NULL,\n `strategy` varchar(128) default NULL,\n `joinempty` varchar(128) default NULL,\n `leavewhenempty` varchar(128) default NULL,\n `eventmemberstatus` tinyint(1) default NULL,\n `eventwhencalled` tinyint(1) default NULL,\n `reportholdtime` tinyint(1) default NULL,\n `memberdelay` int(11) default NULL,\n `weight` int(11) default NULL,\n `timeoutrestart` tinyint(1) default NULL,\n `periodic_announce` varchar(50) default NULL,\n `periodic_announce_frequency` int(11) default NULL,\n PRIMARY KEY (`name`)\n );"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== Servers ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "servers")) { include "admin/db_config.php"; $sql = "Create table `servers` (\n `id` int(10) unsigned NOT NULL auto_increment,\n `phonenumber` varchar(50) NOT NULL default '',\n `stage` int(3) NOT NULL default '0',\n `campaignid` int(3) NOT NULL default '0',\n `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n PRIMARY KEY (`id`)\n );"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== Stage ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "stage")) { include "admin/db_config.php"; $sql = "Create table `stage` (\n `id` int(10) unsigned NOT NULL auto_increment,\n `phonenumber` varchar(50) NOT NULL default '',\n `stage` int(3) NOT NULL default '0',\n `campaignid` int(3) NOT NULL default '0',\n `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n PRIMARY KEY (`id`)\n );"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== Trunk ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "trunk")) { include "admin/db_config.php"; $sql = "Create table `trunk` (\n `id` int(15) unsigned NOT NULL auto_increment,\n `name` varchar(250) NOT NULL default '',\n `dialstring` varchar(250) NOT NULL default '',\n `current` int(1) NOT NULL default '0',\n `maxchans` int(11) unsigned default '100',\n `maxcps` varchar(255) default '30',\n PRIMARY KEY (`id`)\n );"; $result = mysqli_query($link, $sql, $link); } $fields = mysql_list_fields('SineDialer', 'campaign', $link); $columns = mysql_num_fields($fields); for ($i = 0; $i < $columns; $i++) { $field_array[] = mysql_field_name($fields, $i); } if (!in_array('cost', $field_array)) { $result = mysqli_query($link, 'ALTER TABLE campaign ADD cost VARCHAR(10)'); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Added campaign cost field')"; $result = mysqli_query($link, $sql, $link); } /***************************************************************** * ALTER customer TABLE TO ADD astqueuename FIELD * ******************************************************************/ unset($field_array); $fields = mysql_list_fields('SineDialer', 'customer', $link); $columns = mysql_num_fields($fields); for ($i = 0; $i < $columns; $i++) { $field_array[] = mysql_field_name($fields, $i); } if (!in_array('astqueuename', $field_array)) { $result = mysqli_query($link, 'ALTER TABLE customer ADD astqueuename VARCHAR(255)'); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Added customer astqueuename field')"; $result = mysqli_query($link, $sql, $link); } /***************************************************************** * ALTER sip_buddies TABLE TO ADD call-limit FIELD * ******************************************************************/ unset($field_array); $fields = mysql_list_fields('SineDialer', 'sip_buddies', $link); $columns = mysql_num_fields($fields); for ($i = 0; $i < $columns; $i++) { $field_array[] = mysql_field_name($fields, $i); } if (!in_array('call-limit', $field_array)) { $result = mysqli_query($link, 'ALTER TABLE sip_buddies ADD `call-limit` int(8) default 1') or die(mysql_error()); $result = mysqli_query($link, 'UPDATE sip_buddies SET `call-limit`=1') or die(mysql_error()); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Added sip_buddies call-limit field')"; $result = mysqli_query($link, $sql, $link); } /*====================================================================== Stats Only Users ======================================================================*/ if (!mysqli_is_table($db_host, $db_user, $db_pass, "SineDialer", "statuser")) { include "admin/db_config.php"; $sql = "Create table `statuser` (\n `id` int(10) unsigned NOT NULL auto_increment,\n `campaignid` int(3) NOT NULL default '0',\n `hash` varchar(255) NOT NULL default '',\n PRIMARY KEY (`id`)\n );"; $result = mysqli_query($link, $sql, $link); } /***************************************************************** * ALTER customer TABLE TO ADD didlogin FIELD * ******************************************************************/ unset($field_array); $fields = mysql_list_fields('SineDialer', 'customer', $link); $columns = mysql_num_fields($fields); for ($i = 0; $i < $columns; $i++) { $field_array[] = mysql_field_name($fields, $i); } if (!in_array('didlogin', $field_array)) { $result = mysqli_query($link, 'ALTER TABLE customer ADD didlogin VARCHAR(255)'); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Added customer didlogin field')"; $result = mysqli_query($link, $sql, $link); } /***************************************************************** * ALTER MESSAGE TABLE TO ADD length FIELD * ******************************************************************/ unset($field_array); $fields = mysql_list_fields('SineDialer', 'campaignmessage', $link); $columns = mysql_num_fields($fields); for ($i = 0; $i < $columns; $i++) { $field_array[] = mysql_field_name($fields, $i); } if (!in_array('length', $field_array)) { $result = mysqli_query($link, 'ALTER TABLE campaignmessage ADD length VARCHAR(255)'); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Added campaignmessage length field')"; $result = mysqli_query($link, $sql, $link); } /***************************************************************** * ALTER BILLING TABLE TO ADD receipt FIELD * ******************************************************************/ unset($field_array); $fields = mysql_list_fields('SineDialer', 'billinglog', $link); $columns = mysql_num_fields($fields); for ($i = 0; $i < $columns; $i++) { $field_array[] = mysql_field_name($fields, $i); } if (!in_array('receipt', $field_array)) { $result = mysqli_query($link, 'ALTER TABLE billinglog ADD receipt VARCHAR(255)'); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Added billinglog receipt field')"; $result = mysqli_query($link, $sql, $link); } if (!in_array('paymentmode', $field_array)) { $result = mysqli_query($link, 'ALTER TABLE billinglog ADD paymentmode VARCHAR(255)'); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Added billinglog paymentmode field')"; $result = mysqli_query($link, $sql, $link); } /***************************************************************** * ALTER SIP_BUDDIES TABLE TO ADD lastms FIELD * ******************************************************************/ unset($field_array); $fields = mysql_list_fields('SineDialer', 'sip_buddies', $link); $columns = mysql_num_fields($fields); for ($i = 0; $i < $columns; $i++) { $field_array[] = mysql_field_name($fields, $i); } if (!in_array('lastms', $field_array)) { $result = mysqli_query($link, 'ALTER TABLE sip_buddies ADD lastms VARCHAR(255)'); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Added sip_buddies lastms field')"; $result = mysqli_query($link, $sql, $link); } /***************************************************************** * ALTER CUSTOMER TABLE TO ADD interface_type FIELD * ******************************************************************/ unset($field_array); $fields = mysql_list_fields('SineDialer', 'customer', $link); $columns = mysql_num_fields($fields); for ($i = 0; $i < $columns; $i++) { $field_array[] = mysql_field_name($fields, $i); } if (!in_array('interface_type', $field_array)) { $result = mysqli_query($link, 'ALTER TABLE customer ADD interface_type VARCHAR(255) default \'default\''); $sql = "INSERT INTO log (timestamp, username, activity) VALUES (NOW(), '{$_POST['user']}', 'Added customer.interface_type field')"; $result = mysqli_query($link, $sql, $link) or die(mysql_error()); } }