public function CheckTables($table = null, $force = false) { if (isset($GLOBALS[__CLASS__]["FAILED"])) { writelogs("Global connection is failed, aborting", __FUNCTION__, __FILE__, __LINE__); $this->ok = false; return false; } $md5 = md5("CheckTables({$table})"); if (isset($GLOBALS[$md5])) { return; } $GLOBALS[$md5] = true; if ($this->EnableRemoteStatisticsAppliance == 1) { return; } if (!$force) { if ($GLOBALS["AS_ROOT"]) { if (!$GLOBALS["VERBOSE"]) { if (!class_exists("unix")) { include_once "/usr/share/artica-postfix/framework/class.unix.inc"; } $unix = new unix(); $timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time"; $XT_TIME = $this->file_time_min($timefile); if ($XT_TIME < 30) { return true; } @unlink($timefile); @file_put_contents($timefile, time()); $this->ToSyslog("Verify MySQL Tables ( as root) for database {$this->database} last check since {$XT_TIME}Mn"); } } if (!$GLOBALS["AS_ROOT"]) { if (!$GLOBALS["VERBOSE"]) { $timefile = "/usr/share/artica-postfix/ressources/logs/web/" . basename(__FILE__) . ".time"; $XT_TIME = $this->file_time_min($timefile); if ($XT_TIME < 30) { return true; } $this->ToSyslog("Verify MySQL Tables ( as {$_SESSION["uid"]} ) for database {$this->database} last check since {$XT_TIME}Mn"); @unlink($timefile); @file_put_contents($timefile, time()); } } } if (!$this->DATABASE_EXISTS($this->database)) { $this->CREATE_DATABASE($this->database); } if (isset($GLOBALS[__CLASS__]["FAILED"])) { return; } $this->CreateWeekTable(); $this->create_webfilters_categories_caches(); if ($this->TABLE_EXISTS("category_teans")) { if (!$this->TABLE_EXISTS("category_teens")) { $this->QUERY_SQL("RENAME TABLE `category_teans` TO `category_teens`"); } } if ($this->TABLE_EXISTS("webfilters_schedules", $this->database)) { if (!$this->FIELD_EXISTS("webfilters_schedules", "Params", $this->database)) { $this->QUERY_SQL("ALTER TABLE `webfilters_schedules` ADD `Params` TEXT NOT NULL"); } } if ($table != null) { if (!$this->FIELD_EXISTS($table, "uid", $this->database)) { $sql = "ALTER TABLE `{$table}` ADD `uid` VARCHAR( 128 ) NOT NULL,ADD INDEX ( uid )"; if (!$this->ok) { writelogs("{$this->mysql_error}\n{$sql}", __CLASS__ . '/' . __FUNCTION__, __FILE__, __LINE__); $this->mysql_error = $this->mysql_error . "\n{$sql}"; } $this->QUERY_SQL($sql, $this->database); } } $sql = "CREATE TABLE IF NOT EXISTS `computers_time` (\n\t\t\t\t`MAC` VARCHAR( 90 ) NOT NULL,\n\t\t\t\t`ipaddr` VARCHAR( 90 ) NOT NULL,\n\t\t\t\t`enabled` SMALLINT(1) NOT NULL DEFAULT 0,\n\t\t\t\t`MONDAY_AM` VARCHAR( 90 ) NOT NULL,\n\t\t\t\t`MONDAY_PM` VARCHAR( 90 ) NOT NULL,\n\t\t\t\t\n\t\t\t\t`TUESDAY_AM` VARCHAR( 90 ) NOT NULL,\n\t\t\t\t`TUESDAY_PM` VARCHAR( 90 ) NOT NULL,\n\n\t\t\t\t`WEDNESDAY_AM` VARCHAR( 90 ) NOT NULL,\n\t\t\t\t`WEDNESDAY_PM` VARCHAR( 90 ) NOT NULL,\t\t\t\t\n\n\t\t\t\t`THURSDAY_AM` VARCHAR( 90 ) NOT NULL,\n\t\t\t\t`THURSDAY_PM` VARCHAR( 90 ) NOT NULL,\t\t\t\t\t\n\n\t\t\t\t`FRIDAY_AM` VARCHAR( 90 ) NOT NULL,\n\t\t\t\t`FRIDAY_PM` VARCHAR( 90 ) NOT NULL,\t\n\n\t\t\t\t`SATURDAY_AM` VARCHAR( 90 ) NOT NULL,\n\t\t\t\t`SATURDAY_PM` VARCHAR( 90 ) NOT NULL,\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t`SUNDAY_AM` VARCHAR( 90 ) NOT NULL,\n\t\t\t\t`SUNDAY_PM` VARCHAR( 90 ) NOT NULL,\t\t\t\t\n\t\t\t\t\n\t\t\t\t UNIQUE KEY `MAC` (`MAC`),\n\t\t\t\t KEY `enabled` (`enabled`)\n\t\t\t\t \n\t\t\t\t ) ENGINE = MYISAM;\n\t\t\t"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `dnsmasq_records` (\n\t\t\t\t`ID` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,\n\t\t\t\t`ipaddrton` BIGINT UNSIGNED,\n\t\t\t\t`ipaddr` VARCHAR( 90 ) NOT NULL,\n\t\t\t\t`hostname` VARCHAR(128),\n\t\t\t\t KEY `ipaddr` (`ipaddr`),\n\t\t\t\t KEY `ipaddrton` (`ipaddrton`),\n\t\t\t\t KEY `hostname` (`hostname`)\n\t\t\t\t ) ENGINE = MYISAM;\n\t\t\t"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `sarg_aliases` (\n\t\t\t\t`ID` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,\n\t\t\t\t`pattern` VARCHAR( 128 ) NOT NULL,\n\t\t\t\t`group` VARCHAR( 90 ) NOT NULL,\n\t\t\t\t`replace` VARCHAR(90),\n\t\t\t\t UNIQUE KEY `pattern` (`pattern`),\n\t\t\t\t KEY `group` (`group`),\n\t\t\t\t KEY `replace` (`replace`)\n\t\t\t\t ) ENGINE = MYISAM;\n\t\t\t"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `ufdb_page_rules` (\n\t\t\t`zmd5` varchar(90) NOT NULL,\n\t\t\t`category` varchar(90) NOT NULL,\n\t\t\t`deny` smallint(1) NOT NULL,\n\t\t\t`allow` smallint(1) NOT NULL,\n\t\t\t`adgroup` varchar(255) NOT NULL,\n\t\t\t`noauth` smallint(1) NOT NULL,\n\t\t\t`maxtime` smallint(3) NOT NULL,\n\t\t\t`infinite` smallint(1) NOT NULL,\n\t\t\t`addTocat` varchar(255) NOT NULL,\n\t\t\t`username` varchar(255) NOT NULL,\n\t\t\t`webruleid` INT(10) NOT NULL,\n\t\t\tPRIMARY KEY (`zmd5`),\n\t\t\tKEY `category` (`category`),\n\t\t\tKEY `deny` (`deny`),\n\t\t\tKEY `allow` (`allow`),\n\t\t\tKEY `webruleid` (`webruleid`),\n\t\t\tKEY `infinite` (`infinite`)\n\t\t\t) ENGINE=MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->FIELD_EXISTS("ufdb_page_rules", "maxtime")) { $this->QUERY_SQL("ALTER TABLE `ufdb_page_rules` ADD `maxtime` smallint(3) NOT NULL DEFAULT 0, ADD INDEX ( `maxtime` )"); } if (!$this->FIELD_EXISTS("ufdb_page_rules", "ticket")) { $this->QUERY_SQL("ALTER TABLE `ufdb_page_rules` ADD `ticket` smallint(1) NOT NULL DEFAULT 0, ADD INDEX ( `ticket` )"); } if (!$this->FIELD_EXISTS("ufdb_page_rules", "webruleid")) { $this->QUERY_SQL("ALTER TABLE `ufdb_page_rules` ADD `webruleid` INT(10) NOT NULL NOT NULL DEFAULT 0, ADD INDEX ( `webruleid` )"); } $sql = "CREATE TABLE IF NOT EXISTS `UsersAgentsDB` (\n\t\t\t\t`explain` VARCHAR(255),\n\t\t\t\t`editor` VARCHAR( 90 ) NOT NULL,\n\t\t\t\t`pattern` VARCHAR(60) PRIMARY KEY,\n\t\t\t\t`bypass` smallint(1) NOT NULL DEFAULT 1,\n\t\t\t\t`deny` smallint(1) NOT NULL DEFAULT 0,\n\t\t\t\t`enabled` smallint(1) NOT NULL DEFAULT 1,\n\t\t\t\t KEY `bypass` (`bypass`),\n\t\t\t\t KEY `enabled` (`enabled`),\n\t\t\t\t KEY `editor` (`editor`)\n\t\t\t\t ) ENGINE = MYISAM;\n\t\t\t"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `StoreID` (\n\t\t\t\t`ID` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,\n\t\t\t\t`zmd5` VARCHAR( 90 ) NOT NULL,\n\t\t\t\t`pattern` TEXT,\n\t\t\t\t`dedup` VARCHAR(255),\n\t\t\t\t`zOrder` smallint(2) NOT NULL DEFAULT 1,\n\t\t\t\t`enabled` smallint(1) NOT NULL DEFAULT 1,\n\t\t\t\t UNIQUE KEY `zmd5` (`zmd5`),\n\t\t\t\t KEY `enabled` (`enabled`),\n\t\t\t\t KEY `dedup` (`dedup`),\n\t\t\t\t KEY `zOrder` (`zOrder`)\n\t\t\t\t ) ENGINE = MYISAM;\n\t\t\t"; $this->QUERY_SQL($sql, $this->database); if ($this->COUNT_ROWS("StoreID") == 0) { include_once dirname(__FILE__) . "/class.storeid.defaults.inc"; $this->QUERY_SQL(FillStoreIDDefaults()); } $sql = "CREATE TABLE IF NOT EXISTS `dnsmasq_blacklist` (\n\t\t\t\t`ID` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,\n\t\t\t\t`hostname` VARCHAR( 256 ) NOT NULL,\n\t\t\t\t KEY `hostname` (`hostname`)\n\t\t\t\t ) ENGINE = MYISAM;\n\t\t\t"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `dnsmasq_cname` (\n\t\t\t\t`ID` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,\n\t\t\t\t`recordid` BIGINT UNSIGNED,\n\t\t\t\t`hostname` VARCHAR(128),\n\t\t\t\t KEY `recordid` (`recordid`),\n\t\t\t\t KEY `hostname` (`hostname`)\n\t\t\t\t ) ENGINE = MYISAM;\n\t\t\t"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `webfilter_blklnk` (\n\t\t\t\t`ID` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t\t zmd5 VARCHAR(90) NOT NULL,\n\t\t\t\t webfilter_blkid INT(10) NOT NULL,\n\t\t\t\t webfilter_ruleid INT(10) NOT NULL,\n\t\t\t\t blacklist smallint(1) NOT NULL DEFAULT '1',\n\t\t\t\t UNIQUE KEY `zmd5` (`zmd5`),\n\t\t\t\t KEY `webfilter_blkid` (`webfilter_blkid`),\n\t\t\t\t KEY `webfilter_ruleid` (`webfilter_ruleid`),\n\t\t\t\t KEY `blacklist` (`blacklist`)\n\t\t\t\t) ENGINE = MYISAM;\n\t\t\t"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `cicap_profiles` (\n\t\t\t\t`ID` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t\t `rulename` VARCHAR(90) NOT NULL,\n\t\t\t\t `blacklist` smallint(2) NOT NULL,\n\t\t\t\t `whitelist` smallint(2) NOT NULL,\n\t\t\t\t `enabled` smallint(1) NOT NULL,\n\t\t\t\t KEY `rulename` (`rulename`),\n\t\t\t\t KEY `blacklist` (`blacklist`),\n\t\t\t\t KEY `whitelist` (`whitelist`),\n\t\t\t\t KEY `enabled` (`enabled`)\n\t\t\t\t) ENGINE = MYISAM AUTO_INCREMENT = 5;\n\t\t\t"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `webfilter_blkgp` (\n\t\t\t\t`ID` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t\t groupname VARCHAR(255) NOT NULL,\n\t\t\t\t enabled smallint(1) NOT NULL DEFAULT '1',\n\t\t\t\t KEY `groupname` (`groupname`),\n\t\t\t\t KEY `enabled` (`enabled`)\n\t\t\t\t) ENGINE = MYISAM;\n\t\t\t"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `webfilter_blkcnt` (\n\t\t\t\t`ID` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t\t`webfilter_blkid` INT( 10 ) NOT NULL,\n\t\t\t\t category VARCHAR(255) NOT NULL,\n\t\t\t\t KEY `category` (`category`),\n\t\t\t\tKEY `webfilter_blkid` (`webfilter_blkid`)\n\t\t\t\t) ENGINE = MYISAM;\n\t\t\t"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `squid_balancers` (\n\t\t\t`ID` INT( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t`ipsrc` VARCHAR( 255 ) NOT NULL ,\n\t\t\t`enabled` INT( 1 ) NOT NULL DEFAULT '1',\n\t\t\tINDEX ( `enabled`,`ipsrc` )) ENGINE=MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `webfilter_quotas` (\n\t\t\t`ID` INT( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t\tenabled smallint(1) NOT NULL,\n\t\t\tgroupname VARCHAR(90) NOT NULL,\n\t\t\tquotasize INT(10) NOT NULL,\n\t\t\tquotaPeriod SMALLINT(1) NOT NULL,\t\t\t\t\n\t\t\tUseExternalWebPage smallint(1) NOT NULL DEFAULT '0' ,\n\t\t\tExternalWebPage VARCHAR(255) NOT NULL,\n\t\t\tzOrder SMALLINT(2) NOT NULL,\n\t\t\tAllSystems smallint(1) NOT NULL,\n\t\t\tKEY `groupname` (`groupname`),\n\t\t\tKEY `enabled` (`enabled`),\n\t\t\tKEY `zOrder` (`zOrder`),\n\t\t\tKEY `AllSystems` (`AllSystems`)) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `acls_ntlm` (\n\t\t\t`ID` INT( 100 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t\tenabled smallint(1) NOT NULL,\n\t\t\titem VARCHAR(256) NOT NULL,\n\t\t\tType VARCHAR(20) NOT NULL,\n\t\t\tKEY `item` (`Type`),\n\t\t\tKEY `enabled` (`enabled`),\n\t\t\tKEY `Type` (`Type`)) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->TABLE_EXISTS('webfilter_rules', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `webfilter_rules` (\n\t\t\t\t `ID` INT( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t\t \tgroupmode smallint(1) NOT NULL,\n\t\t\t\t \tenabled smallint(1) NOT NULL,\n\t\t\t\t\tgroupname VARCHAR(90) NOT NULL,\n\t\t\t\t\tBypassSecretKey VARCHAR(90) NOT NULL,\n\t\t\t\t\tendofrule VARCHAR(50) NOT NULL,\n\t\t\t\t\tblockdownloads smallint(1) NOT NULL DEFAULT '0' ,\n\t\t\t\t\tnaughtynesslimit INT(2) NOT NULL DEFAULT '50' ,\n\t\t\t\t\tsearchtermlimit INT(2) NOT NULL DEFAULT '30' ,\n\t\t\t\t\tbypass smallint(1) NOT NULL DEFAULT '0' ,\n\t\t\t\t\tdeepurlanalysis smallint(1) NOT NULL DEFAULT '0' ,\n\t\t\t\t\tUseExternalWebPage smallint(1) NOT NULL DEFAULT '0' ,\n\t\t\t\t\tExternalWebPage VARCHAR(255) NOT NULL,\n\t\t\t\t\tfreeweb VARCHAR(255) NOT NULL,\n\t\t\t\t\tsslcertcheck smallint(1) NOT NULL DEFAULT '0' ,\n\t\t\t\t\tsslmitm smallint(1) NOT NULL DEFAULT '0',\n\t\t\t\t\tGoogleSafeSearch smallint(1) NOT NULL DEFAULT '0',\n\t\t\t\t\tTimeSpace TEXT NOT NULL,\n\t\t\t\t\tTemplateError TEXT NOT NULL,\n\t\t\t\t\tTemplateColor1 VARCHAR(90),\n\t\t\t\t\tTemplateColor2 VARCHAR(90),\n\t\t\t\t\tRewriteRules TEXT NOT NULL,\n\t\t\t\t\tzOrder SMALLINT(2) NOT NULL,\n\t\t\t\t\tAllSystems smallint(1) NOT NULL,\n\t\t\t\t\tUseSecurity smallint(1) NOT NULL,\n\t\t\t\t KEY `groupname` (`groupname`),\n\t\t\t\t KEY `enabled` (`enabled`),\n\t\t\t\t KEY `UseSecurity` (`UseSecurity`),\n\t\t\t\t KEY `zOrder` (`zOrder`),\n\t\t\t\t KEY `AllSystems` (`AllSystems`)\n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->FIELD_EXISTS("webfilter_rules", "endofrule")) { $this->QUERY_SQL("ALTER TABLE `webfilter_rules` ADD `endofrule` VARCHAR(50)"); } if (!$this->FIELD_EXISTS("webfilter_rules", "BypassSecretKey")) { $this->QUERY_SQL("ALTER TABLE `webfilter_rules` ADD `BypassSecretKey` VARCHAR(90)"); } if (!$this->FIELD_EXISTS("webfilter_rules", "embeddedurlweight")) { $this->QUERY_SQL("ALTER TABLE `webfilter_rules` ADD `embeddedurlweight` smallint(1)"); } if (!$this->FIELD_EXISTS("webfilter_rules", "TimeSpace")) { $this->QUERY_SQL("ALTER TABLE `webfilter_rules` ADD `TimeSpace` TEXT NOT NULL"); } if (!$this->FIELD_EXISTS("webfilter_rules", "RewriteRules")) { $this->QUERY_SQL("ALTER TABLE `webfilter_rules` ADD `RewriteRules` TEXT NOT NULL"); } if (!$this->FIELD_EXISTS("webfilter_rules", "TemplateError")) { $this->QUERY_SQL("ALTER TABLE `webfilter_rules` ADD `TemplateError` TEXT NOT NULL"); } if (!$this->FIELD_EXISTS("webfilter_rules", "GoogleSafeSearch")) { $this->QUERY_SQL("ALTER TABLE `webfilter_rules` ADD `GoogleSafeSearch` smallint(1) NOT NULL DEFAULT '0'"); } if (!$this->FIELD_EXISTS("webfilter_rules", "UseExternalWebPage")) { $this->QUERY_SQL("ALTER TABLE `webfilter_rules` ADD `UseExternalWebPage` smallint(1) NOT NULL DEFAULT '0'"); } if (!$this->FIELD_EXISTS("webfilter_rules", "ExternalWebPage")) { $this->QUERY_SQL("ALTER TABLE `webfilter_rules` ADD `ExternalWebPage` VARCHAR(255) NOT NULL"); } if (!$this->FIELD_EXISTS("webfilter_rules", "freeweb")) { $this->QUERY_SQL("ALTER TABLE `webfilter_rules` ADD `freeweb` VARCHAR(255) NOT NULL"); } if (!$this->FIELD_EXISTS("webfilter_rules", "zOrder")) { $this->QUERY_SQL("ALTER TABLE `webfilter_rules` ADD `zOrder` SMALLINT(2) NOT NULL,ADD INDEX ( `zOrder` )"); } if (!$this->FIELD_EXISTS("webfilter_rules", "AllSystems")) { $this->QUERY_SQL("ALTER TABLE `webfilter_rules` ADD `AllSystems` smallint(1),ADD INDEX ( `AllSystems` )"); } if (!$this->FIELD_EXISTS("webfilter_rules", "UseSecurity")) { $this->QUERY_SQL("ALTER TABLE `webfilter_rules` ADD `UseSecurity` smallint(1),ADD INDEX ( `UseSecurity` )"); } if (!$this->FIELD_EXISTS("webfilter_rules", "TemplateColor1")) { $this->QUERY_SQL("ALTER TABLE `webfilter_rules` ADD `TemplateColor1` VARCHAR(90)"); } if (!$this->FIELD_EXISTS("webfilter_rules", "TemplateColor2")) { $this->QUERY_SQL("ALTER TABLE `webfilter_rules` ADD `TemplateColor2` VARCHAR(90)"); } if (!$this->FIELD_EXISTS("webfilter_rules", "http_code")) { $this->QUERY_SQL("ALTER TABLE `webfilter_rules` ADD `http_code` smallint(3)"); } $sql = "CREATE TABLE IF NOT EXISTS `webfilter_catprivs` (\n\t\t\t`zmd5` VARCHAR(90) NOT NULL,\n\t\t\t`categorykey` VARCHAR(128) NOT NULL,\n\t\t\t`groupdata` VARCHAR(255) NOT NULL,\n\t\t\t`allowrecompile` smallint(1) NOT NULL DEFAULT 0,\n\t\t\tPRIMARY KEY `zmd5` (`zmd5`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `webfilter_catprivslogs` (\n\t\t\t`zDate` datetime NOT NULL,\n\t\t\t`events` VARCHAR(128) NOT NULL,\n\t\t\t`uid` VARCHAR(128) NOT NULL,\n\t\t\t KEY `uid` (`uid`),\n\t\t\t KEY `zDate` (`zDate`),\n\t\t\t KEY `events` (`events`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `webfilter_certs` (\n\t\t\t`zmd5` VARCHAR(90) NOT NULL,\n\t\t\t`certname` VARCHAR(255) NOT NULL,\n\t\t\t`certdata` TEXT NOT NULL,\n\t\t\tPRIMARY KEY `zmd5` (`zmd5`),\n\t\t\t KEY `certname` (`certname`)\n\t\t\t ) ENGINE = MYISAM;\n\t "; $this->QUERY_SQL($sql, $this->database); if ($this->COUNT_ROWS("webfilter_certs") == 0) { $this->fill_webfilter_certs(); } if (!$this->TABLE_EXISTS('webfilter_group', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `webfilter_group` (\n\t\t\t\t `ID` INT( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t\t\tgroupname VARCHAR(90) NOT NULL,\n\t\t\t\t\tlocalldap smallint(1) NOT NULL DEFAULT '0' ,\n\t\t\t\t\tenabled smallint(1) NOT NULL DEFAULT '1' ,\n\t\t\t\t\tgpid INT(10) NOT NULL DEFAULT '0' ,\n\t\t\t\t\tdescription VARCHAR(255) NOT NULL,\n\t\t\t\t\t`dn` VARCHAR(255) NOT NULL,\n\t\t\t\t KEY `groupname` (`groupname`),\n\t\t\t\t KEY `gpid` (`gpid`),\n\t\t\t\t KEY `enabled` (`enabled`),\n\t\t\t\t KEY `dn` (`dn`)\n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } $sql = "CREATE TABLE IF NOT EXISTS `notcategorized_events` (\n\t\t\t\t `ID` INT( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t\t\ttablename VARCHAR(128) NOT NULL,\n\t\t\t\t\tzDate datetime NOT NULL ,\n\t\t\t\t\tsubject VARCHAR(255) NOT NULL,\n\t\t\t\t\tfinished smallint(1) NOT NULL DEFAULT '0' ,\n\t\t\t\t\tdescription TEXT NOT NULL,\n\t\t\t\t KEY `tablename` (`tablename`),\n\t\t\t\t KEY `zDate` (`zDate`),\n\t\t\t\t KEY `finished` (`finished`)\n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `proxy_ports_wbl` (\n\t\t`ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t`portid` INT NOT NULL,\n\t\t`pattern` VARCHAR(128) NOT NULL,\n\t\t`include` smallint(1) NOT NULL DEFAULT '0' ,\n\t\tKEY `pattern` (`pattern`),\n\t\tKEY `include` (`include`),\n\t\tKEY `portid` (`portid`)\n\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `ss5_fw` (\n\t\t`ID` INT( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t`zorder` INT( 5 ) NOT NULL,\n\t\t`mode` smallint(1) NOT NULL DEFAULT 0,\n\t\t`enabled` smallint(1) NOT NULL DEFAULT 1,\n\t\t`src_host` VARCHAR(128),\n\t\t`src_port` BIGINT UNSIGNED,\n\t\t`dst_host` VARCHAR(128),\n\t\t`dst_port` BIGINT UNSIGNED,\n\t\t`fixup` varchar(20) NULL,\n\t\t`group` VARCHAR(128),\n\t\t`bandwitdh` BIGINT UNSIGNED,\n\t\t`expdate` VARCHAR(40) NULL,\n\t\tKEY `zorder` (`zorder`),\n\t\tKEY `mode` (`mode`),\n\t\tKEY `enabled` (`enabled`),\n\t\tKEY `src_host` (`src_host`),\n\t\tKEY `dst_host` (`dst_host`)\n\t\t) ENGINE=MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `ssl_rules` (\n\t\t\t\t`ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t\t`description` VARCHAR( 128 ) NOT NULL,\n\t\t\t\t`zDate` datetime NOT NULL,\n\t\t\t\t`crypt` smallint( 1 ) NOT NULL DEFAULT '0',\n\t\t\t\t`trust` smallint( 1 ) NOT NULL DEFAULT '0',\n\t\t\t\t`enabled` smallint(1) NULL,\n\t\t\t\t`ruletype` smallint(1) NULL,\n\t\t\t\t`frommeta` smallint(1) NULL,\n\t\t\t\t`zOrder` smallint(5) NULL,\n\t\t\t\t KEY `zDate` (`zDate`),\n\t\t\t\t KEY `crypt` (`crypt`),\n\t\t\t\t KEY `trust` (`trust`),\n\t\t\t\t KEY `enabled` (`enabled`),\n\t\t\t \t KEY `zOrder` (`zOrder`),\n\t\t\t\t KEY `frommeta` (`frommeta`)\n\t\t\t ) ENGINE = MYISAM;"; $this->QUERY_SQL($sql); $sql = "CREATE TABLE IF NOT EXISTS `proxy_ports` (\n\t\t\t`ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t`PortName` VARCHAR(128) NULL,\n\t\t\t`zMD5` VARCHAR(90) NOT NULL,\n\t\t\t`xnote` TEXT NULL ,\n\t\t\t`Params` TEXT NULL ,\n\t\t\t`ipaddr` VARCHAR(128) NOT NULL,\n\t\t\t`port` INT NOT NULL,\n\t\t\t`transparent` smallint(1) NOT NULL DEFAULT '0' ,\n\t\t\t`is_nat` smallint(1) NOT NULL DEFAULT '0' ,\n\t\t\t`enabled` smallint(1) NOT NULL DEFAULT '1' ,\n\t\t\t KEY `ipaddr` (`ipaddr`),\n\t\t\t KEY `enabled` (`enabled`),\n\t\t\t KEY `port` (`port`)\n\t\t\t) ENGINE = MYISAM AUTO_INCREMENT = 20;"; $this->QUERY_SQL($sql, $this->database); if (!$this->FIELD_EXISTS("proxy_ports", "transparent")) { $this->QUERY_SQL("ALTER TABLE `proxy_ports` ADD `transparent` smallint(1) NOT NULL DEFAULT '0'"); if (!$this->ok) { echo $this->mysql_error . "\n"; } } if (!$this->FIELD_EXISTS("proxy_ports", "PortName")) { $this->QUERY_SQL("ALTER TABLE `proxy_ports` ADD `PortName` VARCHAR(128) NULL"); if (!$this->ok) { echo $this->mysql_error . "\n"; } } if (!$this->FIELD_EXISTS("proxy_ports", "TProxy")) { $this->QUERY_SQL("ALTER TABLE `proxy_ports` ADD `TProxy` smallint(1) NOT NULL DEFAULT '0'"); if (!$this->ok) { echo $this->mysql_error . "\n"; } } if (!$this->FIELD_EXISTS("proxy_ports", "is_nat")) { $this->QUERY_SQL("ALTER TABLE `proxy_ports` ADD `is_nat` smallint(1) NOT NULL DEFAULT '0'"); if (!$this->ok) { echo $this->mysql_error . "\n"; } } $sql = "CREATE TABLE IF NOT EXISTS `itcharters` (\n\t\t\t`ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t`ChartContent` TEXT NULL,\n\t\t\t`ChartHeaders` TEXT NOT NULL,\n\t\t\t`PdfContent` LONGBLOB NULL,\n\t\t\t`TextIntro` TEXT NOT NULL,\n\t\t\t`TextButton` VARCHAR(128) NOT NULL,\n\t\t\t`PdfFileName` VARCHAR(128) NULL,\n\t\t\t`Params` TEXT NULL ,\n\t\t\t`title` VARCHAR(255) NOT NULL,\n\t\t\t`explain` TEXT NOT NULL,\n\t\t\t`enabled` smallint(1) NOT NULL DEFAULT '1' ,\n\t\t\t`enablepdf` smallint(1) NOT NULL DEFAULT '0' ,\n\t\t\t KEY `title` (`title`),\n\t\t\t KEY `enablepdf` (`enablepdf`),\n\t\t\t KEY `enabled` (`enabled`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `influxIPClients` (\n\t\t\t`ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t `ipaddr` VARCHAR(128),\n\t\t\t`hostname` VARCHAR(128),\n\t\t\t`isServ` smallint(1) NOT NULL DEFAULT '1' ,\n\t\t\tUNIQUE KEY `ipaddr` (`ipaddr`),\n\t\t\tKEY `hostname` (`hostname`), \n\t\t\tKEY `isServ` (`isServ`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `sarg_performed` (\n\t\t `md5file` VARCHAR(128) PRIMARY KEY ,\n\t\t\t`filename` VARCHAR(128) ,\n\t\t\t`zDate` datetime\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->FIELD_EXISTS("itcharters", "PdfContent")) { $this->QUERY_SQL("ALTER TABLE `itcharters` ADD `PdfContent` LONGBLOB NULL"); if (!$this->ok) { echo $this->mysql_error . "\n"; } } if (!$this->FIELD_EXISTS("itcharters", "PdfContent")) { $this->QUERY_SQL("ALTER TABLE `itcharters` ADD `PdfContent` LONGBLOB NULL"); if (!$this->ok) { echo $this->mysql_error . "\n"; } } if (!$this->FIELD_EXISTS("itcharters", "enablepdf")) { $this->QUERY_SQL("ALTER TABLE `itcharters` ADD `enablepdf` smallint(1) NOT NULL DEFAULT '0',ADD INDEX ( `enablepdf` )"); if (!$this->ok) { echo $this->mysql_error . "\n"; } } if (!$this->FIELD_EXISTS("itcharters", "PdfFileName")) { $this->QUERY_SQL("ALTER TABLE `itcharters` ADD `PdfFileName` VARCHAR(128) NULL"); if (!$this->ok) { echo $this->mysql_error . "\n"; } } if (!$this->FIELD_EXISTS("itcharters", "PdfFileSize")) { $this->QUERY_SQL("ALTER TABLE `itcharters` ADD `PdfFileSize` INT UNSIGNED NULL"); if (!$this->ok) { echo $this->mysql_error . "\n"; } } if (!$this->FIELD_EXISTS("itcharters", "TextIntro")) { $this->QUERY_SQL("ALTER TABLE `itcharters` ADD `TextIntro` TEXT NULL"); if (!$this->ok) { echo $this->mysql_error . "\n"; } } if (!$this->FIELD_EXISTS("itcharters", "TextButton")) { $this->QUERY_SQL("ALTER TABLE `itcharters` ADD `TextButton` VARCHAR(128) NOT NULL"); if (!$this->ok) { echo $this->mysql_error . "\n"; } } $sql = "CREATE TABLE IF NOT EXISTS `itchartlog` (\n\t\t\t`ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t`chartid` INT NOT NULL,\n\t\t\t`uid` VARCHAR(128) NOT NULL ,\n\t\t\t`zDate` datetime NOT NULL,\n\t\t\t`ipaddr` VARCHAR(128) NOT NULL,\n\t\t\t`MAC` VARCHAR(128) NOT NULL\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `ident_networks` (\n\t\t\t\tnetwork_item VARCHAR(128) NOT NULL PRIMARY KEY\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `transparent_networks` (\n\t\t\t\t`ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t\t`pattern` VARCHAR( 90 ) NOT NULL,\n\t\t\t\t`transparent` smallint(1) NOT NULL,\n\t\t\t\t`destination` VARCHAR( 90 ) NOT NULL,\n\t\t\t\t`destination_port` smallint( 3 ) NOT NULL,\n\t\t\t\t`ssl` smallint(1) NOT NULL,\n\t\t\t\t`remote_proxy` VARCHAR( 128 ) NOT NULL,\n\t\t\t\t`enabled` smallint(1) NOT NULL,\n\t\t\t\t`isnot` smallint(1) NOT NULL,\n\t\t\t\t`block` smallint(1) NOT NULL,\n\t\t\t\t`zOrder` smallint(5) NOT NULL,\n\t\t\t\t`eth` VARCHAR( 40 ),\n\t\t\t\tKEY `pattern` (`pattern`),\n\t\t\t\tKEY `transparent` (`transparent`),\n\t\t\t\tKEY `destination` (`destination`),\n\t\t\t\tKEY `remote_proxy` (`remote_proxy`),\n\t\t\t\tKEY `isnot` (`isnot`),\n\t\t\t\tKEY `block` (`block`),\n\t\t\t\tKEY `ssl` (`ssl`),\n\t\t\t\tKEY `zOrder` (`zOrder`),\n\t\t\t\tKEY `enabled` (`enabled`),\n\t\t\t\tKEY `eth` (`eth`)\n\t\t\t ) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->FIELD_EXISTS("transparent_networks", "isnot")) { $this->QUERY_SQL("ALTER TABLE `transparent_networks` ADD `isnot` smallint( 1 ) NOT NULL ,ADD INDEX ( `isnot` )"); } if (!$this->FIELD_EXISTS("transparent_networks", "block")) { $this->QUERY_SQL("ALTER TABLE `transparent_networks` ADD `block` smallint( 1 ) NOT NULL ,ADD INDEX ( `block` )"); } $sql = "CREATE TABLE IF NOT EXISTS `transparent_networks_groups` (\n\t\t`ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t`inbound` smallint(1) NOT NULL,\n\t\t`zmd5` VARCHAR(90) NOT NULL,\n\t\truleid INT NOT NULL,\n\t\tgpid INT NOT NULL,\n\t\t`enabled` smallint(1) NOT NULL,\n\t\tUNIQUE KEY (`zmd5`),\n\t\tKEY `inbound` (`inbound`),\n\t\tKEY `ruleid` (`ruleid`),\n\t\tKEY `enabled` (`enabled`),\n\t\tKEY `gpid` (`gpid`)\n\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $this->QUERY_SQL("CREATE TABLE IF NOT EXISTS `squid_reports` (\n\t\t\t\t `ID` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t\t\t`zmd5` VARCHAR( 90 ) NOT NULL,\n\t\t\t\t\treport_name VARCHAR(128) NOT NULL,\n\t\t\t\t\treport_days smallint(3) NOT NULL ,\n\t\t\t\t\treport_type smallint(1) NOT NULL,\n\t\t\t\t\treport_cat VARCHAR(128) NOT NULL,\n\t\t\t\t\treport_sum smallint(1) NOT NULL,\n\t\t\t\t\treport_not_categorized smallint(1) NOT NULL,\n\t\t\t\t\treport_progress smallint(2) NOT NULL DEFAULT 0,\n\t\t\t\t\treport_progress_text VARCHAR(128),\n\t\t\t\t\treport_build_time_start INT UNSIGNED,\n\t\t\t\t\treport_build_time_end INT UNSIGNED,\n\t\t\t\t\treport_time_start INT UNSIGNED,\n\t\t\t\t\treport_time_end INT UNSIGNED,\n\t\t\t\t\treport_schedenabled smallint(1) NOT NULL,\n\t\t\t\t\treport_bin longblob,\n\t\t\t\t\treport_csv longblob,\n\t\t\t\t\treport_log longblob,\n\t\t\t\t\treport_csv_ext VARCHAR(10),\n\t\t\t\t\treport_schedule VARCHAR(255) NOT NULL,\n\t\t\t\t\trecategorize smallint(1) NOT NULL,\n\t\t\t\t\tcategorize smallint(1) NOT NULL,\n\t\t\t\t\treport_users TEXT,\n\t\t\t\t\treport_data TEXT,\n\t\t\t\t\tdescription TEXT NOT NULL,\n\t\t\t\t UNIQUE KEY `zmd5` (`zmd5`),\n\t\t\t\t KEY `report_name` (`report_name`),\n\t\t\t\t KEY `report_days` (`report_days`),\n\t\t\t\t KEY `report_schedenabled` (`report_schedenabled`),\n\t\t\t\t KEY `report_type` (`report_type`)\n\t\t\t\t) ENGINE = MYISAM;"); if (!$this->ok) { echo $this->mysql_error; } if (!$this->FIELD_EXISTS("squid_reports", "report_csv")) { $this->QUERY_SQL("ALTER TABLE `squid_reports` ADD `report_csv` longblob"); } if (!$this->FIELD_EXISTS("squid_reports", "report_log")) { $this->QUERY_SQL("ALTER TABLE `squid_reports` ADD `report_log` longblob"); } if (!$this->FIELD_EXISTS("squid_reports", "report_csv_ext")) { $this->QUERY_SQL("ALTER TABLE `squid_reports` ADD `report_csv_ext` VARCHAR(10)"); } $this->QUERY_SQL("CREATE TABLE IF NOT EXISTS `squid_reports_categories` (\n\t\t\t\t `zmd5` VARCHAR( 90 ) NOT NULL,\n\t\t\t\t\tcategory VARCHAR(128) NOT NULL,\n\t\t\t\t\treport_id INT( 10 ) NOT NULL,\n\t\t\t\t\tUNIQUE KEY `zmd5` (`zmd5`),\n\t\t\t\t\tKEY `report_id` (`report_id`),\n\t\t\t\t\tKEY `category` (`category`)\n\t\t\t\t) ENGINE = MYISAM;"); if (!$this->ok) { echo $this->mysql_error; } $this->QUERY_SQL("CREATE TABLE IF NOT EXISTS `squid_reports_websites` (\n\t\t\t\t `zmd5` VARCHAR( 90 ) NOT NULL,\n\t\t\t\t\tfamilysite VARCHAR(128) NOT NULL,\n\t\t\t\t\treport_id INT( 10 ) NOT NULL,\n\t\t\t\t\tUNIQUE KEY `zmd5` (`zmd5`),\n\t\t\t\t\tKEY `report_id` (`report_id`),\n\t\t\t\t\tKEY `familysite` (`familysite`)\n\t\t\t\t) ENGINE = MYISAM;"); if (!$this->ok) { echo $this->mysql_error; } $this->QUERY_SQL("CREATE TABLE IF NOT EXISTS `squid_reports_members` (\n\t\t\t\t `zmd5` VARCHAR( 90 ) NOT NULL,\n\t\t\t\t\tmember_value VARCHAR(128) NOT NULL,\n\t\t\t\t\tmember_field VARCHAR(40) NOT NULL,\n\t\t\t\t\treport_id INT( 10 ) NOT NULL,\n\t\t\t\t\tUNIQUE KEY `zmd5` (`zmd5`),\n\t\t\t\t\tKEY `report_id` (`report_id`),\n\t\t\t\t\tKEY `member_value` (`member_value`)\n\t\t\t\t) ENGINE = MYISAM;"); if (!$this->ok) { echo $this->mysql_error; } $sql = "CREATE TABLE IF NOT EXISTS `hotspot_whitelist` (\n\t\t\t\t`ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t\t`hostname` VARCHAR( 256 ) NOT NULL,\n\t\t\t\t`ipaddr` VARCHAR( 90 ) NOT NULL,\n\t\t\t\t`port` smallint(2) NOT NULL,\n\t\t\t\t`ssl` smallint(1) NOT NULL,\n\t\t\t\tKEY `ipaddr` (`ipaddr`),\n\t\t\t\tKEY `ssl` (`ssl`),\n\t\t\t\tKEY `hostname` (`hostname`)\n\t\t\t ) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `webfiltering_meta_items` (\n\t\t\t\t`category` VARCHAR( 15 ) NOT NULL ,\n\t\t\t\t`zmd5` VARCHAR(90) NOT NULL,\n\t\t\t\t`pattern` VARCHAR(128) NOT NULL,\n\t\t\t\tPRIMARY KEY (`zmd5`),\n\t\t\t\tINDEX ( `pattern`) \n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `webfiltering_meta_urls` (\n\t\t\t\t`category` VARCHAR( 15 ) NOT NULL ,\n\t\t\t\t`zmd5` VARCHAR(90) NOT NULL,\n\t\t\t\t`pattern` VARCHAR(128) NOT NULL,\n\t\t\t\tPRIMARY KEY (`zmd5`),\n\t\t\t\tINDEX ( `pattern`) \n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `hotspot_ident` (\n\t\t\t\t`ipaddr` VARCHAR( 90 ) NOT NULL PRIMARY KEY ,\n\t\t\t\t `username` VARCHAR(128) NOT NULL,\n\t\t\t\t `MAC` VARCHAR(128) NOT NULL,\n\t\t\t\t zDate datetime NOT NULL,\n\t\t\t\t KEY `username` (`username`),\n\t\t\t\t UNIQUE KEY `MAC` (`MAC`),\n\t\t\t\t KEY `zDate` (`zDate`)\n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `webfilter_aclsdynamic` (\n\t\t\t\t \t`ID` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t\t\t`type` smallint(1) NOT NULL,\n\t\t\t\t\t`value` VARCHAR(255) NOT NULL,\n\t\t\t\t\t`enabled` smallint(1) NOT NULL DEFAULT '1' ,\n\t\t\t\t\t`gpid` INT(10) NOT NULL DEFAULT '0' ,\n\t\t\t\t\t`description` VARCHAR(255) NOT NULL,\n\t\t\t\t\t`who` VARCHAR(128) NOT NULL,\n\t\t\t\t \tKEY `type` (`type`),\n\t\t\t\t \tKEY `value` (`value`),\n\t\t\t\t \tKEY `enabled` (`enabled`),\n\t\t\t\t\tKEY `who` (`who`)\n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->ok) { writelogs("{$this->mysql_error}", __CLASS__ . "/" . __FUNCTION__, __FILE__, __LINE__); } $sql = "CREATE TABLE IF NOT EXISTS `webfilter_aclsdynlogs` (\n\t\t\t\t \t`ID` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t\t\t`zDate` DATETIME NOT NULL,\n\t\t\t\t\t`gpid` INT(10) NOT NULL DEFAULT '0' ,\n\t\t\t\t\t`events` VARCHAR(255) NOT NULL,\n\t\t\t\t\t`who` VARCHAR(128) NOT NULL,\n\t\t\t\t \tKEY `zDate` (`zDate`),\n\t\t\t\t \tKEY `gpid` (`gpid`),\n\t\t\t\t\tKEY `who` (`who`)\n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->ok) { writelogs("{$this->mysql_error}", __CLASS__ . "/" . __FUNCTION__, __FILE__, __LINE__); } $sql = "CREATE TABLE IF NOT EXISTS `webfilter_aclsdynamic_rights` (\n\t\t\t`ID` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,\n\t\t\t`gpid` INT UNSIGNED,\n\t\t\t`type` smallint(1) NOT NULL,\n\t\t\t`pattern` VARCHAR(255) NOT NULL,\n\t\t\tKEY `type` (`type`),\n\t\t\tKEY `pattern` (`pattern`) ) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->ok) { writelogs("{$this->mysql_error}", __CLASS__ . "/" . __FUNCTION__, __FILE__, __LINE__); } if (!$this->FIELD_EXISTS("webfilter_group", "dn")) { $this->QUERY_SQL("ALTER TABLE `webfilter_group` ADD `dn` VARCHAR( 255 ) NOT NULL ,ADD INDEX ( `dn` )"); } if (!$this->FIELD_EXISTS("webfilter_aclsdynamic", "maxtime")) { $this->QUERY_SQL("ALTER TABLE `webfilter_aclsdynamic` ADD `maxtime` INT UNSIGNED ,\n\t\t\t\t\tADD INDEX ( `maxtime` )"); } if (!$this->FIELD_EXISTS("webfilter_aclsdynamic", "duration")) { $this->QUERY_SQL("ALTER TABLE `webfilter_aclsdynamic` ADD `duration` INT UNSIGNED ,\n\t\t\t\t\tADD INDEX ( `duration` )"); } if (!$this->TABLE_EXISTS('webfilters_dtimes_rules', $this->database)) { $sql = "CREATE TABLE `squidlogs`.`webfilters_dtimes_rules` (\n\t\t\t`ID` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t`TimeName` VARCHAR( 128 ) NOT NULL ,\n\t\t\t`TimeCode` TEXT NOT NULL ,\n\t\t\t`enabled` SMALLINT( 1 ) NOT NULL ,\n\t\t\t`ruleid` INT UNSIGNED ,\n\t\t\tINDEX ( `TimeName` , `enabled` , `ruleid` )\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('webfilters_databases_disk', $this->database)) { $sql = "CREATE TABLE `squidlogs`.`webfilters_databases_disk` (\n\t\t\t`ID` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t`filename` VARCHAR( 128 ) NOT NULL ,\n\t\t\t`size` BIGINT UNSIGNED ,\n\t\t\t`filtime` BIGINT UNSIGNED ,\n\t\t\t`category` VARCHAR( 50 ) NOT NULL ,\n\t\t\tINDEX ( `size` , `category` ,`filtime`),\n\t\t\tKEY `filename` (`filename`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->FIELD_EXISTS("webfilters_databases_disk", "filtime")) { $this->QUERY_SQL("ALTER TABLE `webfilters_databases_disk` ADD `filtime` INT UNSIGNED NOT NULL ,ADD INDEX ( `filtime` )"); } if (!$this->FIELD_EXISTS("webfilters_quotas", "notify")) { $this->QUERY_SQL("ALTER TABLE webfilters_quotas ADD `notify` smallint(1) NOT NULL DEFAULT 0, ADD INDEX (`notify`)"); } if (!$this->FIELD_EXISTS("webfilters_quotas", "notify_params")) { $this->QUERY_SQL("ALTER TABLE webfilters_quotas ADD `notify_params` TEXT"); } if (!$this->TABLE_EXISTS('webfilters_quotas', $this->database)) { $sql = "CREATE TABLE `squidlogs`.`webfilters_quotas` (\n\t\t\t`ID` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t`xtype` VARCHAR( 40 ) NOT NULL ,\n\t\t\t`value` VARCHAR(150) ,\n\t\t\t`maxquota` BIGINT UNSIGNED ,\n\t\t\t`notify` smallint(1) NOT NULL DEFAULT 0,\n\t\t\t`notify_params` TEXT,\n\t\t\t`enabled` smallint(1),\n\t\t\t`duration` smallint(1),\n\t\t\tKEY `type` (`xtype`),\n\t\t\tKEY `value` (`value`),\n\t\t\tKEY `duration` (`duration`),\n\t\t\tKEY `maxquota` (`maxquota`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`webfilters_quotas_grp` (\n\t\t\t`ID` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t`zmd5` VARCHAR(90) NOT NULL,\n\t\t\t`ruleid` INT UNSIGNED,\n\t\t\t`gpid` INT UNSIGNED,\n\t\t UNIQUE KEY `zmd5` (`zmd5`),\n\t\t\tKEY `ruleid` (`ruleid`),\n\t\t\tKEY `gpid` (`gpid`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->TABLE_EXISTS('webtests', $this->database)) { $sql = "CREATE TABLE `squidlogs`.`webtests` (\n\t\t\t`sitename` VARCHAR( 250 ) NOT NULL PRIMARY KEY ,\n\t\t\t`category` VARCHAR( 128 ) NOT NULL ,\n\t\t\t`family` VARCHAR( 128 ) NOT NULL,\n\t\t\t`Country` VARCHAR( 50 ) NOT NULL,\n\t\t\t`zDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,\n\t\t\t`ipaddr` VARCHAR(50) NOT NULL ,\n\t\t\t`SiteInfos` TEXT NOT NULL ,\n\t\t\t`checked` SMALLINT( 1 ) NOT NULL ,\n\t\t\t KEY `sitename` (`sitename`),\n\t\t\t KEY `category` (`category`),\n\t\t\t KEY `Country` (`Country`),\n\t\t\t KEY `checked` (`checked`),\n\t\t\t KEY `family` (`family`),\n\t\t\t KEY `ipaddr` (`ipaddr`),\n\t\t\t KEY `zDate` (`zDate`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } else { if (!$this->FIELD_EXISTS("webtests", "Country")) { $this->QUERY_SQL("ALTER TABLE `webtests` ADD `Country` VARCHAR( 50 ) NOT NULL ,ADD INDEX ( `Country` )"); } } if (!$this->TABLE_EXISTS('webcacheperfs', $this->database)) { $sql = "CREATE TABLE `squidlogs`.`webcacheperfs` (\n\t\t\t`zTimeInt` INT UNSIGNED NOT NULL PRIMARY KEY,\n\t\t\t`zHour` TINYINT( 4 ) NOT NULL,\n\t\t\t`zDay` TINYINT( 4 ) NOT NULL,\n\t\t\t`zMonth` TINYINT( 4 ) NOT NULL,\n\t\t\t`zYear` INT( 5 ) NOT NULL,\n\t\t\t`notcached` BIGINT UNSIGNED,\n\t\t\t`cached` BIGINT UNSIGNED,\n\t\t\t`pourc` TINYINT( 2 ) NOT NULL ,\n\t\t\tINDEX ( `zHour` , `zDay` , `zMonth`,`zYear`,`notcached`,`cached`,`pourc` )\n\t\t\t \n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`rdpproxy_users` (\n\t\t\t`ID` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t`username` VARCHAR(128),\n\t\t\t`password` VARCHAR(128),\n\t\t\t KEY `username`(`username`),\n\t\t\t KEY `password`(`password`)\n\t\t\t ) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `deny_websites` ( `items` VARCHAR( 255 ) NOT NULL PRIMARY KEY ) ENGINE=MYISAM;"; $this->QUERY_SQL($sql); $sql = "CREATE TABLE IF NOT EXISTS `denycache_websites` ( `items` VARCHAR( 255 ) NOT NULL PRIMARY KEY ) ENGINE=MYISAM;"; $this->QUERY_SQL($sql); $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`rdpproxy_items` (\n\t\t\t`ID` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t`userid` BIGINT(11),\n\t\t\t`service` VARCHAR(128) ,\n\t\t\t`rhost` VARCHAR(128),\n\t\t\t`username` VARCHAR(128),\n\t\t\t`domain` VARCHAR(128),\n\t\t\t`password` VARCHAR(128),\n\t\t\t`servicetype` VARCHAR(15),\n\t\t\t`serviceport` smallint(15),\n\t\t\t`alive` INT UNSIGNED NOT NULL,\n\t\t\t`is_rec` smallint(1),\n\t\t\t KEY `username`(`username`),\n\t\t\t KEY `password`(`password`),\n\t\t\t KEY `service`(`service`),\n\t\t\t KEY `rhost`(`rhost`),\n\t\t\t KEY `userid`(`userid`)\n\t\t\t ) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->FIELD_EXISTS("rdpproxy_items", "domain")) { $this->QUERY_SQL("ALTER TABLE `rdpproxy_items` ADD `domain` VARCHAR(128)"); } $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`main_cache_rules` (\n\t\t\t`ID` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t`rulename` VARCHAR(128),\n\t\t\t`zorder` smallint(2) NOT NULL DEFAULT 0,\n\t\t\t`enabled` smallint(1) NOT NULL DEFAULT 1,\n\t\t\t KEY `rulename`(`rulename`),\n\t\t\t KEY `zorder`(`zorder`)\n\t\t\t ) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`main_cache_dyn` (\n\t\t\t`familysite` VARCHAR(128) PRIMARY KEY,\n\t\t\t`enabled` smallint(1) NOT NULL DEFAULT 1,\n\t\t\t`level` smallint(2) NOT NULL DEFAULT 5,\n\t\t\t`zDate` DATETIME,\n\t\t\t KEY `familysite`(`familysite`),\n\t\t\t KEY `enabled`(`enabled`),\n\t\t\t KEY `zDate`(`zDate`)\n\t\t\t ) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->FIELD_EXISTS("main_cache_dyn", "OnlyImages")) { $this->QUERY_SQL("ALTER TABLE `main_cache_dyn` ADD `OnlyImages` smallint( 1 ) DEFAULT '0'"); } if (!$this->FIELD_EXISTS("main_cache_dyn", "OnlyeDoc")) { $this->QUERY_SQL("ALTER TABLE `main_cache_dyn` ADD `OnlyeDoc` smallint( 1 ) DEFAULT '0'"); } if (!$this->FIELD_EXISTS("main_cache_dyn", "OnlyFiles")) { $this->QUERY_SQL("ALTER TABLE `main_cache_dyn` ADD `OnlyFiles` smallint( 1 ) DEFAULT '0'"); } if (!$this->FIELD_EXISTS("main_cache_dyn", "OnlyMultimedia")) { $this->QUERY_SQL("ALTER TABLE `main_cache_dyn` ADD `OnlyMultimedia` smallint( 1 ) DEFAULT '0'"); } $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`cache_rules` (\n\t\t\t`ID` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t`ruleid` INT UNSIGNED NOT NULL,\n\t\t\t`rulename` VARCHAR(128),\n\t\t\t`min` smallint(50) NOT NULL,\n\t\t\t`max` smallint(50) NOT NULL,\n\t\t\t`perc` smallint(2) NOT NULL DEFAULT 20,\n\t\t\t`zorder` smallint(2) NOT NULL DEFAULT 0,\n\t\t\t`GroupType` smallint(1) NOT NULL DEFAULT 1,\n\t\t\t`enabled` smallint(1) NOT NULL DEFAULT 1,\n\t\t\t KEY `rulename`(`rulename`),\n\t\t\t KEY `zorder`(`zorder`)\n\t\t\t ) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`cache_rules_items` (\n\t\t\t`ID` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t`zMD5` VARCHAR(90) NOT NULL,\n\t\t\t`ruleid` INT UNSIGNED NOT NULL,\n\t\t\t`item` VARCHAR(255),\n\t\t\t`zorder` smallint(2) NOT NULL DEFAULT 0,\n\t\t\t`enabled` smallint(1) NOT NULL DEFAULT 1,\n\t\t\t UNIQUE KEY `zMD5`(`zMD5`),\n\t\t\t KEY `item`(`item`),\n\t\t\t KEY `zorder`(`zorder`),\n\t\t\t KEY `ruleid`(`ruleid`)\n\t\t\t ) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`cache_rules_options` (\n\t\t\t`ID` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t`zMD5` VARCHAR(90) NOT NULL,\n\t\t\t`ruleid` INT UNSIGNED NOT NULL,\n\t\t\t`option` VARCHAR(40),\n\t\t\t`enabled` smallint(1) NOT NULL DEFAULT 1,\n\t\t\t UNIQUE KEY `zMD5`(`zMD5`),\n\t\t\t KEY `option`(`option`),\n\t\t\t KEY `ruleid`(`ruleid`)\n\t\t\t ) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `webauth_rules` (\n\t\t\t`ID` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t`rulename` varchar(128) NOT NULL,\n\t\t\t`enabled` smallint(1) NOT NULL,\n\t\t\t PRIMARY KEY (`ID`),\n\t\t\t KEY `rulename` (`rulename`),\n\t\t\t KEY `enabled` (`enabled`)\n\t\t\t) ENGINE=MYISAM;"; $this->QUERY_SQL($sql); $sql = "CREATE TABLE IF NOT EXISTS `webauth_rules_nets` (\n\t\t\t`ID` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t`ruleid` BIGINT UNSIGNED NOT NULL,\n\t\t\t`pattern` VARCHAR(128) NOT NULL,\n\t\t\t PRIMARY KEY (`ID`),\n\t\t\t KEY `ruleid` (`ruleid`)\t\n\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql); $sql = "CREATE TABLE IF NOT EXISTS `webauth_settings` (\n\t\t\t`ID` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t`ruleid` BIGINT UNSIGNED NOT NULL,\n\t\t\t`MasterKey` VARCHAR(128) NOT NULL,\n\t\t\t`MasterValue` TEXT NULL,\n\t\t\t PRIMARY KEY (`ID`),\n\t\t\t KEY `ruleid` (`ruleid`),\n\t\t\t KEY `MasterKey` (`MasterKey`)\n\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql); $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`UserAuthDays` (\n\t\t\t`zMD5` VARCHAR(90) PRIMARY KEY ,\n\t\t\t`ipaddr` VARCHAR(40),\n\t\t\t`hostname` VARCHAR(128),\n\t\t\t`zDate` TIMESTAMP NOT NULL,\n\t\t\t`uid` VARCHAR(40) NOT NULL,\n\t\t\t`MAC` VARCHAR(20) NOT NULL,\n\t\t\t`account` INT UNSIGNED NOT NULL,\n\t\t\t`QuerySize` BIGINT UNSIGNED NOT NULL,\n\t\t\t`hits` INT UNSIGNED NOT NULL,\n\t\t\t KEY `ipaddr`(`ipaddr`),\n\t\t\t KEY `hostname`(`hostname`),\n\t\t\t KEY `zDate`(`zDate`),\n\t\t\t KEY `uid`(`uid`),\n\t\t\t KEY `MAC`(`MAC`),\n\t\t\t KEY `account`(`account`)\n\t\t\t ) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`UserAuthDaysGrouped` (\n\t\t\t`ipaddr` VARCHAR(40),\n\t\t\t`hostname` VARCHAR(128),\n\t\t\t`uid` VARCHAR(40) NOT NULL,\n\t\t\t`MAC` VARCHAR(20) NOT NULL,\n\t\t\t`account` INT UNSIGNED NOT NULL,\n\t\t\t`QuerySize` BIGINT UNSIGNED NOT NULL,\n\t\t\t`hits` INT UNSIGNED NOT NULL,\n\t\t\t KEY `ipaddr`(`ipaddr`),\n\t\t\t KEY `hostname`(`hostname`),\n\t\t\t KEY `uid`(`uid`),\n\t\t\t KEY `MAC`(`MAC`),\n\t\t\t KEY `account`(`account`)\n\t\t\t ) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`wpad_rules` (\n\t\t\t`ID` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t`rulename` VARCHAR(128),\n\t\t\t`enabled` smallint(1) NOT NULL,\n\t\t\t`zorder` smallint(2) NOT NULL ,\n\t\t\t `dntlhstname` smallint(1) DEFAULT '0' ,\n\t\t\t`isResolvable` smallint(1) DEFAULT '0' ,\n\t\t\t`FinishbyDirect` smallint(1) DEFAULT '0' ,\n\t\t\t KEY `rulename`(`rulename`),\n\t\t\t KEY `FinishbyDirect`(`FinishbyDirect`),\n\t\t\t KEY `zorder`(`zorder`),\n\t\t\t KEY `enabled`(`enabled`)\n\t\t\t ) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->FIELD_EXISTS("wpad_rules", "zorder")) { $this->QUERY_SQL("ALTER TABLE `wpad_rules` ADD `zorder` smallint( 2 ) DEFAULT '0',ADD INDEX (`zorder`)"); } if (!$this->FIELD_EXISTS("wpad_rules", "dntlhstname")) { $this->QUERY_SQL("ALTER TABLE `wpad_rules` ADD `dntlhstname` smallint( 1 ) DEFAULT '0'"); } if (!$this->FIELD_EXISTS("wpad_rules", "isResolvable")) { $this->QUERY_SQL("ALTER TABLE `wpad_rules` ADD `isResolvable` smallint( 1 ) DEFAULT '0'"); } if (!$this->FIELD_EXISTS("wpad_sources_link", "zorder")) { $this->QUERY_SQL("ALTER TABLE `wpad_sources_link` ADD `zorder` smallint( 2 ) DEFAULT '0',ADD INDEX (`zorder`)"); } if (!$this->FIELD_EXISTS("wpad_rules", "FinishbyDirect")) { $this->QUERY_SQL("ALTER TABLE `wpad_rules` ADD `FinishbyDirect` smallint( 1 ) DEFAULT '0',ADD INDEX (`FinishbyDirect`)"); } $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`wpad_sources_link` (\n\t\t\t`zmd5` VARCHAR( 90 ) NOT NULL PRIMARY KEY ,\n\t\t\t`aclid` BIGINT UNSIGNED ,\n\t\t\t`negation` smallint(1) NOT NULL ,\n\t\t\t`gpid` INT UNSIGNED ,\n\t\t\t`zorder` smallint(2) NOT NULL ,\n\t\t\tINDEX ( `aclid` , `gpid`,`negation`,`zorder`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`wpad_white_link` (\n\t\t\t`zmd5` VARCHAR( 90 ) NOT NULL PRIMARY KEY ,\n\t\t\t`aclid` BIGINT UNSIGNED ,\n\t\t\t`negation` smallint(1) NOT NULL ,\n\t\t\t`gpid` INT UNSIGNED ,\n\t\t\t`zorder` smallint(2) NOT NULL ,\n\t\t\tINDEX ( `aclid` , `gpid`,`negation`,`zorder`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`wpad_destination` (\n\t\t\t`zmd5` VARCHAR( 90 ) NOT NULL PRIMARY KEY ,\n\t\t\t`aclid` BIGINT UNSIGNED ,\n\t\t\t`proxyserver` VARCHAR(128) NOT NULL ,\n\t\t\t`proxyport` INT UNSIGNED ,\n\t\t\t`zorder` smallint(2) NOT NULL ,\n\t\t\tINDEX ( `aclid` ,`zorder`, `proxyserver`,`proxyport`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`wpad_destination_rules` (\n\t\t\t`zmd5` VARCHAR( 90 ) NOT NULL PRIMARY KEY ,\n\t\t\t`rulename` VARCHAR(255) NOT NULL ,\n\t\t\t`aclid` BIGINT UNSIGNED ,\n\t\t\t`xtype` VARCHAR(40) NOT NULL, \n\t\t\t`value` TEXT NOT NULL, \n\t\t\t`destinations` TEXT NOT NULL, \n\t\t\t`proxyserver` VARCHAR(128) NOT NULL ,\n\t\t\t`proxyport` INT UNSIGNED ,\n\t\t\t`enabled` smallint(1) NOT NULL,\n\t\t\t`zorder` smallint(2) NOT NULL ,\n\t\t\t KEY `xtype` (`xtype`),\n\t\t\t KEY `enabled` (`enabled`),\n\t\t\t KEY `rulename` (`rulename`),\n\t\t\tINDEX ( `aclid` ,`zorder`, `proxyserver`,`proxyport`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->FIELD_EXISTS("wpad_destination_rules", "destinations")) { $this->QUERY_SQL("ALTER TABLE `wpad_destination_rules` ADD `destinations` TEXT NOT NULL"); } if (!$this->FIELD_EXISTS("wpad_destination_rules", "rulename")) { $this->QUERY_SQL("ALTER TABLE `wpad_destination_rules` ADD `rulename` VARCHAR(255) NOT NULL, ADD INDEX (`rulename`)"); } $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`wpad_events` (\n\t\t\t`zmd5` VARCHAR( 90 ) NOT NULL PRIMARY KEY ,\n\t\t\t`zDate` DATETIME NOT NULL ,\n\t\t\t`ruleid` INT UNSIGNED ,\n\t\t\t`ipaddr` VARCHAR( 90 ) NOT NULL ,\n\t\t\t`hostname` VARCHAR( 255 ) NOT NULL ,\n\t\t\t`browser` VARCHAR( 255 ) NOT NULL ,\n\t\t\t`script` TEXT NOT NULL ,\n\t\t\t KEY `ruleid` ( `ruleid`),\n\t\t\t KEY `ipaddr` ( `ipaddr`),\n\t\t\t KEY `hostname` ( `hostname`),\n\t\t\t KEY `zDate` ( `zDate`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->FIELD_EXISTS("wpad_events", "hostname")) { $this->QUERY_SQL("ALTER TABLE `wpad_events` ADD `hostname` VARCHAR( 255 ) NOT NULL ,ADD INDEX ( `hostname` )"); } $this->QUERY_SQL($sql, $this->database); if (!$this->ok) { if ($GLOBALS["AS_ROOT"]) { echo "Fatal !!! {$this->mysql_error}\n-----\n{$sql}\n-----\n"; } } if (!$this->TABLE_EXISTS('youtube_objects', $this->database)) { $sql = "CREATE TABLE `squidlogs`.`youtube_objects` (\n\t\t\t`youtubeid` VARCHAR(60) NOT NULL PRIMARY KEY,\n\t\t\t`category` VARCHAR(90),\n\t\t\t`title` VARCHAR(255) NOT NULL,\n\t\t\t`content` TEXT NOT NULL,\n\t\t\t`uploaded` TIMESTAMP NOT NULL,\n\t\t\t`hits` INT UNSIGNED NOT NULL,\n\t\t\t`duration` INT UNSIGNED NOT NULL,\n\t\t\t`thumbnail` longblob NOT NULL,\n\t\t\t KEY `category`(`category`),\n\t\t\t KEY `uploaded`(`uploaded`),\n\t\t\t KEY `title`(`title`),\n\t\t\t KEY `duration`(`duration`),\n\t\t\t KEY `hits`(`hits`)\n\t\t\t ) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS("youtube_dayz", $this->database)) { $sql = "CREATE TABLE `squidlogs`.`youtube_dayz` (\n\t\t\t`zDate` date NOT NULL,\n\t\t\t`hits` INT UNSIGNED NOT NULL,\n\t\t\t`ipaddr` VARCHAR(40),\n\t\t\t`hostname` VARCHAR(128),\n\t\t\t`uid` VARCHAR(40) NOT NULL,\n\t\t\t`MAC` VARCHAR(20) NOT NULL,\n\t\t\t`account` INT UNSIGNED NOT NULL,\n\t\t\t`youtubeid` VARCHAR(60) NOT NULL,\n\t\t\t KEY `ipaddr`(`ipaddr`),\n\t\t\t KEY `zDate`(`zDate`),\n\t\t\t KEY `hits`(`hits`),\n\t\t\t KEY `hostname`(`hostname`),\n\t\t\t KEY `uid`(`uid`),\n\t\t\t KEY `MAC`(`MAC`),\n\t\t\t KEY `account`(`account`)\n\t\t\t ) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('RegexCatz', $this->database)) { $sql = "CREATE TABLE `squidlogs`.`RegexCatz` (\n\t\t\t`ID` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t`zMD5` VARCHAR( 90 ) NOT NULL,\n\t\t\t`RegexPattern` VARCHAR( 255 ) NOT NULL,\n\t\t\t`category` VARCHAR( 90 ) NOT NULL,\n\t\t\t`enabled` TINYINT( 1 ) NOT NULL,\n\t\t\t`zDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n\t\t\tINDEX (`enabled`,`zDate`),\n\t\t\tKEY `zMD5`(`zMD5`),\n\t\t\tKEY `category`(`category`)\n\t\t\t \n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->FIELD_EXISTS("webtests", "checked")) { $this->QUERY_SQL("ALTER TABLE `webtests` ADD `checked` SMALLINT( 1 ) NOT NULL ,ADD INDEX ( `checked` )"); } if (!$this->TABLE_EXISTS('websites_caches_params', $this->database)) { $sql = "CREATE TABLE `squidlogs`.`websites_caches_params` (\n\t\t\t`sitename` VARCHAR(255) NOT NULL PRIMARY KEY,\n\t\t\t`MIN_AGE` INT( 10 ) NOT NULL,\n\t\t\t`PERCENT` INT( 10 ) NOT NULL,\n\t\t\t`MAX_AGE` INT( 10 ) NOT NULL,\n\t\t\t`options` TINYINT(1 ) NOT NULL,\n\t\t\tINDEX ( `MIN_AGE` , `PERCENT` , `MAX_AGE`,`options`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('webfilters_sqtimes_rules', $this->database)) { $sql = "CREATE TABLE `squidlogs`.`webfilters_sqtimes_rules` (\n\t\t\t`ID` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t`TimeName` VARCHAR( 128 ) NOT NULL ,\n\t\t\t`TimeCode` TEXT NOT NULL ,\n\t\t\t`TemplateError` TEXT NOT NULL ,\n\t\t\t`enabled` SMALLINT( 1 ) NOT NULL ,\n\t\t\t`Allow` SMALLINT( 1 ) NOT NULL ,\n\t\t\tINDEX ( `TimeName` , `enabled`,`Allow`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('webfilters_schedules', $this->database)) { $sql = "CREATE TABLE `squidlogs`.`webfilters_schedules` (\n\t\t\t`ID` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t`TimeText` VARCHAR( 128 ) NOT NULL ,\n\t\t\t`TimeDescription` VARCHAR( 128 ) NOT NULL ,\n\t\t\t`TaskType` SMALLINT( 1 ) NOT NULL ,\n\t\t\t`enabled` SMALLINT( 1 ) NOT NULL ,\n\t\t\tINDEX ( `TaskType` , `TimeDescription`,`enabled`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('webfilters_bigcatzlogs', $this->database)) { $sql = "CREATE TABLE `squidlogs`.`webfilters_bigcatzlogs` (\n\t\t\t`ID` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t`zDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,\n\t\t\t`category_table` VARCHAR( 90 ) NOT NULL ,\n\t\t\t`category` VARCHAR( 60 ) NOT NULL ,\n\t\t\t`AddedItems` BIGINT UNSIGNED ,\n\t\t\tINDEX ( `AddedItems` , `category`,`zDate`),\n\t\t\tKEY `category_table`(`category_table`)\n\t\t\t\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->FIELD_EXISTS("webtests", "family")) { $this->QUERY_SQL("ALTER TABLE `webtests` ADD `family` VARCHAR( 128 ) NOT NULL,ADD INDEX (`family`)"); } if (!$this->FIELD_EXISTS("webtests", "zDate")) { $this->QUERY_SQL("ALTER TABLE `webtests` ADD `zDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,ADD INDEX (`zDate`)"); } if (!$this->FIELD_EXISTS("webtests", "ipaddr")) { $this->QUERY_SQL("ALTER TABLE `webtests` ADD `ipaddr` VARCHAR(50) NOT NULL,ADD INDEX (`ipaddr`)"); } if (!$this->FIELD_EXISTS("webtests", "SiteInfos")) { $this->QUERY_SQL("ALTER TABLE `webtests` ADD `SiteInfos` TEXT NOT NULL"); } if (!$this->FIELD_EXISTS("webfilters_sqtimes_rules", "Allow")) { $this->QUERY_SQL("ALTER TABLE `webfilters_sqtimes_rules` ADD `Allow` SMALLINT( 1 ) NOT NULL ,ADD INDEX ( `Allow` )"); } if (!$this->FIELD_EXISTS("webfilters_sqtimes_rules", "TemplateError")) { $this->QUERY_SQL("ALTER TABLE `webfilters_sqtimes_rules` ADD `TemplateError` TEXT NOT NULL"); } if (!$this->TABLE_EXISTS('webfilters_sqtimes_assoc', $this->database)) { $sql = "CREATE TABLE `squidlogs`.`webfilters_sqtimes_assoc` (\n\t\t\t`zMD5` VARCHAR( 90 ) NOT NULL PRIMARY KEY ,\n\t\t\t`TimeRuleID` INT UNSIGNED ,\n\t\t\t`gpid` INT UNSIGNED ,\n\t\t\tINDEX ( `zMD5` , `TimeRuleID`,`gpid`)\n\t\t\t) ENGINE=MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->ok) { if ($GLOBALS["AS_ROOT"]) { echo "Fatal !!! {$this->mysql_error}\n-----\n{$sql}\n-----\n"; } } } $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`webfilters_sqgroups` (\n\t\t\t`ID` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t`GroupName` VARCHAR( 128 ) NOT NULL ,\n\t\t\t`GroupType` VARCHAR(50) NOT NULL ,\n\t\t\t`acltpl` VARCHAR(90) ,\n\t\t\t`tplreset` SMALLINT( 1 ) NOT NULL ,\n\t\t\t`enabled` SMALLINT( 1 ) NOT NULL ,\n\t\t\t`params` LONGTEXT NOT NULL,\n\t\t\tINDEX ( `GroupName` , `enabled`,`GroupType`),\n\t\t\tKEY `acltpl`(`acltpl`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`portals` (\n\t\t\t`ID` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t`PortalName` VARCHAR( 255 ) NOT NULL ,\n\t\t\t`ListenInterface` VARCHAR(20) NOT NULL ,\n\t\t\t`enabled` SMALLINT( 1 ) NOT NULL ,\n\t\t\tINDEX ( `PortalName` , `enabled`,`ListenInterface`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->TABLE_EXISTS('webfilters_sqitems', $this->database)) { $sql = "CREATE TABLE `squidlogs`.`webfilters_sqitems` (\n\t\t\t`ID` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t`pattern` VARCHAR( 128 ) NOT NULL ,\n\t\t\t`other` TEXT,\n\t\t\t`gpid` INT UNSIGNED ,\n\t\t\t`enabled` SMALLINT( 1 ) NOT NULL ,\n\t\t\tINDEX ( `pattern` , `enabled`,`gpid`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->FIELD_EXISTS("webfilters_sqitems", "other")) { $this->QUERY_SQL("ALTER TABLE `webfilters_sqitems` ADD `other` TEXT"); } $sql = "CREATE TABLE IF NOT EXISTS `webfilters_sqaclsports` (\n\t\t\t`aclport` SMALLINT( 5 ) PRIMARY KEY,\n\t\t\t`portname` VARCHAR( 128 ) NOT NULL,\n\t\t\t`interface` VARCHAR( 128 ),\n\t\t\t`enabled` SMALLINT( 1 ) NOT NULL,\n\t\t\tKEY `portname`(`portname`),\n\t\t\tKEY `aclport`(`aclport`),\n\t\t\tKEY `enabled`(`enabled`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->ok) { if ($GLOBALS["AS_ROOT"]) { echo "Fatal !!! {$this->mysql_error}\n-----\n{$sql}\n-----\n"; } } if (!$this->FIELD_EXISTS("webfilters_sqaclsports", "interface")) { $this->QUERY_SQL("ALTER TABLE `webfilters_sqaclsports` ADD `interface` VARCHAR(128),ADD INDEX(`interface`)"); } if (!$this->FIELD_EXISTS("webfilters_sqaclsports", "enabled")) { $this->QUERY_SQL("ALTER TABLE `webfilters_sqaclsports` ADD `enabled` smallint(1) NOT NULL,ADD INDEX(`enabled`)"); } $sql = "CREATE TABLE IF NOT EXISTS `webfilters_sqacls` (\n\t\t\t`ID` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t`PortDirection` smallint( 2 ) NOT NULL DEFAULT '0',\n\t\t\t`aclname` VARCHAR( 128 ) NOT NULL ,\n\t\t\t`aclport` SMALLINT( 5 ) NOT NULL ,\n\t\t\t`acltpl` VARCHAR( 90 ),\n\t\t\t`enabled` SMALLINT( 1 ) NOT NULL ,\n\t\t\t`aclgroup` SMALLINT( 1 ) NOT NULL,\n\t\t\t`aclgpid` INT UNSIGNED,\t\t\t\n\t\t\t`xORDER` SMALLINT( 2 ),\n\t\t\tINDEX ( `aclname` , `enabled`,`xORDER`),\n\t\t\tKEY `acltpl`(`acltpl`),\n\t\t\tKEY `PortDirection`(`PortDirection`),\n\t\t\tKEY `aclport`(`aclport`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->ok) { if ($GLOBALS["AS_ROOT"]) { echo "Fatal !!! {$this->mysql_error}\n-----\n{$sql}\n-----\n"; } } $sql = "CREATE TABLE IF NOT EXISTS `meta_webfilters_acls` (\n\t\t\t`ID` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t`aclname` VARCHAR( 128 ) NOT NULL ,\n\t\t\t`acltpl` VARCHAR( 90 ),\n\t\t\t`enabled` SMALLINT( 1 ) NOT NULL ,\n\t\t\t`metagroup` INT UNSIGNED NOT NULL DEFAULT 0,\n\t\t\t`metauuid` VARCHAR(90) NULL,\n\t\t\t`aclgpid` INT UNSIGNED,\n\t\t\t`httpaccess` VARCHAR( 60 ) NOT NULL ,\n\t\t\t`httpaccess_value` SMALLINT( 1 ) NOT NULL,\n\t\t\t`httpaccess_data` TEXT NOT NULL,\t\t\t\t\n\t\t\t`xORDER` SMALLINT( 2 ),\n\t\t\tINDEX ( `aclname` , `enabled`,`xORDER`),\n\t\t\tKEY `acltpl`(`acltpl`),\n\t\t\tKEY `metagroup`(`metagroup`),\n\t\t\tKEY `httpaccess`(`httpaccess`),\n\t\t\tKEY `metauuid`(`metauuid`),\n\t\t\tKEY `httpaccess_value`(`httpaccess_value`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql); $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`meta_webfilters_sqacllinks` (\n\t\t\t`ID` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t`aclid` BIGINT UNSIGNED ,\n\t\t\t`negation` smallint(1) NOT NULL ,\n\t\t\t`gpid` INT UNSIGNED ,\n\t\t\t`zorder` INT( 10 ) NOT NULL ,\n\t\t\tINDEX ( `aclid` , `gpid`,`negation`),\n\t\t\tKEY `zorder`(`zorder`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql); $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`meta_webfilters_groups` (\n\t\t\t`ID` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t`groupname` VARCHAR( 128 ) NOT NULL ,\n\t\t\t`grouptype` VARCHAR(50) NOT NULL ,\n\t\t\t`acltpl` VARCHAR(90) ,\n\t\t\t`enabled` SMALLINT( 1 ) NOT NULL ,\n\t\t\t`params` LONGTEXT NOT NULL,\n\t\t\tINDEX ( `groupname` , `enabled`,`grouptype`),\n\t\t\tKEY `acltpl`(`acltpl`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql); $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`webfilters_sqaclaccess` (\n\t\t`zmd5` VARCHAR( 90 ) NOT NULL PRIMARY KEY ,\n\t\t`aclid` BIGINT UNSIGNED ,\n\t\t`httpaccess` VARCHAR( 60 ) NOT NULL ,\n\t\t`httpaccess_value` SMALLINT( 1 ) NOT NULL,\n\t\t`httpaccess_data` TEXT NOT NULL,\n\t\tINDEX ( `aclid` ,`httpaccess_value`),\n\t\tKEY `httpaccess`(`httpaccess`)\n\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->ok) { if ($GLOBALS["AS_ROOT"]) { echo "Fatal !!! {$this->mysql_error}\n-----\n{$sql}\n-----\n"; } } $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`sslrules_sqacllinks` (\n\t\t`zmd5` VARCHAR( 90 ) NOT NULL PRIMARY KEY ,\n\t\t`aclid` BIGINT UNSIGNED ,\n\t\t`negation` smallint(1) NOT NULL ,\n\t\t`gpid` INT UNSIGNED ,\n\t\t`zOrder` INT( 10 ) NOT NULL ,\n\t\tINDEX ( `aclid` , `gpid`,`negation`),\n\t\tKEY `zOrder`(`zOrder`)\n\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->ok) { if ($GLOBALS["AS_ROOT"]) { echo "Fatal !!! {$this->mysql_error}\n-----\n{$sql}\n-----\n"; } } $sql = "CREATE TABLE `squidlogs`.`webfilters_sqacllinks` (\n\t\t\t`zmd5` VARCHAR( 90 ) NOT NULL PRIMARY KEY ,\n\t\t\t`aclid` BIGINT UNSIGNED ,\n\t\t\t`negation` smallint(1) NOT NULL ,\n\t\t\t`gpid` INT UNSIGNED ,\n\t\t\t`zOrder` INT( 10 ) NOT NULL ,\n\t\t\tINDEX ( `aclid` , `gpid`,`negation`),\n\t\t\tKEY `zOrder`(`zOrder`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->ok) { if ($GLOBALS["AS_ROOT"]) { echo "Fatal !!! {$this->mysql_error}\n-----\n{$sql}\n-----\n"; } } $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`qos_sqacllinks` (\n\t\t\t`zmd5` VARCHAR( 90 ) NOT NULL PRIMARY KEY ,\n\t\t\t`aclid` BIGINT UNSIGNED ,\n\t\t\t`negation` smallint(1) NOT NULL ,\n\t\t\t`gpid` INT UNSIGNED ,\n\t\t\t`zOrder` INT( 10 ) NOT NULL ,\n\t\t\tINDEX ( `aclid` , `gpid`,`negation`),\n\t\t\tKEY `zOrder`(`zOrder`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->ok) { if ($GLOBALS["AS_ROOT"]) { echo "Fatal !!! {$this->mysql_error}\n-----\n{$sql}\n-----\n"; } } $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`webfilters_usersasks` (\n\t\t`zmd5` VARCHAR( 90 ) NOT NULL PRIMARY KEY ,\n\t\t`zDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,\n\t\t`ipaddr` VARCHAR( 60 ) NOT NULL ,\n\t\t`sitename` VARCHAR( 255 ) NOT NULL ,\n\t\t`uid` VARCHAR( 128 ) NOT NULL ,\n\t\tINDEX ( `ipaddr`),\n\t\tKEY `sitename`(`sitename`),\n\t\tKEY `uid`(`uid`)\n\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`firewallfilter_sqacllinks` (\n\t\t\t`zmd5` VARCHAR( 90 ) NOT NULL PRIMARY KEY ,\n\t\t\t`aclid` BIGINT UNSIGNED ,\n\t\t\t`negation` smallint(1) NOT NULL ,\n\t\t\t`direction` smallint(1) NOT NULL ,\n\t\t\t`gpid` INT UNSIGNED ,\n\t\t\t`zOrder` INT( 10 ) NOT NULL ,\n\t\t\tINDEX ( `aclid` , `gpid`,`negation`),\n\t\t\tKEY `zOrder`(`zOrder`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->ok) { if ($GLOBALS["AS_ROOT"]) { echo "Fatal !!! {$this->mysql_error}\n-----\n{$sql}\n-----\n"; } } if (!$this->TABLE_EXISTS('squid_storelogs', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `squid_storelogs` (\n\t\t\t\t `ID` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t `filename` varchar(128) NOT NULL,\n\t\t\t\t `fileext` varchar(4) NOT NULL,\n\t\t\t\t `filesize` BIGINT UNSIGNED NOT NULL,\n\t\t\t\t `filecontent` longblob NOT NULL,\n\t\t\t\t `filetime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n\t\t\t\t `Compressedsize` BIGINT UNSIGNED NOT NULL,\n\t\t\t\t PRIMARY KEY (`ID`),\n\t\t\t\t KEY `filename` (`filename`),\n\t\t\t\t KEY `filesize` (`filesize`),\n\t\t\t\t KEY `fileext` (`fileext`),\n\t\t\t\t KEY `filetime` (`filetime`),\n\t\t\t\t KEY `Compressedsize` (`Compressedsize`)\n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('webfilters_dbstats', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `webfilters_dbstats` (\n\t\t\t\t `category` varchar(128) NOT NULL PRIMARY KEY,\n\t\t\t\t `articasize` INT UNSIGNED NOT NULL,\n\t\t\t\t `unitoulouse` INT UNSIGNED NOT NULL,\n\t\t\t\t `persosize` BIGINT UNSIGNED NOT NULL,\n\t\t\t\t KEY `articasize` (`articasize`),\n\t\t\t\t KEY `unitoulouse` (`unitoulouse`),\n\t\t\t\t KEY `persosize` (`persosize`)\n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } $sql = "CREATE TABLE IF NOT EXISTS `webfilters_nodes` (\n\t\t`MAC` VARCHAR( 90 ) NOT NULL PRIMARY KEY ,\n\t\t`uid` VARCHAR( 128 ) NOT NULL ,\n\t\t`hostname` VARCHAR( 128 ),\n\t\t`group` VARCHAR( 128 ),\n\t\t`nmap` smallint(1) NOT NULL ,\n\t\t`nmapreport` TEXT,\n\t\t KEY `group` (`group`),\n\t\t INDEX ( `uid`,`nmap`)\n\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->TABLE_EXISTS('webfilters_ipaddr', $this->database)) { $sql = "CREATE TABLE `squidlogs`.`webfilters_ipaddr` (\n\t\t\t`ipaddr` VARCHAR( 90 ) NOT NULL PRIMARY KEY ,\n\t\t\t `ip` int(10) unsigned NOT NULL default '0',\n\t\t\t`uid` VARCHAR( 128 ) NOT NULL ,\n\t\t\t`hostname` VARCHAR( 128 ),\n\t\t\t`group` VARCHAR( 128 ),\n\t\t\t INDEX ( `uid`,`hostname`),\n\t\t\t KEY `group` (`group`),\n\t\t\t KEY `ip` (`ip`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('webfilters_backupeddbs', $this->database)) { $sql = "CREATE TABLE `squidlogs`.`webfilters_backupeddbs` (\n\t\t\t`filepath` VARCHAR( 128 ) NOT NULL PRIMARY KEY ,\n\t\t\t`zDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,\n\t\t\t`size` BIGINT UNSIGNED ,\n\t\t\tINDEX ( `zDate`),\n\t\t\tKEY `size`(`size`)\n\t\t\t)"; $this->QUERY_SQL($sql, $this->database); } if (!$this->FIELD_EXISTS("webfilters_nodes", "group")) { $this->QUERY_SQL("ALTER TABLE `webfilters_nodes` ADD `group` VARCHAR( 128 ),ADD INDEX ( `group` ) "); } if (!$this->FIELD_EXISTS("webfilters_ipaddr", "group")) { $this->QUERY_SQL("ALTER TABLE `webfilters_ipaddr` ADD `group` VARCHAR( 128 ),ADD INDEX ( `group` ) "); } if (!$this->FIELD_EXISTS("webfilters_nodes", "nmap")) { $this->QUERY_SQL("ALTER TABLE `webfilters_nodes` ADD `nmap` SMALLINT( 1 ) NOT NULL ,ADD INDEX ( `nmap` ) "); } if (!$this->FIELD_EXISTS("webfilters_nodes", "nmapreport")) { $this->QUERY_SQL("ALTER TABLE `webfilters_nodes` ADD `nmapreport` TEXT NOT NULL"); } if (!$this->FIELD_EXISTS("webfilters_usersasks", "uid")) { $this->QUERY_SQL("ALTER TABLE `webfilters_usersasks` ADD `uid` VARCHAR( 128 ) NOT NULL ,ADD INDEX ( `uid` ) "); } if (!$this->FIELD_EXISTS("webfilters_usersasks", "zDate")) { $this->QUERY_SQL("ALTER TABLE `webfilters_usersasks` ADD `zDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"); } if (!$this->FIELD_EXISTS("webfilters_sqacls", "acltpl")) { $this->QUERY_SQL("ALTER TABLE `webfilters_sqacls` ADD `acltpl` VARCHAR( 90 ) ,ADD INDEX ( `acltpl` ) "); } if (!$this->FIELD_EXISTS("webfilters_sqgroups", "acltpl")) { $this->QUERY_SQL("ALTER TABLE `webfilters_sqgroups` ADD `acltpl` VARCHAR( 90 ) ,ADD INDEX ( `acltpl` ) "); } if (!$this->FIELD_EXISTS("webfilters_sqgroups", "tplreset")) { $this->QUERY_SQL("ALTER TABLE `webfilters_sqgroups` ADD `tplreset` smallint(1) ,ADD INDEX ( `tplreset` ) "); } if (!$this->FIELD_EXISTS("webfilters_sqaclaccess", "httpaccess_data")) { $this->QUERY_SQL("ALTER TABLE `webfilters_sqaclaccess` ADD `httpaccess_data` VARCHAR( 255 ) NOT NULL"); } if (!$this->TABLE_EXISTS('squidservers', $this->database)) { $sql = "CREATE TABLE `squidlogs`.`squidservers` (\n\t\t\t\t`ipaddr` VARCHAR( 90 ) NOT NULL ,\n\t\t\t\t`port` INT( 2 ) NOT NULL DEFAULT 9000 ,\n\t\t\t\t`hostname` VARCHAR( 128 ) NOT NULL ,\n\t\t\t\t`udpated` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,\n\t\t\t\t`created` TIMESTAMP NOT NULL ,\n\t\t\t\tPRIMARY KEY ( `ipaddr` ) ,\n\t\t\t\tINDEX ( `hostname` , `udpated` , `created` )\n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->ok) { writelogs("{$this->mysql_error}", __FUNCTION__, __FILE__, __LINE__); } } if (!$this->FIELD_EXISTS("squidservers", "udpated")) { $this->QUERY_SQL("ALTER TABLE `squidservers` ADD `udpated` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,ADD INDEX ( `udpated` )"); } $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`ftpunivtlse1fr` (\n\t\t\t\t`zmd5` VARCHAR( 90 ) NOT NULL ,\n\t\t\t\t`filename` VARCHAR( 60) NOT NULL,\n\t\t\t\t`websitesnum` INT( 10 ) NOT NULL ,\n\t\t\t\t`zDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,\n\t\t\t\tPRIMARY KEY ( `filename` ) ,\n\t\t\t\tINDEX ( `websitesnum` , `zmd5` , `zDate` )\n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`univtlse1fr` (\n\t\t\t\t`category` VARCHAR( 90 ) NOT NULL ,\n\t\t\t\t`websitesnum` INT UNSIGNED ,\n\t\t\t\t`zDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,\n\t\t\t\tPRIMARY KEY ( `category` ) ,\n\t\t\t\tINDEX ( `websitesnum` , `zDate` )\n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->TABLE_EXISTS('webfilter_members', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `webfilter_members` (\n\t\t\t\t `ID` INT( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t\t\tpattern VARCHAR(90) NOT NULL,\n\t\t\t\t\tenabled smallint(1) NOT NULL DEFAULT '1' ,\n\t\t\t\t\tgroupid INT(10) NOT NULL DEFAULT '0' ,\n\t\t\t\t\tmembertype smallint(1) NOT NULL DEFAULT '0' ,\n\t\t\t\t\t KEY `pattern` (`pattern`),\n\t\t\t\t\t KEY `groupid` (`groupid`),\n\t\t\t\t\t KEY `membertype` (`membertype`),\n\t\t\t\t\t KEY `enabled` (`enabled`)\n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('cacheconfig', $this->database)) { $sql = "CREATE TABLE `cacheconfig` (\n\t\t\t\t\t`uuid` VARCHAR( 90 ) NOT NULL ,\n\t\t\t\t\t`hostname` VARCHAR( 128 ) NOT NULL ,\n\t\t\t\t\t`workers` INT( 2 ) NOT NULL ,\n\t\t\t\t\t`cachesDirectory` VARCHAR( 255 ) NOT NULL,\n\t\t\t\t\t`globalCachesize` INT UNSIGNED ,\n\t\t\t\t\t`alternateConfig` MEDIUMTEXT NOT NULL ,\n\t\t\t\t\tPRIMARY KEY ( `uuid` ) ,\n\t\t\t\t\tINDEX ( `hostname` , `workers` , `globalCachesize` )\n\t\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('cachestatus', $this->database)) { $sql = "CREATE TABLE `cachestatus` (\n\t\t\t\t\t`ID` INT( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t\t\t`uuid` VARCHAR( 90 ) NOT NULL ,\n\t\t\t\t\t`cachedir` VARCHAR( 255 ) NOT NULL ,\n\t\t\t\t\t`maxsize` BIGINT UNSIGNED ,\n\t\t\t\t\t`currentsize` BIGINT UNSIGNED ,\n\t\t\t\t\t`pourc` VARCHAR( 20 ) NOT NULL,\n\t\t\t\t\tINDEX ( `maxsize` , `currentsize` , `pourc` ),\n\t\t\t\t\tKEY `uuid` (`uuid`),\n\t\t\t\t\tKEY `cachedir` (`cachedir`)\n\t\t\t\t\t) ENGINE=MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->FIELD_EXISTS("webfilter_members", "membertype")) { $this->QUERY_SQL("ALTER TABLE `webfilter_members` \n\t\t\tADD `membertype` smallint(1) NOT NULL ,ADD KEY `membertype` (`membertype`)"); } if (!$this->TABLE_EXISTS('webfilter_bannedexts', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `webfilter_bannedexts` (\n\t\t\t\t `zmd5` varchar(90) NOT NULL,\n\t\t\t\t `ext` varchar(10) NOT NULL,\n\t\t\t\t `description` varchar(255) NOT NULL,\n\t\t\t\t `enabled` smallint(1) NOT NULL DEFAULT '1',\n\t\t\t\t `ruleid` int(2) NOT NULL,\n\t\t\t\t UNIQUE KEY `zmd5` (`zmd5`),\n\t\t\t\t KEY `ext` (`ext`,`enabled`,`ruleid`),\n\t\t\t\t KEY `description` (`description`)\n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('webfilter_bannedextsdoms', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `webfilter_bannedextsdoms` (\n\t\t\t\t `zmd5` varchar(90) NOT NULL,\n\t\t\t\t `ext` varchar(10) NOT NULL,\n\t\t\t\t `description` varchar(255) NOT NULL,\n\t\t\t\t `enabled` smallint(1) NOT NULL DEFAULT '1',\n\t\t\t\t `ruleid` int(2) NOT NULL,\n\t\t\t\t UNIQUE KEY `zmd5` (`zmd5`),\n\t\t\t\t KEY `ext` (`ext`,`enabled`,`ruleid`),\n\t\t\t\t KEY `description` (`description`)\n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('webfilter_avwhitedoms', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `webfilter_avwhitedoms` (\n\t\t\t\t `websitename` varchar(128) NOT NULL,\n\t\t\t\t PRIMARY KEY (`websitename`)\n\t\t\t\t) ENGINE=MYISAM;"; $this->QUERY_SQL($sql, $this->database); } $this->QUERY_SQL("CREATE TABLE IF NOT EXISTS `dashboard_notcached` (\n\t\t\t`TIME` DATETIME,\n\t\t\t`PROXYNAME` VARCHAR(128),\n\t\t\t`SIZE` BIGINT UNSIGNED,\n\t\t\tKEY `PROXYNAME` (`PROXYNAME`),\n\t\t\tKEY `TIME` (`TIME`)\n\t\t\t) ENGINE=MYISAM;"); $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`hotspot_blckports` (\n\t\t\t`port` BIGINT UNSIGNED ,\n\t\t\t`enabled` smallint(1) NOT NULL,\n\t\t\tPRIMARY KEY ( `port` ) ,\n\t\t\tINDEX ( `enabled`)\n\t\t\t\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->ok) { echo "CREATE TABLE hotspot_blckports Failed {$this->mysql_error}\n"; } $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`hotspot_whitemacs` (\n\t\t\t`MAC` VARCHAR(90) NOT NULL ,\n\t\t\t`enabled` smallint(1) NOT NULL,\n\t\t\t`username` VARCHAR(120) NULL,\n\t\t\tPRIMARY KEY ( `MAC` ) ,\n\t\t\tINDEX ( `enabled`)\n\t\t\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->ok) { echo "CREATE TABLE hotspot_blckports Failed {$this->mysql_error}\n"; } if (!$this->FIELD_EXISTS("hotspot_whitemacs", "username")) { $this->QUERY_SQL("ALTER TABLE `hotspot_whitemacs` ADD `username` VARCHAR(128) NULL ,\n\t\t\t\t\tADD INDEX ( `username` )"); } $this->check_hotspot_session(); $this->check_hotspot_tables(); if (!$this->TABLE_EXISTS('webfilter_dnsbl', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `webfilter_dnsbl` (\n\t\t\t\t `dnsbl` varchar(128) NOT NULL,\n\t\t\t\t `name` varchar(128) NOT NULL,\n\t\t\t\t `uri` varchar(128) NOT NULL ,\n\t\t\t\t `enabled` smallint(1) NOT NULL DEFAULT '1',\n\t\t\t\t UNIQUE KEY `dnsbl` (`dnsbl`),\n\t\t\t\t KEY `name` (`name`,`enabled`)\n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } $this->checkDNSBLTables(); $sql = "CREATE TABLE IF NOT EXISTS `webfilter_updateev` (\n\t\t\t`zDate` TIMESTAMP NOT NULL ,\n\t\t\t`description` MEDIUMTEXT NOT NULL ,\n\t\t\t`function` VARCHAR( 60 ) NOT NULL ,\n\t\t\t`filename` VARCHAR( 50 ) NOT NULL ,\n\t\t\t`line` INT( 10 ) NOT NULL ,\n\t\t\t`category` VARCHAR( 50 ) NOT NULL ,\n\t\t\t`TASKID` BIGINT UNSIGNED ,\n\t\t\tINDEX ( `zDate` , `function` , `filename` , `line` , `category`,`TASKID` )\n\t\t\t) ENGINE=MYISAM;"; $this->QUERY_SQL($sql, 'artica_events'); if (!$this->TABLE_EXISTS('webfilters_blkwhlts', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `webfilters_blkwhlts` (\n\t\t\t `pattern` varchar(128) NOT NULL,\n\t\t\t `description` text NOT NULL,\n\t\t\t `enabled` smallint(1) NOT NULL,\n\t\t\t `PatternType` smallint(1) NOT NULL,\n\t\t\t `blockType` smallint(1) NOT NULL,\n\t\t\t `zmd5` VARCHAR( 90 ) NOT NULL,\n\t\t\t PRIMARY KEY (`zmd5`),\n\t\t\t KEY `pattern` (`pattern`),\n\t\t\t KEY `enabled` (`enabled`),\n\t\t\t KEY `blockType` (`blockType`),\n\t\t\t FULLTEXT KEY `description` (`description`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('UserAutDB', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `UserAutDB` (\n\t\t\t `zmd5` varchar(90) NOT NULL,\n\t\t\t `MAC` varchar(90) NOT NULL,\n\t\t\t `ipaddr` varchar(50) NOT NULL,\n\t\t\t `uid` varchar(128) NOT NULL,\n\t\t\t `hostname` varchar(128) NOT NULL,\n\t\t\t `UserAgent` varchar(128) NOT NULL,\n\t\t\t PRIMARY KEY (`zmd5`),\n\t\t\t KEY `MAC` (`MAC`),\n\t\t\t KEY `ipaddr` (`ipaddr`),\n\t\t\t KEY `uid` (`uid`),\n\t\t\t KEY `hostname` (`hostname`),\n\t\t\t KEY `UserAgent` (`UserAgent`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('webfilter_blks', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `webfilter_blks` (\n\t\t\t\t `ID` INT( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t\t webfilter_id INT(2) NOT NULL,\n\t\t\t\t \tmodeblk smallint(1) NOT NULL,\n\t\t\t\t \tcategory VARCHAR(128) NOT NULL,\n\t\t\t\t KEY `webfilter_id` (`webfilter_id`),\n\t\t\t\t KEY `category` (`category`),\n\t\t\t\t KEY `modeblk` (`modeblk`)\n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } $sql = "CREATE TABLE IF NOT EXISTS `cicap_profiles_blks` (\n\t\t\t\t `ID` INT( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t\t mainid INT(3) NOT NULL,\n\t\t\t\t \tbltype smallint(1) NOT NULL,\n\t\t\t\t \tcategory VARCHAR(128) NOT NULL,\n\t\t\t\t KEY `mainid` (`mainid`),\n\t\t\t\t KEY `category` (`category`),\n\t\t\t\t KEY `bltype` (`bltype`)\n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `cicap_rules` (\n\t\t\t\t `ID` INT( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t\t rulename VARCHAR(128) NOT NULL,\n\t\t\t\t \tGroupType smallint(1) NOT NULL,\n\t\t\t\t \tProfileID INT(10) NOT NULL,\n\t\t\t\t\tenabled smallint(1) NOT NULL,\n\t\t\t\t KEY `rulename` (`rulename`),\n\t\t\t\t KEY `GroupType` (`GroupType`),\n\t\t\t\t KEY `enabled` (`enabled`)\n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->TABLE_EXISTS('webfilter_termsg', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `webfilter_termsg` (\n\t\t\t\t `ID` BIGINT( 100) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t\t groupname VARCHAR(128) NOT NULL,\n\t\t\t\t enabled smallint(1) NOT NULL,\n\t\t\t\t KEY `groupname` (`groupname`),\n\t\t\t\t KEY `enabled` (`enabled`)\n\t\t\t\t \n\t\t\t\t) ENGINE=MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('webfilter_terms', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `webfilter_terms` (\n\t\t\t\t `ID` BIGINT( 100) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t\t term VARCHAR(255) NOT NULL,\n\t\t\t\t enabled smallint(1) NOT NULL,\n\t\t\t\t xregex smallint(1) NOT NULL,\n\t\t\t\t UNIQUE KEY `term` (`term`),\n\t\t\t\t KEY `enabled` (`enabled`),\n\t\t\t\t KEY `xregex` (`xregex`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } $sql = "CREATE TABLE IF NOT EXISTS `dashboard_cached` (\n\t\t\t`TIME` DATETIME,\n\t\t\t`PROXYNAME` VARCHAR(128),\n\t\t\t`SIZE` BIGINT UNSIGNED,\n\t\t\tKEY `PROXYNAME` (`PROXYNAME`),\n\t\t\tKEY `TIME` (`TIME`)\n\t\t\t) ENGINE=MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->FIELD_EXISTS("webfilter_terms", "xregex")) { $this->QUERY_SQL("ALTER TABLE `webfilter_terms` ADD `xregex` smallint( 1 ) NOT NULL ,ADD INDEX ( `xregex` )"); } if (!$this->TABLE_EXISTS('webfilter_termsassoc', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `webfilter_termsassoc` (\n\t\t\t\t `ID` BIGINT( 100) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t\t term_group BIGINT( 100) NOT NULL,\n\t\t\t\t termid BIGINT( 100)NOT NULL,\n\t\t\t\t KEY `term_group` (`term_group`),\n\t\t\t\t KEY `termid` (`termid`)\n\t\t\t) "; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('webfilter_ufdbexpr', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `webfilter_ufdbexpr` (\n\t\t\t\t `ID` BIGINT( 100) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t\t rulename VARCHAR(128) NOT NULL,\n\t\t\t\t ruleid BIGINT( 100) NOT NULL,\n\t\t\t\t enabled smallint(1) NOT NULL,\n\t\t\t\t KEY `rulename` (`rulename`),\n\t\t\t\t KEY `enabled` (`enabled`),\n\t\t\t\t KEY `ruleid` (`ruleid`)\n\t\t\t\t \n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('webfilter_ufdbexprassoc', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `webfilter_ufdbexprassoc` (\n\t\t\t\t `ID` BIGINT( 100) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t\t groupid BIGINT( 100) NOT NULL,\n\t\t\t\t termsgid BIGINT( 100) NOT NULL,\n\t\t\t\t enabled smallint(1) NOT NULL,\n\t\t\t\t KEY `ID` (`ID`),\n\t\t\t\t KEY `groupid` (`groupid`),\n\t\t\t\t KEY `enabled` (`enabled`),\n\t\t\t\t KEY `termsgid` (`termsgid`)\n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('webfilters_dtimes_blks', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `webfilters_dtimes_blks` (\n\t\t\t\t `ID` INT( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t\t webfilter_id INT(2) NOT NULL,\n\t\t\t\t \tmodeblk smallint(1) NOT NULL,\n\t\t\t\t \tcategory VARCHAR(128) NOT NULL,\n\t\t\t\t KEY `webfilter_id` (`webfilter_id`),\n\t\t\t\t KEY `category` (`category`),\n\t\t\t\t KEY `modeblk` (`modeblk`)\n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } $sql = "CREATE TABLE IF NOT EXISTS `webfilters_quotas_blks` (\n\t\t\t\t `ID` INT( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t\t webfilter_id INT(2) NOT NULL,\n\t\t\t\t \tmodeblk smallint(1) NOT NULL,\n\t\t\t\t \tcategory VARCHAR(128) NOT NULL,\n\t\t\t\t KEY `webfilter_id` (`webfilter_id`),\n\t\t\t\t KEY `category` (`category`),\n\t\t\t\t KEY `modeblk` (`modeblk`)\n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->TABLE_EXISTS('webfilters_rewriterules', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `webfilters_rewriterules` (\n\t\t\t\t `ID` INT( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t\t rulename VARCHAR(128) NOT NULL,\n\t\t\t\t \tenabled smallint(1) NOT NULL DEFAULT 1,\n\t\t\t\t \tItemsCount INT(10) NOT NULL,\n\t\t\t\t KEY `rulename` (`rulename`),\n\t\t\t\t KEY `enabled` (`enabled`),\n\t\t\t\t KEY `ItemsCount` (`ItemsCount`)\n\t\t\t\t) ENGINE=MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('webfilters_updates', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `webfilters_updates` (\n\t\t\t\t tablename VARCHAR(128) NOT NULL PRIMARY KEY,\n\t\t\t\t \tzDate timestamp NOT NULL,\n\t\t\t\t \tupdated smallint(1) NOT NULL,\n\t\t\t\t KEY `zDate` (`zDate`),\n\t\t\t\t KEY `updated` (`updated`)\n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('webfilters_rewriteitems', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `webfilters_rewriteitems` (\n\t\t\t\t `ID` INT( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t\t ruleid INT(2) NOT NULL,\n\t\t\t\t \tfrompattern VARCHAR(128) NOT NULL,\n\t\t\t\t \ttopattern VARCHAR(128) NOT NULL,\n\t\t\t\t \tenabled smallint(1) NOT NULL DEFAULT 1,\n\t\t\t\t KEY `ruleid` (`ruleid`),\n\t\t\t\t KEY `frompattern` (`frompattern`),\n\t\t\t\t KEY `enabled` (`enabled`)\n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('webstats_backup', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `webstats_backup` (\n\t\t\t\t `tablename` VARCHAR( 90 ) NOT NULL PRIMARY KEY,\n\t\t\t\t `filepath` VARCHAR(255) NOT NULL,\n\t\t\t\t \t `filesize` INT UNSIGNED NOT NULL,\n\t\t\t\t\t KEY `filesize` (`filesize`)\n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('webfilter_assoc_groups', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `webfilter_assoc_groups` (\n\t\t\t\t `ID` INT( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t\t webfilter_id INT(2) NOT NULL,\n\t\t\t\t \tgroup_id INT(2) NOT NULL,\n\t\t\t\t \tzMD5 VARCHAR(90) NOT NULL,\n\t\t\t\t KEY `webfilter_id` (`webfilter_id`),\n\t\t\t\t KEY `group_id` (`group_id`),\n\t\t\t\t UNIQUE KEY `zMD5` (`zMD5`)\n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } $sql = "CREATE TABLE IF NOT EXISTS `webfilter_assoc_quota_groups` (\n\t\t\t\t `ID` INT( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t\t webfilter_id INT(2) NOT NULL,\n\t\t\t\t \tgroup_id INT(2) NOT NULL,\n\t\t\t\t \tzMD5 VARCHAR(90) NOT NULL,\n\t\t\t\t KEY `webfilter_id` (`webfilter_id`),\n\t\t\t\t KEY `group_id` (`group_id`),\n\t\t\t\t UNIQUE KEY `zMD5` (`zMD5`)\n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->FIELD_EXISTS("webfilter_assoc_groups", "zMD5")) { $this->QUERY_SQL("ALTER TABLE `webfilter_assoc_groups` ADD `zMD5` VARCHAR( 90 ) NOT NULL ,ADD UNIQUE KEY `zMD5` (`zMD5`)"); } if (!$this->TABLE_EXISTS('instant_updates', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `instant_updates` (\n\t\t\t\t `ID` BIGINT UNSIGNED PRIMARY KEY ,\n\t\t\t\t `zDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n\t\t\t\t \tCountItems INT UNSIGNED NOT NULL,\n\t\t\t\t \tDbCount INT UNSIGNED NOT NULL,\n\t\t\t\t KEY `zDate` (`zDate`),\n\t\t\t\t \tKEY `CountItems` (`CountItems`),\n\t\t\t\t \tKEY `DbCount` (`DbCount`)\n\t\t\t\t) ENGINE=MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('uris_malwares', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `uris_malwares` (\n\t\t\t\t `uri` VARCHAR( 255 ) NOT NULL PRIMARY KEY \n\t\t\t\t ) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('UserAgents', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `UserAgents` (\n\t\t\t\t `pattern` VARCHAR( 255 ) NOT NULL PRIMARY KEY \n\t\t\t\t ) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('uris_phishing', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `uris_phishing` (\n\t\t\t\t `uri` VARCHAR( 255 ) NOT NULL PRIMARY KEY \n\t\t\t\t ) "; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('tables_day', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `tables_day` (\n\t\t\t `tablename` varchar(90) NOT NULL,\n\t\t\t `zDate` date NOT NULL,\n\t\t\t `size` bigint(255) NOT NULL,\n\t\t\t `size_cached` bigint(255) NOT NULL,\n\t\t\t `totalsize` bigint(255) NOT NULL,\n\t\t\t `requests` bigint(255) NOT NULL,\n\t\t\t `cache_perfs` int(2) NOT NULL,\n\t\t\t `cached` smallint(1) NOT NULL DEFAULT '0',\n\t\t\t `YouTubeHits` INT UNSIGNED NOT NULL,\n\t\t\t `MembersCount` INT UNSIGNED NOT NULL,\n\t\t\t `Hour` smallint(1) NOT NULL,\n\t\t\t `members` smallint(1) NOT NULL DEFAULT '0',\n\t\t\t `month_members` smallint(1) NOT NULL DEFAULT '0',\n\t\t\t `month_flow` smallint(1) NOT NULL DEFAULT '0',\n\t\t\t `blocks` smallint(1) NOT NULL,\n\t\t\t `totalBlocked` bigint(255) NOT NULL,\n\t\t\t `weekdone` smallint(1) NOT NULL DEFAULT '0',\n\t\t\t `weekbdone` smallint(1) NOT NULL DEFAULT '0',\n\t\t\t `monthdone` smallint(1) NOT NULL DEFAULT '0',\n\t\t\t `yeardone` smallint(1) NOT NULL DEFAULT '0',\n\t\t\t `year1` smallint(1) NOT NULL DEFAULT '0',\n\t\t\t `month_query` smallint(1) NOT NULL DEFAULT '0',\n\t\t\t `not_categorized` INT(50) NOT NULL DEFAULT '0',\n\t\t\t `visited_day` smallint(1) NOT NULL DEFAULT '0',\n\t\t\t `memberscentral` smallint(1) NOT NULL DEFAULT '0',\n\t\t\t `compressed` smallint(1) NOT NULL DEFAULT '0',\n\t\t\t `backuped` smallint(1) NOT NULL DEFAULT '0',\n\t\t\t `youtube_dayz` smallint(1) NOT NULL DEFAULT '0',\n\t\t\t `youtube_week` smallint(1) NOT NULL DEFAULT '0',\n\t\t\t `members_uid` smallint(1) NOT NULL DEFAULT '0',\n\t\t\t `websites_uid` smallint(1) NOT NULL DEFAULT '0',\n\t\t\t `blocked_uid` smallint(1) NOT NULL DEFAULT '0',\n\t\t\t `youtube_uid` smallint(1) NOT NULL DEFAULT '0',\n\t\t\t `members_mac` smallint(1) NOT NULL DEFAULT '0',\n\t\t\t `members_macip` smallint(1) NOT NULL DEFAULT '0',\n\t\t\t `familysites` smallint(1) NOT NULL DEFAULT '0',\n\t\t\t `usersday` smallint(1) NOT NULL DEFAULT '0',\n\t\t\t `WeekDay` SMALLINT( 2 ) NOT NULL ,\n\t\t\t `WeekNum` SMALLINT( 2 ) NOT NULL, \n\t\t\t `SearchWordWeek` INT(50) NOT NULL,\n\t\t\t `SearchWordTEMP` INT(50) NOT NULL,\n\t\t\t `wwwvisited` smallint(1) NOT NULL DEFAULT '0',\n\t\t\t PRIMARY KEY (`tablename`),\n\t\t\t KEY `zDate` (`zDate`,`size`,`size_cached`,`cache_perfs`),\n\t\t\t KEY `Hour` (`Hour`),\n\t\t\t KEY `totalsize` (`totalsize`),\n\t\t\t KEY `requests` (`requests`),\n\t\t\t KEY `members` (`members`),\n\t\t\t KEY `memberscentral` (`memberscentral`),\n\t\t\t KEY `youtube_dayz` (`youtube_dayz`),\n\t\t\t KEY `youtube_week` (`youtube_week`),\n\t\t\t KEY `month_members` (`month_members`),\n\t\t\t KEY `month_flow` (`month_flow`),\n\t\t\t KEY `blocks` (`blocks`),\n\t\t\t KEY `totalBlocked` (`totalBlocked`),\n\t\t\t KEY `weekdone` (`weekdone`),\n\t\t\t KEY `weekbdone` (`weekbdone`),\n\t\t\t KEY `monthdone` (`monthdone`),\n\t\t\t KEY `yeardone` (`yeardone`),\n\t\t\t KEY `not_categorized` (`not_categorized`),\n\t\t\t KEY `YouTubeHits` (`YouTubeHits`),\n\t\t\t KEY `MembersCount` (`MembersCount`),\n\t\t\t KEY `month_query` (`month_query`),\n\t\t\t KEY `compressed` (`compressed`),\n\t\t\t KEY `WeekDay` (`WeekDay`),\n\t\t\t KEY `WeekNum` (`WeekNum`),\n\t\t\t KEY `SearchWordWeek` (`SearchWordWeek`),\n\t\t\t KEY `members_uid` (`members_uid`),\n\t\t\t KEY `websites_uid` (`websites_uid`),\n\t\t\t KEY `blocked_uid` (`blocked_uid`),\n\t\t\t KEY `members_mac` (`members_mac`),\n\t\t\t KEY `members_macip` (`members_macip`),\n\t\t\t KEY `usersday` (`usersday`),\n\t\t\t KEY `visited_day` (`visited_day`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->FIELD_EXISTS("tables_day", "blocks")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `blocks` INT( 1 ) NOT NULL ,ADD INDEX ( `blocks` )"); } if (!$this->FIELD_EXISTS("tables_day", "totalBlocked")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `totalBlocked` BIGINT UNSIGNED ,ADD INDEX ( `totalBlocked` )"); } if (!$this->FIELD_EXISTS("tables_day", "weekdone")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `weekdone` TINYINT( 1 ) NOT NULL DEFAULT '0',ADD INDEX ( `weekdone` )"); } if (!$this->FIELD_EXISTS("tables_day", "weekbdone")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `weekbdone` TINYINT( 1 ) NOT NULL DEFAULT '0',ADD INDEX ( `weekbdone` )"); } if (!$this->FIELD_EXISTS("tables_day", "month_query")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `month_query` TINYINT( 1 ) NOT NULL DEFAULT '0',ADD INDEX ( `month_query` ) "); } if (!$this->FIELD_EXISTS("tables_day", "not_categorized")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `not_categorized` INT( 50 ) NOT NULL DEFAULT '0',ADD INDEX ( `not_categorized` ) "); } if (!$this->FIELD_EXISTS("tables_day", "visited_day")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `visited_day` TINYINT( 1 ) NOT NULL DEFAULT '0',ADD INDEX ( `visited_day` )"); } if (!$this->FIELD_EXISTS("tables_day", "memberscentral")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `memberscentral` TINYINT( 1 ) NOT NULL DEFAULT '0',ADD INDEX ( `memberscentral` )"); } if (!$this->FIELD_EXISTS("tables_day", "backuped")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `backuped` TINYINT( 1 ) NOT NULL DEFAULT '0',ADD INDEX ( `backuped` )"); } if (!$this->FIELD_EXISTS("tables_day", "month_flow")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `month_flow` TINYINT( 1 ) NOT NULL DEFAULT '0',ADD INDEX ( `month_flow` )"); } if (!$this->FIELD_EXISTS("tables_day", "compressed")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `compressed` SMALLINT( 1 ) NOT NULL DEFAULT '0', ADD INDEX ( `compressed` )"); } if (!$this->FIELD_EXISTS("tables_day", "YouTubeHits")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `YouTubeHits` INT UNSIGNED DEFAULT '0', ADD INDEX ( `YouTubeHits` )"); } if (!$this->FIELD_EXISTS("tables_day", "MembersCount")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `MembersCount` INT UNSIGNED DEFAULT '0', ADD INDEX ( `MembersCount` )"); } if (!$this->FIELD_EXISTS("tables_day", "youtube_dayz")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `youtube_dayz` TINYINT( 1 ) NOT NULL DEFAULT '0', ADD INDEX ( `youtube_dayz` )"); } if (!$this->FIELD_EXISTS("tables_day", "youtube_week")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `youtube_week` TINYINT( 1 ) NOT NULL DEFAULT '0', ADD INDEX ( `youtube_week` )"); } if (!$this->FIELD_EXISTS("tables_day", "wwwvisited")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `wwwvisited` TINYINT( 1 ) NOT NULL DEFAULT '0', ADD INDEX ( `wwwvisited` )"); } if (!$this->FIELD_EXISTS("tables_day", "members_uid")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `members_uid` TINYINT( 1 ) NOT NULL DEFAULT '0', ADD INDEX ( `members_uid` )"); } if (!$this->FIELD_EXISTS("tables_day", "WeekDay")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `WeekDay` SMALLINT( 2 ) NOT NULL ,ADD `WeekNum` SMALLINT( 2 ) NOT NULL ,ADD INDEX ( `WeekDay` , `WeekNum` )"); } if (!$this->FIELD_EXISTS("tables_day", "SearchWordWeek")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `SearchWordWeek` INT(50) NOT NULL ,ADD INDEX ( `SearchWordWeek` )"); } if (!$this->FIELD_EXISTS("tables_day", "SearchWordTEMP")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `SearchWordTEMP` INT(50) NOT NULL ,ADD INDEX ( `SearchWordTEMP` )"); } if (!$this->FIELD_EXISTS("tables_day", "websites_uid")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `websites_uid` TINYINT( 1 ) NOT NULL DEFAULT '0', ADD INDEX ( `websites_uid` )"); } if (!$this->FIELD_EXISTS("tables_day", "members_mac")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `members_mac` TINYINT( 1 ) NOT NULL DEFAULT '0', ADD INDEX ( `members_mac` )"); } if (!$this->FIELD_EXISTS("tables_day", "members_macip")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `members_macip` TINYINT( 1 ) NOT NULL DEFAULT '0', ADD INDEX ( `members_macip` )"); } if (!$this->FIELD_EXISTS("tables_day", "blocked_uid")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `blocked_uid` TINYINT( 1 ) NOT NULL DEFAULT '0', ADD INDEX ( `blocked_uid` )"); } if (!$this->FIELD_EXISTS("tables_day", "youtube_uid")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `youtube_uid` TINYINT( 1 ) NOT NULL DEFAULT '0', ADD INDEX ( `youtube_uid` )"); } if (!$this->FIELD_EXISTS("tables_day", "familysites")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `familysites` TINYINT( 1 ) NOT NULL DEFAULT '0', ADD INDEX ( `familysites` )"); } if (!$this->FIELD_EXISTS("tables_day", "cached")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `cached` TINYINT( 1 ) NOT NULL DEFAULT '0', ADD INDEX ( `cached` )"); } if (!$this->FIELD_EXISTS("tables_day", "monthdone")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `monthdone` TINYINT( 1 ) NOT NULL DEFAULT '0', ADD INDEX ( `monthdone` )"); } if (!$this->FIELD_EXISTS("tables_day", "yeardone")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `yeardone` TINYINT( 1 ) NOT NULL DEFAULT '0', ADD INDEX ( `yeardone` )"); } if (!$this->FIELD_EXISTS("tables_day", "year1")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `year1` TINYINT( 1 ) NOT NULL DEFAULT '0', ADD INDEX ( `year1` )"); } if (!$this->FIELD_EXISTS("tables_day", "familyday")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `familyday` TINYINT( 1 ) NOT NULL DEFAULT '0', ADD INDEX ( `familyday` )"); } if (!$this->FIELD_EXISTS("tables_day", "usersday")) { $this->QUERY_SQL("ALTER TABLE `tables_day` ADD `usersday` TINYINT( 1 ) NOT NULL DEFAULT '0', ADD INDEX ( `usersday` )"); } if ($this->FIELD_TYPE("tables_day", "totalBlocked", $this->database) == "bigint(100)") { $this->QUERY_SQL('ALTER TABLE `tables_day` CHANGE `size` `size` BIGINT( 255 ) NOT NULL'); $this->QUERY_SQL('ALTER TABLE `tables_day` CHANGE `totalBlocked` `totalBlocked` BIGINT( 255 ) NOT NULL'); $this->QUERY_SQL('ALTER TABLE `tables_day` CHANGE `requests` `requests` BIGINT( 255 ) NOT NULL'); $this->QUERY_SQL('ALTER TABLE `tables_day` CHANGE `totalsize` `totalsize` BIGINT( 255 ) NOT NULL'); $this->QUERY_SQL('ALTER TABLE `tables_day` CHANGE `size_cached` `size_cached` BIGINT( 255 ) NOT NULL'); } $sql = "CREATE TABLE IF NOT EXISTS `squidtpls` (\n\t\t\t `zmd5` CHAR(32) NOT NULL,\n\t\t\t `template_name` varchar(128) NOT NULL,\n\t\t\t `template_body` LONGTEXT NOT NULL,\n\t\t\t `template_header` LONGTEXT NOT NULL,\n\t\t\t `template_title` varchar(255) NOT NULL,\n\t\t\t `template_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n\t\t\t `template_link` smallint(1) NOT NULL,\n\t\t\t `template_uri` varchar(255) NOT NULL,\n\t\t\t `lang` varchar(5) NOT NULL,\n\t\t\t PRIMARY KEY (`zmd5`),\n\t\t\t KEY `template_name` (`template_name`,`lang`),\n\t\t\t KEY `template_title` (`template_title`),\n\t\t\t KEY `template_time` (`template_time`),\n\t\t\t KEY `template_link` (`template_link`),\n\t\t\t FULLTEXT KEY `template_body` (`template_body`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `members_uid` (\n\t\t\t `zmd5` CHAR(32) NOT NULL,\n\t\t\t `uid` varchar(128) NOT NULL,\n\t\t\t `zDate` date NOT NULL,\n\t\t\t `size` BIGINT UNSIGNED NOT NULL,\n\t\t\t `hits` BIGINT UNSIGNED NOT NULL,\n\t\t\t PRIMARY KEY (`zmd5`),\n\t\t\t KEY `uid` (`uid`),\n\t\t\t KEY `zDate` (`zDate`),\n\t\t\t KEY `size` (`size`),\n\t\t\t KEY `hits` (`hits`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `familysites` (\n\t\t\t `zmd5` CHAR(32) NOT NULL,\n\t\t\t `familysites` varchar(255) NOT NULL,\n\t\t\t `zDate` date NOT NULL,\n\t\t\t `size` BIGINT UNSIGNED NOT NULL,\n\t\t\t `hits` BIGINT UNSIGNED NOT NULL,\n\t\t\t PRIMARY KEY (`zmd5`),\n\t\t\t KEY `familysites` (`familysites`),\n\t\t\t KEY `zDate` (`zDate`),\n\t\t\t KEY `size` (`size`),\n\t\t\t KEY `hits` (`hits`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `members_macip` (\n\t\t\t `zmd5` CHAR(32) NOT NULL,\n\t\t\t `MAC` varchar(128) NOT NULL,\n\t\t\t `ipaddr` varchar(128) NOT NULL,\n\t\t\t PRIMARY KEY (`zmd5`),\n\t\t\t KEY `MAC` (`MAC`),\n\t\t\t KEY `ipaddr` (`ipaddr`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `members_mac` (\n\t\t\t `zmd5` CHAR(32) NOT NULL,\n\t\t\t `MAC` varchar(128) NOT NULL,\n\t\t\t `zDate` date NOT NULL,\n\t\t\t `size` BIGINT UNSIGNED NOT NULL,\n\t\t\t `hits` BIGINT UNSIGNED NOT NULL,\n\t\t\t\t\n\t\t\t PRIMARY KEY (`zmd5`),\n\t\t\t KEY `MAC` (`MAC`),\n\t\t\t KEY `zDate` (`zDate`),\n\t\t\t KEY `size` (`size`),\n\t\t\t KEY `hits` (`hits`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->FIELD_EXISTS("squidtpls", "template_time")) { $sql = "ALTER TABLE `squidtpls` ADD `template_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,ADD INDEX (`template_time`)"; $this->QUERY_SQL($sql, "artica_backup"); if (!$this->ok) { writelogs("{$this->mysql_error}\n{$sql}", __CLASS__ . '/' . __FUNCTION__, __FILE__, __LINE__); } } if (!$this->FIELD_EXISTS("squidtpls", "template_header")) { $this->QUERY_SQL("ALTER TABLE `squidtpls` ADD `template_header` LONGTEXT NOT NULL"); } if (!$this->FIELD_EXISTS("squidtpls", "template_link")) { $this->QUERY_SQL("ALTER TABLE `squidtpls` ADD `template_link` smallint(1) NOT NULL,ADD INDEX (`template_link`)"); } if (!$this->FIELD_EXISTS("squidtpls", "template_uri")) { $this->QUERY_SQL("ALTER TABLE `squidtpls` ADD `template_uri` VARCHAR(255) NOT NULL"); } if (!$this->FIELD_EXISTS("squidtpls", "emptytpl")) { $this->QUERY_SQL("ALTER TABLE `squidtpls` ADD `emptytpl` smallint(1) NOT NULL"); } if (!$this->TABLE_EXISTS('tables_hours', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `tables_hours` (\n\t\t\t `tablename` varchar(90) NOT NULL,\n\t\t\t `zDate` date NOT NULL,\n\t\t\t `size` INT UNSIGNED NOT NULL,\n\t\t\t `size_cached` INT UNSIGNED NOT NULL,\n\t\t\t `totalsize` INT UNSIGNED ,\n\t\t\t `requests` INT UNSIGNED ,\n\t\t\t `cache_perfs` INT( 2 ) NOT NULL ,\n\t\t\t `members` smallint(1) NOT NULL,\n\t\t\t PRIMARY KEY (`tablename`),\n\t\t\t KEY `zDate` (`zDate`,`size`,`size_cached`,`cache_perfs`),\n\t\t\t KEY `totalsize` (`totalsize`),\n\t\t\t KEY `requests` (`requests`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->ok) { writelogs($this->mysql_error, __FUNCTION__, __FILE__, __LINE__); } } if (!$this->TABLE_EXISTS('TrackMembers', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `TrackMembers` (\n\t\t\t `ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t `report` VARCHAR(255) NOT NULL,\n\t\t\t `userfield` VARCHAR(60) NOT NULL,\n\t\t\t `duration` VARCHAR(128) NOT NULL,\n\t\t\t `userdata` VARCHAR(128) NOT NULL,\n\t\t\t `categories` TEXT NOT NULL ,\n\t\t\t `sitename` TEXT NOT NULL ,\n\t\t\t `scheduled` smallint(1) NOT NULL,\n\t\t\t `csv` smallint(1) NOT NULL,\n\t\t\t `csvContent` longblob NOT NULL,\n\t\t\t KEY `report` (`report`),\n\t\t\t KEY `scheduled` (`scheduled`),\n\t\t\t KEY `csv` (`csv`)\n\t\t\t \n\t\t\t) ENGINE=MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->ok) { writelogs($this->mysql_error, __FUNCTION__, __FILE__, __LINE__); } } if (!$this->FIELD_EXISTS("TrackMembers", "duration")) { $this->QUERY_SQL("ALTER TABLE `TrackMembers` ADD `duration` VARCHAR( 128 ) NOT NULL"); } if (!$this->FIELD_EXISTS("TrackMembers", "scheduled")) { $this->QUERY_SQL("ALTER TABLE `TrackMembers` ADD `scheduled` smallint(1) NOT NULL,ADD KEY `scheduled` (`scheduled`)"); } if (!$this->FIELD_EXISTS("TrackMembers", "csv")) { $this->QUERY_SQL("ALTER TABLE `TrackMembers` ADD `csv` smallint(1) NOT NULL,ADD KEY `csv` (`csv`)"); } if (!$this->FIELD_EXISTS("TrackMembers", "csvContent")) { $this->QUERY_SQL("ALTER TABLE `TrackMembers` ADD `csvContent` longblob NOT NULL"); } if (!$this->TABLE_EXISTS('updateblks_events', $this->database)) { $sql = "CREATE TABLE `squidlogs`.`updateblks_events` (\n\t\t\t`ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t`zDate` TIMESTAMP NOT NULL ,\n\t\t\t`PID` INT( 5 ) NOT NULL ,\n\t\t\t`function` VARCHAR( 50 ) NOT NULL ,\n\t\t\t`category` VARCHAR( 50 ) NOT NULL ,\n\t\t\t`text` TEXT NOT NULL ,\n\t\t\tINDEX ( `zDate` , `PID` , `function` ),\n\t\t\tKEY `category` (`category`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->FIELD_EXISTS("updateblks_events", "category")) { $this->QUERY_SQL("ALTER TABLE `updateblks_events` ADD `category` VARCHAR( 50 ) NOT NULL ,ADD KEY `category` (`category`)"); } $sql = "CREATE TABLE IF NOT EXISTS `visited_sites_days` (\n\t\t\t `zmd5` varchar(90) NOT NULL,\n\t\t\t `familysite` varchar(255) NOT NULL,\n\t\t\t `size` BIGINT(255) UNSIGNED NOT NULL,\n\t\t\t `hits` BIGINT(255) UNSIGNED NOT NULL,\n\t\t\t `zDate` date NOT NULL ,\t\t\t \n\t\t\t PRIMARY KEY (`zmd5`),\n\t\t\t KEY `size` (`size`),\n\t\t\t KEY `hits` (`hits`),\n\t\t\t KEY `zDate` (`zDate`),\n\t\t\t KEY `familysite` (`familysite`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `visited_sites_tot` (\n\t\t\t `familysite` varchar(255) NOT NULL,\n\t\t\t `size` BIGINT(255) UNSIGNED NOT NULL,\n\t\t\t `hits` BIGINT(255) UNSIGNED NOT NULL,\n\t\t\t KEY `size` (`size`),\n\t\t\t KEY `hits` (`hits`),\n\t\t\t PRIMARY KEY `familysite` (`familysite`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `cached_total` (\n\t\t\t\t `size` bigint(255) unsigned NOT NULL,\n\t\t\t\t `cached` smallint(1) unsigned NOT NULL,\n\t\t\t\t `zDate` date NOT NULL,\n\t\t\t\t `zmd5` varchar(40) NOT NULL,\n\t\t\t\t PRIMARY KEY (`zmd5`),\n\t\t\t\t KEY `size` (`size`),\n\t\t\t\t KEY `cached` (`cached`)\n\t\t\t\t) ENGINE=MyISAM;"; $this->QUERY_SQL($sql, $this->database); $sql = "CREATE TABLE IF NOT EXISTS `notcategorized` (\n\t\t\t\t `sitename` VARCHAR(255) NOT NULL,\n\t\t\t\t `familysite` VARCHAR(255) NOT NULL,\n\t\t\t\t `domain` VARCHAR(5) NOT NULL,\n\t\t\t\t `country` VARCHAR(60) NOT NULL,\n\t\t\t\t `hits` bigint(255) unsigned NOT NULL,\n\t\t\t\t `size` bigint(255) unsigned NOT NULL,\n\t\t\t\t `seen` TEXT,\n\t\t\t\t PRIMARY KEY (`sitename`),\n\t\t\t\t KEY `size` (`size`),\n\t\t\t\t KEY `hits` (`hits`),\n\t\t\t\t KEY `familysite` (`familysite`),\n\t\t\t\t KEY `domain` (`domain`),\n\t\t\t\t KEY `country` (`country`)\n\t\t\t\t) ENGINE=MyISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->FIELD_EXISTS("notcategorized", "seen")) { $this->QUERY_SQL("ALTER TABLE `notcategorized` ADD `seen` TEXT"); } $sql = "CREATE TABLE IF NOT EXISTS `visited_sites` (\n\t\t\t `sitename` varchar(255) NOT NULL,\n\t\t\t `Querysize` BIGINT UNSIGNED NOT NULL,\n\t\t\t `category` varchar(255) NOT NULL,\n\t\t\t `HitsNumber` INT UNSIGNED NOT NULL,\n\t\t\t `country` varchar(128) NOT NULL,\n\t\t\t `familysite` varchar(128) NOT NULL,\n\t\t\t `whois` TEXT,\n\t\t\t `probablect1` varchar(60) NOT NULL ,\n\t\t\t `probablect2` varchar(60) NOT NULL ,\n\t\t\t `probablect3` varchar(60) NOT NULL ,\n\t\t\t `NotVisitedSended` smallint(1) NOT NULL,\n\t\t\t `recatgorized` smallint(1) NOT NULL,\n\t\t\t `thumbnail` smallint(1) NOT NULL,\n\t\t\t PRIMARY KEY (`sitename`),\n\t\t\t KEY `Querysize` (`Querysize`,`HitsNumber`,`country`),\n\t\t\t KEY `familysite` (`familysite`),\n\t\t\t KEY `probablect1` (`probablect1`),\n\t\t\t KEY `probablect2` (`probablect2`),\n\t\t\t KEY `probablect3` (`probablect3`),\n\t\t\t KEY `category` (`category`),\n\t\t\t KEY `recatgorized` (`recatgorized`),\n\t\t\t KEY `thumbnail` (`thumbnail`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); if (!$this->INDEX_EXISTS("visited_sites", "category", $this->database)) { $this->QUERY_SQL("ALTER TABLE `visited_sites` ADD KEY `category` (`category`)"); } if (!$this->FIELD_EXISTS("visited_sites", "whois")) { $this->QUERY_SQL("ALTER TABLE `visited_sites` ADD `whois` TEXT"); } if (!$this->FIELD_EXISTS("visited_sites", "probablect1")) { $this->QUERY_SQL("ALTER TABLE `visited_sites` ADD `probablect1` varchar(60) NOT NULL ,ADD KEY `probablect1` (`probablect1`)"); } if (!$this->FIELD_EXISTS("visited_sites", "probablect2")) { $this->QUERY_SQL("ALTER TABLE `visited_sites` ADD `probablect2` varchar(60) NOT NULL ,ADD KEY `probablect2` (`probablect2`)"); } if (!$this->FIELD_EXISTS("visited_sites", "probablect3")) { $this->QUERY_SQL("ALTER TABLE `visited_sites` ADD `probablect3` varchar(60) NOT NULL ,ADD KEY `probablect3` (`probablect3`)"); } if (!$this->FIELD_EXISTS("visited_sites", "NotVisitedSended")) { $this->QUERY_SQL("ALTER TABLE `visited_sites` ADD `NotVisitedSended` smallint(1) NOT NULL ,ADD KEY `NotVisitedSended` (`NotVisitedSended`)"); } if (!$this->FIELD_EXISTS("visited_sites", "thumbnail")) { $this->QUERY_SQL("ALTER TABLE `visited_sites` ADD `thumbnail` smallint(1) NOT NULL ,ADD KEY `thumbnail` (`thumbnail`)"); } if (!$this->TABLE_EXISTS("visited_sites_catz", $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `visited_sites_catz` (\n\t\t\t\t `zmd5` varchar(90) NOT NULL,\n\t\t\t\t `category` varchar(60) NOT NULL,\n\t\t\t\t `familysite` varchar(128) NOT NULL,\n\t\t\t\t PRIMARY KEY (`zmd5`),\n\t\t\t\t KEY `familysite` (`familysite`),\n\t\t\t\t KEY `category` (`category`)\n\t\t\t\t ) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('stats_appliance_events', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `stats_appliance_events` (\n\t\t\t `ID` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t `hostname` varchar(60) NOT NULL,\n\t\t\t `events` varchar(255) NOT NULL,\n\t\t\t `zDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n\t\t\t PRIMARY KEY (`ID`),\n\t\t\t KEY `hostname` (`hostname`),\n\t\t\t KEY `zDate` (`zDate`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('categorize', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `categorize` (\n\t\t\t `zmd5` varchar(90) NOT NULL,\n\t\t\t `pattern` varchar(255) NOT NULL,\n\t\t\t `zDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n\t\t\t `uuid` varchar(128) NOT NULL,\n\t\t\t `category` varchar(80) NOT NULL,\n\t\t\t PRIMARY KEY (`zmd5`),\n\t\t\t KEY `zDate` (`zDate`,`category`),\n\t\t\t KEY `pattern` (`pattern`),\n\t\t\t KEY `uuid` (`uuid`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('framework_orders', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `framework_orders` (\n\t\t\t `zmd5` varchar(90) NOT NULL,\n\t\t\t `ORDER` varchar(255) NOT NULL,\n\t\t\t `zDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n\t\t\t PRIMARY KEY (`zmd5`),\n\t\t\t KEY `ORDER` (`ORDER`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('categorize_changes', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `categorize_changes` (\n\t\t\t `zmd5` varchar(90) NOT NULL,\n\t\t\t `sitename` varchar(255) NOT NULL,\n\t\t\t `category` varchar(255) NOT NULL,\n\t\t\t PRIMARY KEY (`zmd5`),\n\t\t\t KEY `sitename` (`sitename`),\n\t\t\t KEY `category` (`category`)\n\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('categorize_delete', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `categorize_delete` (\n\t\t\t\t `sitename` varchar(255) NOT NULL,\n\t\t\t\t `category` varchar(128) NOT NULL,\n\t\t\t\t `zmd5` varchar(90) NOT NULL,\n\t\t\t\t `sended` INT( 1 ) NOT NULL,\n\t\t\t\t PRIMARY KEY (`zmd5`),\n\t\t\t\t KEY `category` (`category`),\n\t\t\t\t KEY `sitename` (`sitename`),\n\t\t\t\t KEY `sended` (`sended`)\n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->FIELD_EXISTS("categorize_delete", "sended")) { $this->QUERY_SQL("ALTER TABLE `categorize_delete` ADD `sended` INT( 1 ) NOT NULL ,ADD INDEX ( `sended` )"); } if (!$this->TABLE_EXISTS('personal_categories', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`personal_categories` (\n\t\t\t\t`category` VARCHAR( 15 ) NOT NULL ,\n\t\t\t\t`category_description` VARCHAR( 255 ) NOT NULL ,\n\t\t\t\t`master_category` VARCHAR( 50 ) NOT NULL ,\n\t\t\t\t`sended` INT( 1 ) NOT NULL DEFAULT '0',\n\t\t\t\t`PublicMode` smallint( 1 ) NOT NULL DEFAULT '0',\n\t\t\t\t`Meta` smallint( 1 ) NOT NULL DEFAULT '0',\n\t\t\t\tINDEX ( `category_description` , `sended` ) ,\n\t\t\t\tKEY `master_category` (`master_category`),\n\t\t\t\tKEY `PublicMode` (`PublicMode`),\n\t\t\t\tUNIQUE (`category`)) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->FIELD_EXISTS("personal_categories", "PublicMode")) { $this->QUERY_SQL("ALTER TABLE `personal_categories` \n\t\t\t\tADD `PublicMode` smallint( 1 ) NOT NULL ,\n\t\t\t\tADD INDEX ( `PublicMode` )"); } if (!$this->FIELD_EXISTS("personal_categories", "Meta")) { $this->QUERY_SQL("ALTER TABLE `personal_categories`\n\t\t\t\tADD `Meta` smallint( 1 ) NOT NULL ,\n\t\t\t\tADD INDEX ( `Meta` )"); } if (!$this->TABLE_EXISTS('work_optimize', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`work_optimize` (\n\t\t`table_name` VARCHAR( 50 ) NOT NULL ,\n\t\t`job` TINYINT NOT NULL ,\n\t\tPRIMARY KEY ( `table_name` )) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('work_squid_repo', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`work_squid_repo` (\n\t\t`version` VARCHAR( 50 ) NOT NULL ,\n\t\t`package` longblob NOT NULL ,\n\t\tPRIMARY KEY ( `version` )\n\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->FIELD_EXISTS("personal_categories", "master_category")) { $this->QUERY_SQL("ALTER TABLE `personal_categories` ADD `master_category` VARCHAR( 50 ) NOT NULL ,ADD KEY `master_category` (`master_category`)"); } if (!$this->TABLE_EXISTS('usersisp', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`usersisp` (\n\t\t\t\t`userid` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t\t`email` VARCHAR( 128 ) NOT NULL ,\n\t\t\t\t`user_password` VARCHAR( 90 ) NOT NULL ,\n\t\t\t\t`createdon` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,\n\t\t\t\t`enabled` SMALLINT( 1 ) NOT NULL ,\n\t\t\t\t`publicip` VARCHAR( 60 ) NOT NULL ,\n\t\t\t\t`macaddr` VARCHAR( 60 ) NOT NULL ,\n\t\t\t\t`language` VARCHAR( 5 ) NOT NULL ,\n\t\t\t\t`updatedon` TIMESTAMP NOT NULL ,\n\t\t\t\t`zmd5` VARCHAR( 90 ) NOT NULL ,\n\t\t\t\t`ProxyPacDatas` TEXT NOT NULL,\n\t\t\t\t`ProxyPacCompiled` TEXT NOT NULL,\n\t\t\t\t`wwwname` VARCHAR( 255 ) NOT NULL ,\n\t\t\t\t`ProxyPacRemoveProxyListAtTheEnd` SMALLINT( 1 ) NOT NULL ,\n\t\t\t\tINDEX ( `createdon` , `enabled` , `updatedon` ) ,\n\t\t\t\tKEY `wwwname` (`wwwname`),\n\t\t\t\tUNIQUE KEY (`email`),\n\t\t\t\tUNIQUE KEY (`publicip`),\n\t\t\t\tUNIQUE KEY (`macaddr`),\n\t\t\t\tUNIQUE KEY (`zmd5`)\n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->FIELD_EXISTS("usersisp", "wwwname")) { $this->QUERY_SQL("ALTER TABLE `usersisp` ADD `wwwname` VARCHAR( 255 ) NOT NULL ,ADD KEY `wwwname` (`wwwname`)"); } if (!$this->TABLE_EXISTS('usersisp_blkcatz', $this->database)) { $sql = "CREATE TABLE `squidlogs`.`usersisp_blkcatz` (`category` VARCHAR( 255 ) NOT NULL PRIMARY KEY) "; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('usersisp_blkwcatz', $this->database)) { $sql = "CREATE TABLE `squidlogs`.`usersisp_blkwcatz` (\n\t\t\t\t`category` VARCHAR( 255 ) NOT NULL PRIMARY KEY\n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('usersisp_catztables', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`usersisp_catztables` (\n\t\t\t\t`ID` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t\t`zmd5` VARCHAR( 90 ) NOT NULL,\n\t\t\t\t`category` VARCHAR( 255 ) NOT NULL,\n\t\t\t\t`userid` BIGINT UNSIGNED,\n\t\t\t\t`blck` smallint(1) NOT NULL,\n\t\t\t\tKEY `category` (`category`),\n\t\t\t\tUNIQUE (`zmd5`),\n\t\t\t\tINDEX ( `userid` , `blck`) \n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->TABLE_EXISTS('webfilters_thumbnails', $this->database)) { $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`webfilters_thumbnails` (\n\t\t\t\t`zmd5` VARCHAR( 90 ) NOT NULL ,\n\t\t\t\t`withid` SMALLINT( 1 ) NOT NULL ,\n\t\t\t\t`sended` SMALLINT( 1 ) NOT NULL ,\n\t\t\t\t`picture` BLOB NOT NULL ,\n\t\t\t\t`savedate` TIMESTAMP NOT NULL ,\n\t\t\t\t`filemd5` VARCHAR( 90 ) NOT NULL ,\n\t\t\t\t`LinkTo` VARCHAR( 90 ) NOT NULL ,\n\t\t\t\tPRIMARY KEY ( `zmd5` ) ,\n\t\t\t\tUNIQUE KEY `filemd5` (`filemd5`),\n\t\t\t\tKEY `LinkTo` (`LinkTo`),\n\t\t\t\tINDEX ( `withid` , `sended` , `savedate` )\n\t\t\t\t) ENGINE = MYISAM;"; $this->QUERY_SQL($sql, $this->database); } if (!$this->FIELD_EXISTS("webfilters_thumbnails", "filemd5")) { $this->QUERY_SQL("ALTER TABLE `webfilters_thumbnails` ADD `filemd5` VARCHAR( 90 ) NOT NULL ,ADD UNIQUE (`filemd5`)"); } if (!$this->FIELD_EXISTS("webfilters_thumbnails", "LinkTo")) { $this->QUERY_SQL("ALTER TABLE `webfilters_thumbnails` ADD `LinkTo` VARCHAR( 90 ) NOT NULL ,ADD KEY `LinkTo` (`LinkTo`)"); } if (!$this->FIELD_EXISTS("usersisp", "ProxyPacDatas")) { $this->QUERY_SQL("ALTER TABLE `usersisp` ADD `ProxyPacDatas` TEXT"); } if (!$this->FIELD_EXISTS("usersisp", "ProxyPacRemoveProxyListAtTheEnd")) { $this->QUERY_SQL("ALTER TABLE `usersisp` ADD `ProxyPacRemoveProxyListAtTheEnd` SMALLINT( 1 ) NOT NULL"); } if (!$this->FIELD_EXISTS("usersisp", "ProxyPacCompiled")) { $this->QUERY_SQL("ALTER TABLE `usersisp` ADD `ProxyPacCompiled` TEXT NOT NULL"); } $this->CreateCategoryWeightedTable(); }
function items_js() { $page = CurrentPageName(); $tpl = new templates(); $q = new mysql_squid_builder(); $URL = $tpl->_ENGINE_parse_body("{url}"); $pattern = $tpl->_ENGINE_parse_body("{pattern}"); $new_item = $tpl->_ENGINE_parse_body("{new_rule}"); $new_group = $tpl->_ENGINE_parse_body("{new_proxy_object}"); $apply = $tpl->_ENGINE_parse_body("{apply}"); $t = time(); $MyTime = time(); $title = $tpl->javascript_parse_text("{rules}"); $q = new mysql_squid_builder(); if (!$q->TABLE_EXISTS("StoreID")) { $q->CheckTables(); } include_once dirname(__FILE__) . "/ressources/class.storeid.defaults.inc"; $q->QUERY_SQL(FillStoreIDDefaults()); if (!$q->ok) { echo $q->mysql_error_html(); die; } $html = "\n\t<table class='STOREID_RULES_TABLE' style='display: none' id='STOREID_RULES_TABLE' style='width:99%'></table>\n<script>\nvar DeleteAclKey=0;\nfunction LoadTable{$t}(){\n\$('#STOREID_RULES_TABLE').flexigrid({\n\turl: '{$page}?items-list=yes&ID={$ID}&t={$t}&aclid={$_GET["aclid"]}',\n\tdataType: 'json',\n\tcolModel : [\n\t\t{display: '<span style=font-size:18px> </span>', name : 'zOrder', width :50, sortable : true, align: 'center'},\t\n\t\t{display: '<span style=font-size:18px>{$pattern}</span>', name : 'pattern', width : 585, sortable : true, align: 'left'},\n\t\t{display: '<span style=font-size:18px>{$URL}</span>', name : 'dedup', width : 585, sortable : false, align: 'left'},\n\t\t{display: ' ', name : 'up', width :43, sortable : false, align: 'center'},\n\t\t{display: ' ', name : 'down', width :43, sortable : false, align: 'center'},\t\t\n\t\t{display: ' ', name : 'del', width : 43, sortable : false, align: 'center'},\n\t\t\n\t],\nbuttons : [\n\t{name: '<strong style=font-size:18px>{$new_item}</strong>', bclass: 'add', onpress : LinkAclItem{$t}},\n\t{name: '<strong style=font-size:18px>{$apply}</strong>', bclass: 'apply', onpress : Apply{$t}},\n\n\t\t],\t\n\tsearchitems : [\n\t\t{display: '{$pattern}', name : 'pattern'},\n\t\t{display: '{$URL}', name : 'dedup'},\n\t\t{display: 'ID', name : 'ID'},\n\t\t],\n\tsortname: 'zOrder',\n\tsortorder: 'asc',\n\tusepager: true,\n\ttitle: '<span style=font-size:30px>{$title}</span>',\n\tuseRp: true,\n\trp: 50,\n\tshowTableToggleBtn: false,\n\twidth: '99%',\n\theight: 550,\n\tsingleSelect: true\n\t\n\t}); \n}\nfunction LinkAclItem{$t}() {\n\tLoadjs('{$page}?ruleid-js=0');\n\t\n}\t\nvar xHyperCacheRuleGroupUpDown{$t}= function (obj) {\n\tvar res=obj.responseText;\n\tif(res.length>3){alert(res);return;}\n\t\$('#STOREID_RULES_TABLE').flexReload();\n}\t\n\t\nfunction HyperCacheRuleGroupUpDown(mkey,direction){\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('acl-rule-link-order', mkey);\n\tXHR.appendData('direction', direction);\n\tXHR.sendAndLoad('{$page}', 'POST',xHyperCacheRuleGroupUpDown{$t});\n\n}\n\nfunction Apply{$t}(){\n\tLoadjs('squid.hypercache.rules.progress.php');\n}\n\nLoadTable{$t}();\n</script>\n\t\n\t"; echo $html; }