Exemple #1
0
function alterTableStructure(&$returnList, &$command, $num)
{
    global $conn, $var_host, $var_user, $var_password, $var_database;
    $sql = "DROP TABLE IF EXISTS `sptbl_chat`";
    mysql_query($sql, $conn) or die("Cannot remove chat table.");
    $sql = "DROP TABLE IF EXISTS `sptbl_operatorchat`";
    mysql_query($sql, $conn) or die("Cannot remove operatorchat table.");
    $sql = "DROP TABLE IF EXISTS `sptbl_cannedmessages`";
    mysql_query($sql, $conn) or die("Cannot remove cannedmessages table.");
    $sql = "DROP TABLE IF EXISTS `sptbl_chattransfer`";
    mysql_query($sql, $conn) or die("Cannot remove chattransfer table.");
    $sql = "DROP TABLE IF EXISTS `sptbl_visitors`";
    mysql_query($sql, $conn) or die("Cannot remove visitors table.");
    $sql = "DROP TABLE IF EXISTS `sptbl_desktop_share`";
    mysql_query($sql, $conn) or die("Cannot remove desktop_share table.");
    $sql = "CREATE TABLE sptbl_chat(nChatId bigint(20) NOT NULL auto_increment, dTimeStart datetime default '0000-00-00 00:00:00',nUserId bigint(20) default '0', vUserName varchar(100),nStaffId bigint(20) NOT NULL default '0',tMatter text default '',dTimeEnd datetime NOT NULL default '0000-00-00 00:00:00',vStatus varchar(10), vNewMsg char(1)  NOT NULL default '1',  nDeptId bigint(20), PRIMARY KEY (nChatId))  TYPE=MyISAM";
    mysql_query($sql, $conn) or die("Cannot create table sptbl_chat.");
    $sql = "CREATE TABLE sptbl_operatorchat(nChatId bigint(20) NOT NULL auto_increment, dTimeStart datetime default '0000-00-00 00:00:00',nFirstStaffId bigint(20) default '0',nSecondStaffId bigint(20) NOT NULL default '0',tMatter text default '',dTimeEnd datetime NOT NULL default '0000-00-00 00:00:00',vStatus varchar(10), vNewMsg char(1)  NOT NULL default '1',  vChatSts char(1), PRIMARY KEY (nChatId)) TYPE=MyISAM";
    mysql_query($sql, $conn) or die("Cannot create table sptbl_operatorchat.");
    $sql = "CREATE TABLE sptbl_cannedmessages(nMsgId int(11) NOT NULL auto_increment, dDate date default '0000-00-00', vTitle varchar(100), vDescription varchar(250), nStaffId bigint(20), vStatus char(1) default '0', PRIMARY KEY (nMsgId)) TYPE=MyISAM";
    mysql_query($sql, $conn) or die("Cannot create table sptbl_cannedmessages.");
    $sql = "CREATE TABLE sptbl_chattransfer(nTransferId bigint(20) NOT NULL auto_increment, cChatId bigint(20) NOT NULL default '0', nFirstStaff bigint(20) NOT NULL default '0', nSecondStaff bigint(20) NOT NULL default '0', vStatus varchar(10), PRIMARY KEY (nTransferId)) TYPE=MyISAM";
    mysql_query($sql, $conn) or die("Cannot create table sptbl_chattransfer.");
    $sql = "CREATE TABLE sptbl_visitors (nVisitingId BIGINT( 20 ) NOT NULL auto_increment, nCompId BIGINT( 20 ) , vIpAddr  VARCHAR( 25 ) , vPage  VARCHAR( 128 ) , vStatus  VARCHAR( 10 ), dVisitTime  datetime, dLastUpdTime  datetime ,  PRIMARY KEY (nVisitingId)) TYPE = MYISAM";
    mysql_query($sql, $conn) or die("Cannot create table sptbl_visitors.");
    $sql = "CREATE TABLE sptbl_desktop_share (nShareId  BIGINT( 20 ) NOT NULL auto_increment, nChatId BIGINT( 20 ), vClientIp varchar(25), vStatus  varchar(15),  PRIMARY KEY (nShareId)) TYPE = MYISAM";
    mysql_query($sql, $conn) or die("Cannot create table sptbl_desktop_share.");
    if (checkDBUpdate("sptbl_staffs", "vStaffImg") == false) {
        $sql = "ALTER TABLE `sptbl_staffs` ADD `vStaffImg` VARCHAR( 128 )";
        mysql_query($sql, $conn) or die("Cannot alter staffs table.");
    }
    if (checkDBUpdate("sptbl_companies", "vChatWelcomeMessage") == false) {
        $sql = "ALTER TABLE `sptbl_companies` ADD `vChatWelcomeMessage` VARCHAR( 128 ) default 'Welcome'";
        mysql_query($sql, $conn) or die("Cannot alter companies table.");
    }
    if (checkDBUpdate("sptbl_companies", "vChatIcon") == false) {
        $sql = "ALTER TABLE `sptbl_companies` ADD `vChatIcon`  CHAR( 1 ) default '1'";
        mysql_query($sql, $conn) or die("Cannot alter companies table.");
    }
    if (checkDBUpdate("sptbl_companies", "vChatOperatorRating") == false) {
        $sql = "ALTER TABLE `sptbl_companies` ADD `vChatOperatorRating` CHAR( 1 ) default '0'";
        mysql_query($sql, $conn) or die("Cannot alter companies table.");
    }
    if (checkDBUpdate("sptbl_staffratings", "vType") == false) {
        $sql = "ALTER TABLE `sptbl_staffratings` ADD `vType` CHAR( 1 ) default 'T'";
        mysql_query($sql, $conn) or die("Cannot alter staffratings table.");
    }
    $sql = "Insert Into sptbl_lookup(vLookUpName,vLookUpValue) values('LiveChat','1')";
    mysql_query($sql, $conn) or die("Cannot update lookup values.");
    $returnList = "Database synchronization complete!";
    $command = "";
    return true;
}
Exemple #2
0
function alterTableStructure(&$returnList, &$command, $num)
{
    global $conn, $var_host, $var_user, $var_password, $var_database;
    $hdurl = "";
    if ($_SERVER["HTTPS"] == 'on') {
        $hdurl = "https://";
    } else {
        $hdurl = "http://";
    }
    $hdurl .= $_SERVER['HTTP_HOST'];
    $var_installurl = $_SERVER['PHP_SELF'];
    $arr_installurl = explode("/", $var_installurl);
    $cnt = count($arr_installurl) - 2;
    $hdurl .= "/";
    for ($i = 1; $i < $cnt; $i++) {
        $hdurl .= $arr_installurl[$i] . "/";
    }
    $emailurl = $hdurl;
    $filename = "../api/useradd.php";
    $handle = @fopen($filename, "rb");
    $contents = @fread($handle, filesize($filename));
    @fclose($handle);
    $str_write = "<?php \r\n\$" . "glb_dbhost_1=\"" . $var_host . "\";\r\n";
    $str_write .= "\$" . "glb_dbuser_1=\"" . $var_user . "\";\r\n";
    $str_write .= "\$" . "glb_dbpass_1=\"" . $var_password . "\";\r\n";
    $str_write .= "\$" . "glb_dbname_1=\"" . $var_database . "\";\r\n ";
    $str_write .= $contents;
    $fp = @fopen("../api/useradd.php", "w");
    @fputs($fp, "{$str_write}");
    @fclose($fp);
    $str_write = "\r\n" . "function xml_server() {\r\n";
    $str_write .= "\$" . "this->users_tag = \"\";\r\n";
    $str_write .= "\$" . "this->function_tag = \"\";\r\n";
    $str_write .= "\$" . "this->values_tag = \"\";\r\n";
    $str_write .= "\$" . "this->username_tag = \"\";\r\n";
    $str_write .= "\$" . "this->password_tag = \"\";\r\n";
    $str_write .= "\$" . "this->email_tag = \"\";\r\n";
    $str_write .= "\$" . "this->company_tag = \"\";\r\n";
    $str_write .= "\$" . "this->errno = \"0\";\r\n";
    $str_write .= "\$" . "this->conapi = mysql_connect(\"" . $var_host . "\",\"" . $var_user . "\",\"" . $var_password . "\") or die(mysql_error());\r\n";
    $str_write .= "mysql_select_db(\"" . $var_database . "\",\$" . "this->conapi) or die(mysql_error());\r\n}\r\n}\r\n?>";
    $fp = @fopen("../api/server_class.php", "a+");
    @fputs($fp, "{$str_write}");
    @fclose($fp);
    $sql = "DROP TABLE IF EXISTS `sptbl_css`";
    mysql_query($sql, $conn) or die("Cannot remove css table.");
    $sql = "DROP TABLE IF EXISTS `sptbl_labels`";
    mysql_query($sql, $conn) or die("Cannot remove css table.");
    $sql = "DROP TABLE IF EXISTS `sptbl_pop3settings`";
    mysql_query($sql, $conn) or die("Cannot remove css table.");
    $sql = "DROP TABLE IF EXISTS `sptbl_rules`";
    mysql_query($sql, $conn) or die("Cannot remove css table.");
    $sql = "DROP TABLE IF EXISTS `sptbl_spam_categories`";
    mysql_query($sql, $conn) or die("Cannot remove css table.");
    $sql = "DROP TABLE IF EXISTS `sptbl_spam_references`";
    mysql_query($sql, $conn) or die("Cannot remove css table.");
    $sql = "DROP TABLE IF EXISTS `sptbl_spam_tickets`";
    mysql_query($sql, $conn) or die("Cannot remove css table.");
    $sql = "DROP TABLE IF EXISTS `sptbl_spam_wordfreqs`";
    mysql_query($sql, $conn) or die("Cannot remove css table.");
    /*suppportdesk4 modifications starts*/
    $sql = "DROP TABLE IF EXISTS `sptbl_chat`";
    mysql_query($sql, $conn) or die("Cannot remove chat table.");
    $sql = "DROP TABLE IF EXISTS `sptbl_operatorchat`";
    mysql_query($sql, $conn) or die("Cannot remove operatorchat table.");
    $sql = "DROP TABLE IF EXISTS `sptbl_cannedmessages`";
    mysql_query($sql, $conn) or die("Cannot remove cannedmessages table.");
    $sql = "DROP TABLE IF EXISTS `sptbl_chattransfer`";
    mysql_query($sql, $conn) or die("Cannot remove chattransfer table.");
    $sql = "DROP TABLE IF EXISTS `sptbl_visitors`";
    mysql_query($sql, $conn) or die("Cannot remove visitors table.");
    $sql = "DROP TABLE IF EXISTS `sptbl_desktop_share`";
    mysql_query($sql, $conn) or die("Cannot remove desktop_share table.");
    /*suppportdesk4 modifications ends*/
    $sql = "CREATE TABLE sptbl_css(nCSSId bigint(20) NOT NULL auto_increment,vCSSName varchar(50) default NULL,vCSSURL text NOT NULL,dDate datetime NOT NULL default '0000-00-00 00:00:00',PRIMARY KEY  (nCSSId)) TYPE=MyISAM";
    mysql_query($sql, $conn) or die("Cannot create table css.");
    $sql = "CREATE TABLE sptbl_labels(nLabelId bigint(20) NOT NULL auto_increment,vLabelname varchar(100) default NULL,nStaffId bigint(20) default NULL,PRIMARY KEY  (nLabelId)) TYPE=MyISAM";
    mysql_query($sql, $conn) or die("Cannot create table labels.");
    $sql = "CREATE TABLE sptbl_pop3settings(nPop3Id bigint(20) NOT NULL auto_increment,nDeptId bigint(20) NOT NULL default '0',vDeptEmail varchar(100) NOT NULL default '',vServerName varchar(200) NOT NULL default '',vUserName varchar(100) NOT NULL default '',vPassword varchar(100) NOT NULL default '',nPortNo bigint(10) NOT NULL default '0', PRIMARY KEY  (nPop3Id)) TYPE=MyISAM";
    mysql_query($sql, $conn) or die("Cannot create table pop3settings.");
    $sql = "CREATE TABLE sptbl_rules(nRuleId bigint(20) NOT NULL auto_increment,vRuleName varchar(100) NOT NULL default '',nSearchTitle tinyint(4) NOT NULL default '0', nSearchBody tinyint(4) NOT NULL default '0',vSearchWords text NOT NULL,nStaffId bigint(20) NOT NULL default '0',nDeptId bigint(20) NOT NULL default '0',dDateCreated date NOT NULL default '0000-00-00',PRIMARY KEY  (nRuleId)) TYPE=MyISAM";
    mysql_query($sql, $conn) or die("Cannot create table rules.");
    $sql = "CREATE TABLE sptbl_spam_categories(category_id varchar(250) NOT NULL default '',probability double NOT NULL default '0',word_count bigint(20) NOT NULL default '0',PRIMARY KEY  (category_id)) TYPE=MyISAM";
    mysql_query($sql, $conn) or die("Cannot create table spam_categories.");
    $sql = "CREATE TABLE sptbl_spam_references(id varchar(250) NOT NULL default '',category_id varchar(250) NOT NULL default '', content text NOT NULL, PRIMARY KEY  (id),KEY category_id (category_id)) TYPE=MyISAM";
    mysql_query($sql, $conn) or die("Cannot create table spam_references.");
    $sql = "CREATE TABLE sptbl_spam_tickets(nSpamTicketId bigint(20) NOT NULL auto_increment,vuseremail varchar(100) default NULL,nDeptId bigint(20) NOT NULL default '0', vTitle varchar(100) NOT NULL default '0', tQuestion mediumtext NOT NULL,dPostDate datetime NOT NULL default '0000-00-00 00:00:00',vMachineIP varchar(20) default '0.0.0.0',tcontent text,PRIMARY KEY  (nSpamTicketId)) TYPE=MyISAM";
    mysql_query($sql, $conn) or die("Cannot create table spam_tickets.");
    $sql = "CREATE TABLE sptbl_spam_wordfreqs(word varchar(250) NOT NULL default '',category_id varchar(250) NOT NULL default '',count bigint(20) NOT NULL default '0',PRIMARY KEY  (word,category_id),KEY categoryindex (category_id)) TYPE=MyISAM";
    mysql_query($sql, $conn) or die("Cannot create table spam_wordfreqs.");
    /*suppportdesk4 modifications starts*/
    $sql = "CREATE TABLE sptbl_chat(nChatId bigint(20) NOT NULL auto_increment, dTimeStart datetime default '0000-00-00 00:00:00',nUserId bigint(20) default '0',vUserName varchar(100),nStaffId bigint(20) NOT NULL default '0',tMatter text default '',dTimeEnd datetime NOT NULL default '0000-00-00 00:00:00',vStatus varchar(10), vNewMsg char(1)  NOT NULL default '1',  nDeptId bigint(20), PRIMARY KEY (nChatId))  TYPE=MyISAM";
    mysql_query($sql, $conn) or die("Cannot create table sptbl_chat.");
    $sql = "CREATE TABLE sptbl_operatorchat(nChatId bigint(20) NOT NULL auto_increment, dTimeStart datetime default '0000-00-00 00:00:00',nFirstStaffId bigint(20) default '0',nSecondStaffId bigint(20) NOT NULL default '0',tMatter text default '',dTimeEnd datetime NOT NULL default '0000-00-00 00:00:00',vStatus varchar(10), vNewMsg char(1)  NOT NULL default '1',  vChatSts char(1), PRIMARY KEY (nChatId)) TYPE=MyISAM";
    mysql_query($sql, $conn) or die("Cannot create table sptbl_operatorchat.");
    $sql = "CREATE TABLE sptbl_cannedmessages(nMsgId int(11) NOT NULL auto_increment, dDate date default '0000-00-00', vTitle varchar(100), vDescription varchar(250), nStaffId bigint(20), vStatus char(1) default '0', PRIMARY KEY (nMsgId)) TYPE=MyISAM";
    mysql_query($sql, $conn) or die("Cannot create table sptbl_cannedmessages.");
    $sql = "CREATE TABLE sptbl_chattransfer(nTransferId bigint(20) NOT NULL auto_increment, nChatId bigint(20) NOT NULL default '0', nFirstStaff bigint(20) NOT NULL default '0', nSecondStaff bigint(20) NOT NULL default '0', vStatus varchar(10), PRIMARY KEY (nTransferId)) TYPE=MyISAM";
    mysql_query($sql, $conn) or die("Cannot create table sptbl_chattransfer.");
    $sql = "CREATE TABLE sptbl_visitors (nVisitingId BIGINT( 20 ) NOT NULL auto_increment, nCompId BIGINT( 20 ) , vIpAddr  VARCHAR( 25 ) , vPage  VARCHAR( 128 ) , vStatus  VARCHAR( 10 ), dVisitTime  datetime, dLastUpdTime  datetime ,  PRIMARY KEY (nVisitingId)) TYPE = MYISAM";
    mysql_query($sql, $conn) or die("Cannot create table sptbl_visitors.");
    $sql = "CREATE TABLE sptbl_desktop_share (nShareId  BIGINT( 20 ) NOT NULL auto_increment, nChatId BIGINT( 20 ), vClientIp varchar(25), vStatus  varchar(15),  PRIMARY KEY (nShareId)) TYPE = MYISAM";
    mysql_query($sql, $conn) or die("Cannot create table sptbl_desktop_share.");
    /*suppportdesk4 modifications ends*/
    $sql = "Insert Into sptbl_lookup(vLookUpName,vLookUpValue) values('UserAuthenticate','1')";
    mysql_query($sql, $conn) or die("Cannot update lookup values.");
    $sql = "Insert Into sptbl_lookup(vLookUpName,vLookUpValue) values('PostTicketBeforeLogin','1')";
    mysql_query($sql, $conn) or die("Cannot update lookup values.");
    $sql = "Insert Into sptbl_lookup(vLookUpName,vLookUpValue) values('spamfiltertype','OFF')";
    mysql_query($sql, $conn) or die("Cannot update lookup values.");
    $sql = "Insert Into sptbl_lookup(vLookUpName,vLookUpValue) values('MessageRule','0')";
    mysql_query($sql, $conn) or die("Cannot update lookup values.");
    $sql = "Insert Into sptbl_lookup(vLookUpName,vLookUpValue) values('SMTPSettings','0')";
    mysql_query($sql, $conn) or die("Cannot update lookup values.");
    $sql = "Insert Into sptbl_lookup(vLookUpName,vLookUpValue) values('SMTPServer','')";
    mysql_query($sql, $conn) or die("Cannot update lookup values.");
    $sql = "Insert Into sptbl_lookup(vLookUpName,vLookUpValue) values('SMTPPort','0')";
    mysql_query($sql, $conn) or die("Cannot update lookup values.");
    $sql = "Insert Into sptbl_lookup(vLookUpName,vLookUpValue) values('UserAuthenticate','1')";
    mysql_query($sql, $conn) or die("Cannot update lookup values.");
    $sql = "Insert Into sptbl_lookup(vLookUpName,vLookUpValue) values('EmailURL','{$emailurl}')";
    mysql_query($sql, $conn) or die("Cannot update lookup values.");
    $sql = "Insert Into sptbl_spam_categories(category_id,probability,word_count) values('spam',0.887777777778, 799)";
    mysql_query($sql, $conn) or die("Cannot update spam_categories table.");
    $sql = "Insert Into sptbl_spam_categories(category_id,probability,word_count) values('notspam',0.112222222222, 101)";
    mysql_query($sql, $conn) or die("Cannot update spam_categories table.");
    $sql = "Insert Into sptbl_lookup(vLookUpName,vLookUpValue) values('Attachments','txt|text/plain')";
    mysql_query($sql, $conn) or die("Cannot update lookup values.");
    $sql = "Insert Into sptbl_lookup(vLookUpName,vLookUpValue) values('Attachments','zip|application/x-zip')";
    mysql_query($sql, $conn) or die("Cannot update lookup values.");
    $sql = "Insert Into sptbl_lookup(vLookUpName,vLookUpValue) values('Attachments','html|text/html')";
    mysql_query($sql, $conn) or die("Cannot update lookup values.");
    $sql = "Insert Into sptbl_lookup(vLookUpName,vLookUpValue) values('Attachments','htm|text/html')";
    mysql_query($sql, $conn) or die("Cannot update lookup values.");
    $sql = "Insert Into sptbl_lookup(vLookUpName,vLookUpValue) values('Attachments','doc|application/msword')";
    mysql_query($sql, $conn) or die("Cannot update lookup values.");
    $sql = "Insert Into sptbl_lookup(vLookUpName,vLookUpValue) values('Attachments','crt|application/x-x509-ca-cert')";
    mysql_query($sql, $conn) or die("Cannot update lookup values.");
    $sql = "Insert Into sptbl_lookup(vLookUpName,vLookUpValue) values('Attachments','key|key|application/octet-stream')";
    mysql_query($sql, $conn) or die("Cannot update lookup values.");
    $sql = "Insert Into sptbl_lookup(vLookUpName,vLookUpValue) values('Attachments','csv|text/plain')";
    mysql_query($sql, $conn) or die("Cannot update lookup values.");
    $sql = "Insert Into sptbl_lookup(vLookUpName,vLookUpValue) values('Attachments','csv|application/octet-stream')";
    mysql_query($sql, $conn) or die("Cannot update lookup values.");
    /*suppportdesk4 modification starts*/
    $sql = "Insert Into sptbl_lookup(vLookUpName,vLookUpValue) values('LiveChat','1')";
    mysql_query($sql, $conn) or die("Cannot update lookup values.");
    /*suppportdesk4 modification starts*/
    $sql = "insert INTO sptbl_css VALUES (1,'Cool Green','styles/coolgreen.css','2006-01-02 11:22:57')";
    mysql_query($sql, $conn) or die("Cannot update css table.");
    $sql = "insert INTO sptbl_css VALUES (2,'Maroon','styles/meroon.css','2006-02-16 14:21:50')";
    mysql_query($sql, $conn) or die("Cannot update css table.");
    $sql = "insert INTO sptbl_css VALUES (3,'Aqua Blue','styles/aquablue.css','2006-05-16 14:21:50')";
    mysql_query($sql, $conn) or die("Cannot update css table.");
    $sql = "Update sptbl_lookup set vLookUpValue='en' where vLookUpName='DefaultLang'";
    mysql_query($sql, $conn) or die("Cannot update lookup values.");
    $sql = "Update sptbl_users set nCSSId='1'";
    mysql_query($sql, $conn) or die("Cannot update user master.");
    $sql = "Update sptbl_staffs set nCSSId='1'";
    mysql_query($sql, $conn) or die("Cannot update staff master.");
    if (checkDBUpdate("sptbl_staffs", "nWatcher") == false) {
        $sql = "ALTER TABLE `sptbl_staffs` ADD `nWatcher` TINYINT( 4 ) NOT NULL default '0' AFTER `tSignature`";
        mysql_query($sql, $conn) or die("Cannot alter staffs table.");
    }
    if (checkDBUpdate("sptbl_tickets", "nLabelId") == false) {
        $sql = "ALTER TABLE `sptbl_tickets` ADD `nLabelId` BIGINT( 20 ) NOT NULL default '0' AFTER `dLastAttempted`";
        mysql_query($sql, $conn) or die("Cannot update tickets table.");
    }
    /*suppportdesk4 modifications starts*/
    if (checkDBUpdate("sptbl_staffs", "vStaffImg") == false) {
        $sql = "ALTER TABLE `sptbl_staffs` ADD `vStaffImg` VARCHAR( 128 )";
        mysql_query($sql, $conn) or die("Cannot alter staffs table.");
    }
    if (checkDBUpdate("sptbl_companies", "vChatWelcomeMessage") == false) {
        $sql = "ALTER TABLE `sptbl_companies` ADD `vChatWelcomeMessage` VARCHAR( 128 ) default 'Welcome'";
        mysql_query($sql, $conn) or die("Cannot alter companies table.");
    }
    if (checkDBUpdate("sptbl_companies", "vChatIcon") == false) {
        $sql = "ALTER TABLE `sptbl_companies` ADD `vChatIcon`  CHAR( 1 ) default '1'";
        mysql_query($sql, $conn) or die("Cannot alter companies table.");
    }
    if (checkDBUpdate("sptbl_companies", "vChatOperatorRating") == false) {
        $sql = "ALTER TABLE `sptbl_companies` ADD `vChatOperatorRating` CHAR( 1 ) default '0'";
        mysql_query($sql, $conn) or die("Cannot alter companies table.");
    }
    if (checkDBUpdate("sptbl_staffratings", "vType") == false) {
        $sql = "ALTER TABLE `sptbl_staffratings` ADD `vType` CHAR( 1 ) default 'T'";
        mysql_query($sql, $conn) or die("Cannot alter staffratings table.");
    }
    /*suppportdesk4 modifications ends*/
    $returnList = "Database synchronization complete!";
    $command = "";
    return true;
}