コード例 #1
0
function MysqlCheck()
{
    $db_file = "/usr/share/ocsinventory-reports/ocsreports/files/ocsbase.sql";
    if (!is_file($db_file)) {
        die;
    }
    if (CheckTables()) {
        die;
    }
    if ($dbf_handle = @fopen($db_file, "r")) {
        $sql_query = fread($dbf_handle, filesize($db_file));
        fclose($dbf_handle);
    }
    $q = new mysql();
    if (!$q->DATABASE_EXISTS("ocsweb")) {
        $q->CREATE_DATABASE("ocsweb");
    }
    $array_commands = explode(";", "{$sql_query}");
    while (list($num, $sql) = each($array_commands)) {
        if (trim($sql) == null) {
            continue;
        }
        $q->QUERY_SQL($sql, "ocsweb");
    }
}
コード例 #2
0
ファイル: exec.ocsweb.php プロジェクト: rsd/artica-1.5
function MysqlCheck(){
$db_file = "/usr/share/ocsinventory-reports/ocsreports/files/ocsbase.sql";
if(!is_file($db_file)){
	echo "Starting......: OCS web Engine unable to stat $db_file\n";
	return;
}

$q=new mysql();
if(!$q->DATABASE_EXISTS("ocsweb")){
	echo "Starting......: OCS web Engine creating ocsweb\n";
	$q->CREATE_DATABASE("ocsweb");
	if(!$q->DATABASE_EXISTS("ocsweb")){
		echo "Starting......: OCS web Engine unable to create ocsweb mysql database\n";
		return;
	}
}



if(CheckTables()){
	$sock=new sockets();
	$users=new usersMenus();
	$q=new mysql();
	$ocswebservername=$sock->GET_INFO("ocswebservername");
	$OCSWebPort=$sock->GET_INFO("OCSWebPort");	
	if($OCSWebPort==null){$OCSWebPort=9080;}
	if($OCSWebPortSSL==null){$OCSWebPortSSL=$OCSWebPort+50;}	
	if($ocswebservername==null){$ocswebservername=$users->hostname;}
	$sql="UPDATE config SET IVALUE=1 WHERE NAME='DOWNLOAD'";
	$q->QUERY_SQL($sql,"ocsweb");
	$sql="UPDATE config SET IVALUE=1 WHERE NAME='REGISTRY'";
	$q->QUERY_SQL($sql,"ocsweb");
	$sql="UPDATE config SET IVALUE='http://$ocswebservername:$OCSWebPort' WHERE NAME='LOCAL_SERVER'";
	$q->QUERY_SQL($sql,"ocsweb");	
	return;
}




if($dbf_handle = @fopen($db_file, "r")) {
	$sql_query = fread($dbf_handle, filesize($db_file));
	fclose($dbf_handle);
	
}



$array_commands=explode(";", "$sql_query");
while (list ($num, $sql) = each ($array_commands) ){
	if(trim($sql)==null){continue;}
	
	$q->QUERY_SQL($sql,"ocsweb");
	if(!$q->ok){
	echo "Starting......: OCS web Engine $q->mysql_error $sql\n";	
	}
}

}
コード例 #3
0
ファイル: exec.drupal.php プロジェクト: BillTheBest/1.6.x
function initialize()
{
    $q = new mysql();
    if (!$q->DATABASE_EXISTS("drupal")) {
        $q->CREATE_DATABASE("drupal");
        if (!$q->DATABASE_EXISTS("drupal")) {
            echo "Failed to create \"drupal\" database with error {$q->mysql_error}\n";
        }
    }
}
コード例 #4
0
ファイル: exec.greensql.php プロジェクト: BillTheBest/1.6.x
function build()
{
    echo "Starting......: " . date("H:i:s") . " GreenSQL checking Database....\n";
    $q = new mysql();
    if (!$q->DATABASE_EXISTS("greensql")) {
        echo "Starting......: " . date("H:i:s") . " GreenSQL creating database greensql\n";
        $q->CREATE_DATABASE("greensql");
    }
    checkGreenTables();
    buildconfig();
}
コード例 #5
0
ファイル: exec.zabbix.php プロジェクト: brucewu16899/artica
function TestDatabase()
{
    $sql = new mysql();
    if (!$sql->DATABASE_EXISTS("zabbix")) {
        echo "Starting......: Zabbix server daemon creating database\n";
        $sql->CREATE_DATABASE("zabbix");
        CreateTables();
    }
    if (!$sql->DATABASE_EXISTS("zabbix")) {
        echo "Starting......: Zabbix server daemon creating database FAILED\n";
        die;
    }
    if (TablesCount() < 73) {
        CreateTables();
    }
    echo "Starting......: Zabbix server daemon database success\n";
    UpdateAdmin();
}
コード例 #6
0
ファイル: exec.zabbix.php プロジェクト: BillTheBest/1.6.x
function TestDatabase()
{
    $sql = new mysql();
    if (!$sql->DATABASE_EXISTS("zabbix")) {
        echo "Starting......: " . date("H:i:s") . " Zabbix server daemon creating database\n";
        $sql->CREATE_DATABASE("zabbix");
        CreateTables();
    }
    if (!$sql->DATABASE_EXISTS("zabbix")) {
        echo "Starting......: " . date("H:i:s") . " Zabbix server daemon creating database FAILED\n";
        die;
    }
    $TablesCount = TablesCount();
    echo "Starting......: " . date("H:i:s") . " Zabbix server {$TablesCount} tables\n";
    if ($TablesCount < 66) {
        CreateTables();
    }
    echo "Starting......: " . date("H:i:s") . " Zabbix server daemon database success\n";
    UpdateAdmin();
}
コード例 #7
0
ファイル: exec.pommo.php プロジェクト: brucewu16899/artica
function buildMysql()
{
    $q = new mysql();
    if (!$q->DATABASE_EXISTS("pommo")) {
        $q->CREATE_DATABASE("pommo");
    }
    $sql = "CREATE TABLE IF NOT EXISTS `pommo_config` (\n  `config_name` varchar(64) NOT NULL default '',\n  `config_value` text NOT NULL,\n  `config_description` tinytext NOT NULL,\n  `autoload` enum('on','off') NOT NULL default 'on',\n  `user_change` enum('on','off') NOT NULL default 'on',\n  PRIMARY KEY  (`config_name`)\n) ENGINE=MyISAM;\n";
    $q->QUERY_SQL($sql, "pommo");
    $sql = "INSERT INTO `pommo_config` (`config_name`, `config_value`, `config_description`, `autoload`, `user_change`) VALUES\n('admin_username', 'admin', 'Username', 'off', 'on'),\n('admin_password', '9dd3ba637ec2fcaf383415617d39e002', 'Password', 'off', 'on'),\n('admin_email', '*****@*****.**', 'Administrator Email', 'on', 'on'),\n('site_name', 'Artica For poMMo', 'Website Name', 'on', 'on'),\n('site_url', 'http://www.pommo-rocks.com', 'Website URL', 'on', 'on'),\n('site_success', '', 'Signup Success URL', 'off', 'on'),\n('site_confirm', '', '', 'off', 'on'),\n('list_name', 'Artica Mailing List', 'List Name', 'on', 'on'),\n('list_fromname', 'poMMo Administrative Team', 'From Name', 'off', 'on'),\n('list_fromemail', '*****@*****.**', 'From Email', 'off', 'on'),\n('list_frombounce', '*****@*****.**', 'Bounces', 'off', 'on'),\n('list_exchanger', 'sendmail', 'List Exchanger', 'off', 'on'),\n('list_confirm', 'on', 'Confirmation Messages', 'off', 'on'),\n('list_charset', 'ISO-8859-1', '', 'off', 'on'),\n('list_wysiwyg', 'on', '', 'off', 'off'),\n('maxRuntime', '80', '', 'off', 'on'),\n('messages', 'a:6:{s:9:\"subscribe\";a:4:{s:3:\"msg\";s:152:\"Welcome to our mailing list. You can always login to update your records or unsubscribe by visiting: \n  https://192.168.1.12:9000/mailing/user/login.php\";s:3:\"sub\";s:30:\"Welcome to Artica Mailing List\";s:3:\"web\";s:45:\"Welcome to our mailing list. Enjoy your stay.\";s:5:\"email\";b:0;}s:11:\"unsubscribe\";a:4:{s:3:\"sub\";s:33:\"Farewell from Artica Mailing List\";s:3:\"msg\";s:106:\"You have been unsubscribed and will not receive any more mailings from us. Feel free to come back anytime!\";s:3:\"web\";s:55:\"You have successfully unsubscribed. Enjoy your travels.\";s:5:\"email\";b:0;}s:7:\"confirm\";a:2:{s:3:\"msg\";s:253:\"You have requested to subscribe to Artica Mailing List. We would like to validate your email address before adding you as a subscriber. Please click the link below to be added ->\r\n\t[[url]]\r\n\r\nIf you have received this message in error, please ignore it.\";s:3:\"sub\";s:20:\"Subscription request\";}s:8:\"activate\";a:2:{s:3:\"msg\";s:222:\"Someone has requested to access to your records for Artica Mailing List. You may edit your information or unsubscribe by visiting the link below ->\r\n\t[[url]]\r\n\r\nIf you have received this message in error, please ignore it.\";s:3:\"sub\";s:36:\"Artica Mailing List: Account Access.\";}s:8:\"password\";a:2:{s:3:\"msg\";s:201:\"You have requested to change your password for Artica Mailing List. Please validate this request by clicking the link below ->\r\n\t[[url]]\r\n\r\nIf you have received this message in error, please ignore it.\";s:3:\"sub\";s:23:\"Change Password request\";}s:6:\"update\";a:2:{s:3:\"msg\";s:198:\"You have requested to update your records for Artica Mailing List. Please validate this request by clicking the link below ->\n\n\t[[url]]\n\nIf you have received this message in error, please ignore it.\";s:3:\"sub\";s:22:\"Update Records request\";}}', '', 'off', 'off'),\n('notices', '', '', 'off', 'off'),\n('demo_mode', 'off', 'Demonstration Mode', 'on', 'on'),\n('smtp_1', 'a:5:{s:4:\"host\";s:9:\"127.0.0.1\";s:4:\"port\";s:4:\"2525\";s:4:\"auth\";s:3:\"off\";s:4:\"user\";s:0:\"\";s:4:\"pass\";s:0:\"\";}', '', 'off', 'off'),\n('smtp_2', '', '', 'off', 'off'),\n('smtp_3', '', '', 'off', 'off'),\n('smtp_4', '', '', 'off', 'off'),\n('throttle_DBPP', '0', '', 'off', 'on'),\n('throttle_DP', '10', '', 'off', 'on'),\n('throttle_DMPP', '0', '', 'off', 'on'),\n('throttle_BPS', '0', '', 'off', 'on'),\n('throttle_MPS', '3', '', 'off', 'on'),\n('throttle_SMTP', 'individual', '', 'off', 'on'),\n('public_history', 'on', 'Public Mailing History', 'off', 'on'),\n('version', 'Aardvark PR16.1', 'poMMo Version', 'on', 'off'),\n('key', '1e0b60', 'Unique Identifier', 'on', 'off'),\n('revision', '42', 'Internal Revision', 'on', 'off');\n";
    $q->QUERY_SQL($sql, "pommo");
    $sql = "CREATE TABLE IF NOT EXISTS `pommo_fields` (\n  `field_id` smallint(5) unsigned NOT NULL auto_increment,\n  `field_active` enum('on','off') NOT NULL default 'off',\n  `field_ordering` smallint(5) unsigned NOT NULL default '0',\n  `field_name` varchar(60) default NULL,\n  `field_prompt` varchar(60) default NULL,\n  `field_normally` varchar(60) default NULL,\n  `field_array` text,\n  `field_required` enum('on','off') NOT NULL default 'off',\n  `field_type` enum('checkbox','multiple','text','date','number','comment') default NULL,\n  PRIMARY KEY  (`field_id`),\n  KEY `active` (`field_active`,`field_ordering`)\n) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n";
    $q->QUERY_SQL($sql, "pommo");
    $sql = "CREATE TABLE IF NOT EXISTS `pommo_groups` (\n  `group_id` smallint(5) unsigned NOT NULL auto_increment,\n  `group_name` tinytext NOT NULL,\n  PRIMARY KEY  (`group_id`)\n) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n";
    $q->QUERY_SQL($sql, "pommo");
    $sql = "CREATE TABLE IF NOT EXISTS `pommo_group_rules` (\n  `rule_id` int(10) unsigned NOT NULL auto_increment,\n  `group_id` int(10) unsigned NOT NULL default '0',\n  `field_id` tinyint(3) unsigned NOT NULL default '0',\n  `type` tinyint(1) NOT NULL default '0' COMMENT '0: OFF, (and), 1: ON (or)',\n  `logic` enum('is','not','greater','less','true','false','is_in','not_in') NOT NULL,\n  `value` text,\n  PRIMARY KEY  (`rule_id`),\n  KEY `group_id` (`group_id`)\n) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n";
    $q->QUERY_SQL($sql, "pommo");
    $sql = "CREATE TABLE IF NOT EXISTS `pommo_mailings` (\n  `mailing_id` int(10) unsigned NOT NULL auto_increment,\n  `fromname` varchar(60) NOT NULL default '',\n  `fromemail` varchar(60) NOT NULL default '',\n  `frombounce` varchar(60) NOT NULL default '',\n  `subject` varchar(60) NOT NULL default '',\n  `body` mediumtext NOT NULL,\n  `altbody` mediumtext,\n  `ishtml` enum('on','off') NOT NULL default 'off',\n  `mailgroup` varchar(60) NOT NULL default 'Unknown',\n  `subscriberCount` int(10) unsigned NOT NULL default '0',\n  `started` datetime NOT NULL,\n  `finished` datetime default NULL,\n  `sent` int(10) unsigned NOT NULL default '0',\n  `charset` varchar(15) NOT NULL default 'UTF-8',\n  `status` tinyint(1) NOT NULL default '1' COMMENT '0: finished, 1: processing, 2: cancelled',\n  PRIMARY KEY  (`mailing_id`),\n  KEY `status` (`status`)\n) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n";
    $q->QUERY_SQL($sql, "pommo");
    $sql = "CREATE TABLE IF NOT EXISTS `pommo_mailing_current` (\n  `current_id` int(10) unsigned NOT NULL,\n  `command` enum('none','restart','stop','cancel') NOT NULL default 'none',\n  `serial` int(10) unsigned default NULL,\n  `securityCode` char(32) default NULL,\n  `notices` longtext,\n  `current_status` enum('started','stopped') NOT NULL default 'stopped',\n  `touched` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n  PRIMARY KEY  (`current_id`)\n) ENGINE=MyISAM DEFAULT CHARSET=latin1;\n";
    $q->QUERY_SQL($sql, "pommo");
    $sql = "CREATE TABLE IF NOT EXISTS `pommo_mailing_notices` (\n  `mailing_id` int(10) unsigned NOT NULL,\n  `notice` varchar(255) NOT NULL,\n  `touched` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n  `id` smallint(5) unsigned NOT NULL,\n  KEY `mailing_id` (`mailing_id`)\n) ENGINE=MyISAM DEFAULT CHARSET=latin1;\n";
    $q->QUERY_SQL($sql, "pommo");
    $sql = "CREATE TABLE IF NOT EXISTS `pommo_queue` (\n  `subscriber_id` int(10) unsigned NOT NULL,\n  `status` tinyint(1) NOT NULL default '0' COMMENT '0: unsent, 1: sent, 2: failed',\n  `smtp` tinyint(1) NOT NULL default '0' COMMENT '0: none, 1-4: Designated to SMTP relay #',\n  PRIMARY KEY  (`subscriber_id`),\n  KEY `status` (`status`,`smtp`)\n) ENGINE=MyISAM DEFAULT CHARSET=latin1;\n";
    $q->QUERY_SQL($sql, "pommo");
    $sql = "CREATE TABLE IF NOT EXISTS `pommo_scratch` (\n  `scratch_id` int(10) unsigned NOT NULL auto_increment,\n  `time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n  `type` smallint(5) unsigned NOT NULL default '0' COMMENT 'Used to identify row type. 0 = undifined, 1 = ',\n  `int` bigint(20) default NULL,\n  `str` text,\n  PRIMARY KEY  (`scratch_id`),\n  KEY `type` (`type`)\n) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='General Purpose Table for caches, counts, etc.' AUTO_INCREMENT=1 ;\n";
    $q->QUERY_SQL($sql, "pommo");
    $sql = "CREATE TABLE IF NOT EXISTS `pommo_subscribers` (\n  `subscriber_id` int(10) unsigned NOT NULL auto_increment,\n  `email` char(60) NOT NULL default '',\n  `time_touched` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n  `time_registered` datetime NOT NULL,\n  `flag` tinyint(1) NOT NULL default '0' COMMENT '0: NULL, 1-8: REMOVE, 9: UPDATE',\n  `ip` int(10) unsigned default NULL COMMENT 'Stored with INET_ATON(), Fetched with INET_NTOA()',\n  `status` tinyint(1) NOT NULL default '2' COMMENT '0: Inactive, 1: Active, 2: Pending',\n  PRIMARY KEY  (`subscriber_id`),\n  KEY `status` (`status`,`subscriber_id`),\n  KEY `status_2` (`status`,`email`),\n  KEY `status_3` (`status`,`time_touched`),\n  KEY `status_4` (`status`,`time_registered`),\n  KEY `status_5` (`status`,`ip`),\n  KEY `flag` (`flag`)\n) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n";
    $q->QUERY_SQL($sql, "pommo");
    $sql = "CREATE TABLE IF NOT EXISTS `pommo_subscriber_data` (\n  `data_id` bigint(20) unsigned NOT NULL auto_increment,\n  `field_id` int(10) unsigned NOT NULL default '0',\n  `subscriber_id` int(10) unsigned NOT NULL default '0',\n  `value` char(60) NOT NULL default '',\n  PRIMARY KEY  (`data_id`),\n  KEY `subscriber_id` (`subscriber_id`,`field_id`)\n) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n";
    $q->QUERY_SQL($sql, "pommo");
    $sql = "CREATE TABLE IF NOT EXISTS `pommo_subscriber_pending` (\n  `pending_id` int(10) unsigned NOT NULL auto_increment,\n  `subscriber_id` int(10) unsigned NOT NULL default '0',\n  `pending_code` char(32) NOT NULL,\n  `pending_type` enum('add','del','change','password') default NULL,\n  `pending_array` text,\n  PRIMARY KEY  (`pending_id`),\n  KEY `code` (`pending_code`),\n  KEY `subscriber_id` (`subscriber_id`)\n) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n";
    $q->QUERY_SQL($sql, "pommo");
    $sql = "CREATE TABLE IF NOT EXISTS `pommo_templates` (\n  `template_id` smallint(5) unsigned NOT NULL auto_increment,\n  `name` varchar(60) NOT NULL default 'name',\n  `description` varchar(255) default NULL,\n  `body` mediumtext,\n  `altbody` mediumtext,\n  PRIMARY KEY  (`template_id`)\n) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;\n";
    $q->QUERY_SQL($sql, "pommo");
    $sql = "INSERT INTO `pommo_templates` (`template_id`, `name`, `description`, `body`, `altbody`) VALUES\n(1, 'CSS Example', 'poMMo default, featuring a plain CSS based HTML design. Includes a weblink (to view online) in the header, and a unsubscribe link in the footer.', '<style type=\"text/css\" media=\"all\">\r\n\r\n/* base styling */\r\n\r\ndiv.pommoMailing {\r\n\r\n  background-color: white; /* background color */\r\n  color: #333; /* text color */\r\n  width: 100%;\r\n  padding: 6px;\r\n\r\n}\r\n\r\ndiv.pommoMailing a, div.pommoMailing a:visited {\r\n\r\n  text-decoration: none;\r\n  color: #0067ff; /* link & visited link color */\r\n\r\n}\r\n\r\n/* header styling */\r\n\r\ndiv.pommoMailing div.pommoHeader {\r\n  \r\n  border: 1px solid black;\r\n  padding: 6px;\r\n  background-color: #DDF0BD; /* light green */\r\n  color: green;\r\n  width: 100%;\r\n  text-align: center;\r\n}\r\n\r\n/* footer styling */\r\n\r\ndiv.pommoMailing div.pommoFooter {\r\n  width: 100%;\r\n  padding: 5px 12px;\r\n  background-color: black;\r\n  color: #DDD;\r\n}\r\n\r\ndiv.pommoMailing p.smaller {\r\n  font-size: 80%;\r\n}\r\n\r\n\r\n</style>\r\n\r\n<div class=\"pommoMailing\">\r\n\r\n  <div class=\"pommoHeader\">\r\n    If you are having trouble viewing this email, <a href=\"[[!weblink]]\">click here</a>.\r\n  </div>\r\n\r\n  <h2>Bonjour!</h2>\r\n  <br />\r\n \r\n  <p>\r\n  Aliquam tempor erat eu sapien. Proin nisl lorem, hendrerit ut, venenatis vel, consequat in, est. In hac habitasse platea dictumst. Praesent malesuada tristique massa. Donec nec dui. Nulla at ligula quis diam auctor vulputate. Sed ligula ligula, elementum ac, tincidunt nec, accumsan non, risus. Aliquam convallis blandit tortor. In porta nisi interdum ante. Maecenas sem. Maecenas at felis ac massa dictum malesuada. Maecenas quis lectus. In hac habitasse platea dictumst. Ut sit amet nunc. Donec non lacus. Nulla facilisi. Vestibulum molestie. Aenean at enim sit amet augue auctor bibendum. Duis in ipsum.\r\n  </p>\r\n\r\n  <div class=\"pommoFooter\">\r\n  To unsubscribe or update your records, <a href=\"[[!unsubscribe]]\">Click here</a>.\r\n  </div>\r\n\r\n  <p class=\"smaller\">\r\n    Message sent with <a href=\"http://www.pommo.org/\">poMMo</a>.\r\n  </p>\r\n\r\n</div>', NULL);";
    $q->QUERY_SQL($sql, "pommo");
    $sql = "CREATE TABLE IF NOT EXISTS `pommo_updates` (\n  `serial` int(10) unsigned NOT NULL,\n  PRIMARY KEY  (`serial`)\n) ENGINE=MyISAM DEFAULT CHARSET=latin1;\n";
    $sql = "INSERT INTO `pommo_updates` (`serial`) VALUES (24);";
    $q->QUERY_SQL($sql, "pommo");
}
コード例 #8
0
function repairocsweb()
{
    $unix = new unix();
    $q = new mysql();
    $q->CREATE_DATABASE("ocsweb");
    $q->QUERY_SQL("CREATE TABLE IF NOT EXISTS `hardware` (\n\t\t\t\t  `ID` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\t  `DEVICEID` varchar(255) NOT NULL,\n\t\t\t\t  `NAME` varchar(255) DEFAULT NULL,\n\t\t\t\t  `WORKGROUP` varchar(255) DEFAULT NULL,\n\t\t\t\t  `USERDOMAIN` varchar(255) DEFAULT NULL,\n\t\t\t\t  `OSNAME` varchar(255) DEFAULT NULL,\n\t\t\t\t  `OSVERSION` varchar(255) DEFAULT NULL,\n\t\t\t\t  `OSCOMMENTS` varchar(255) DEFAULT NULL,\n\t\t\t\t  `PROCESSORT` varchar(255) DEFAULT NULL,\n\t\t\t\t  `PROCESSORS` int(11) DEFAULT '0',\n\t\t\t\t  `PROCESSORN` smallint(6) DEFAULT NULL,\n\t\t\t\t  `MEMORY` int(11) DEFAULT NULL,\n\t\t\t\t  `SWAP` int(11) DEFAULT NULL,\n\t\t\t\t  `IPADDR` varchar(255) DEFAULT NULL,\n\t\t\t\t  `DNS` varchar(255) DEFAULT NULL,\n\t\t\t\t  `DEFAULTGATEWAY` varchar(255) DEFAULT NULL,\n\t\t\t\t  `ETIME` datetime DEFAULT NULL,\n\t\t\t\t  `LASTDATE` datetime DEFAULT NULL,\n\t\t\t\t  `LASTCOME` datetime DEFAULT NULL,\n\t\t\t\t  `QUALITY` decimal(7,4) DEFAULT NULL,\n\t\t\t\t  `FIDELITY` bigint(20) DEFAULT '1',\n\t\t\t\t  `USERID` varchar(255) DEFAULT NULL,\n\t\t\t\t  `TYPE` int(11) DEFAULT NULL,\n\t\t\t\t  `DESCRIPTION` varchar(255) DEFAULT NULL,\n\t\t\t\t  `WINCOMPANY` varchar(255) DEFAULT NULL,\n\t\t\t\t  `WINOWNER` varchar(255) DEFAULT NULL,\n\t\t\t\t  `WINPRODID` varchar(255) DEFAULT NULL,\n\t\t\t\t  `WINPRODKEY` varchar(255) DEFAULT NULL,\n\t\t\t\t  `USERAGENT` varchar(50) DEFAULT NULL,\n\t\t\t\t  `CHECKSUM` bigint(20) unsigned DEFAULT '262143',\n\t\t\t\t  `SSTATE` int(11) DEFAULT '0',\n\t\t\t\t  `IPSRC` varchar(255) DEFAULT NULL,\n\t\t\t\t  `UUID` varchar(255) DEFAULT NULL,\n\t\t\t\t  PRIMARY KEY (`DEVICEID`,`ID`),\n\t\t\t\t  KEY `NAME` (`NAME`),\n\t\t\t\t  KEY `CHECKSUM` (`CHECKSUM`),\n\t\t\t\t  KEY `USERID` (`USERID`),\n\t\t\t\t  KEY `WORKGROUP` (`WORKGROUP`),\n\t\t\t\t  KEY `OSNAME` (`OSNAME`),\n\t\t\t\t  KEY `MEMORY` (`MEMORY`),\n\t\t\t\t  KEY `DEVICEID` (`DEVICEID`),\n\t\t\t\t  KEY `ID` (`ID`)\n\t\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=UTF8;", "ocsweb");
    $mysql = $unix->find_program("mysql");
    $password = $q->mysql_password;
    if (strlen($password) > 0) {
        $password = "******";
    }
    $cmd = "{$mysql} -u {$q->mysql_admin}{$password} --batch -h {$q->mysql_server} -P {$q->mysql_port} -D ocsweb < /usr/share/artica-postfix/bin/install/ocsbase_new.sql";
    exec($cmd, $results);
    while (list($a, $b) = each($results)) {
        if ($GLOBALS["VERBOSE"]) {
            echo "{$b}";
        }
    }
}
コード例 #9
0
function CheckHttpdConf()
{
    EnableMods();
    apache_user();
    $sock = $GLOBALS["CLASS_SOCKETS"];
    $unix = new unix();
    $users = new usersMenus();
    $freeweb = new freeweb();
    $httpdconf = $unix->LOCATE_APACHE_CONF_PATH();
    if (!is_file($httpdconf)) {
        echo "Starting......: Apache unable to stat configuration file\n";
        return;
    }
    $d_path = $unix->APACHE_DIR_SITES_ENABLED();
    $DAEMON_PATH = $unix->getmodpathfromconf($httpdconf);
    $APACHE_SRC_ACCOUNT = $unix->APACHE_SRC_ACCOUNT();
    $APACHE_SRC_GROUP = $unix->APACHE_SRC_GROUP();
    if (is_file("/etc/apache2/sites-available/default-ssl")) {
        @unlink("/etc/apache2/sites-available/default-ssl");
    }
    echo "Starting......: Apache daemon path: \"{$DAEMON_PATH}\" run has \"{$APACHE_SRC_ACCOUNT}:{$APACHE_SRC_GROUP}\"\n";
    if ($APACHE_SRC_ACCOUNT == null) {
        echo "Starting......: Apache daemon unable to determine user that will run apache\n";
        die;
    }
    if (!is_dir("/var/log/apache2")) {
        @mkdir("/var/log/apache2", 755, true);
    }
    $ApacheDisableModDavFS = $sock->GET_INFO("ApacheDisableModDavFS");
    $FreeWebListen = trim($sock->GET_INFO("FreeWebListen"));
    $FreeWebListenPort = $sock->GET_INFO("FreeWebListenPort");
    $FreeWebListenSSLPort = $sock->GET_INFO("FreeWebListenSSLPort");
    $FreeWebListen = $sock->GET_INFO("FreeWebListen");
    $FreeWebsEnableModSecurity = $sock->GET_INFO("FreeWebsEnableModSecurity");
    $FreeWebsEnableModEvasive = $sock->GET_INFO("FreeWebsEnableModEvasive");
    $FreeWebsEnableModQOS = $sock->GET_INFO("FreeWebsEnableModQOS");
    $FreeWebsEnableOpenVPNProxy = $sock->GET_INFO("FreeWebsEnableOpenVPNProxy");
    $FreeWebsOpenVPNRemotPort = trim($sock->GET_INFO("FreeWebsOpenVPNRemotPort"));
    $FreeWebDisableSSL = trim($sock->GET_INFO("FreeWebDisableSSL"));
    $TomcatEnable = $sock->GET_INFO("TomcatEnable");
    if ($FreeWebListen == null) {
        $FreeWebListen = "*";
    }
    if ($FreeWebListen != "*") {
        $FreeWebListenApache = "{$FreeWebListen}";
    }
    if (!isset($FreeWebListenApache)) {
        $FreeWebListenApache = "*";
    }
    if (!is_numeric($FreeWebDisableSSL)) {
        $FreeWebDisableSSL = 0;
    }
    if (!is_numeric($FreeWebListenSSLPort)) {
        $FreeWebListenSSLPort = 443;
    }
    if (!is_numeric($FreeWebListenPort)) {
        $FreeWebListenPort = 80;
    }
    if (!is_numeric($ApacheDisableModDavFS)) {
        $ApacheDisableModDavFS = 0;
    }
    if (!is_numeric($FreeWebsEnableModSecurity)) {
        $FreeWebsEnableModSecurity = 0;
    }
    if (!is_numeric($FreeWebsEnableModEvasive)) {
        $FreeWebsEnableModEvasive = 0;
    }
    if (!is_numeric($FreeWebsEnableModQOS)) {
        $FreeWebsEnableModQOS = 0;
    }
    if (!is_numeric($FreeWebsEnableOpenVPNProxy)) {
        $FreeWebsEnableOpenVPNProxy = 0;
    }
    if (!is_numeric($TomcatEnable)) {
        $TomcatEnable = 1;
    }
    $users = new usersMenus();
    $APACHE_MODULES_PATH = $users->APACHE_MODULES_PATH;
    $toremove[] = "mod-status.init";
    $toremove[] = "status.conf";
    $toremove[] = "fcgid.load";
    $toremove[] = "fcgid.conf";
    $toremove[] = "log_sql.load";
    $toremove[] = "log_sql_mysql.load";
    if (is_file("/etc/apache2/sites-enabled/000-default")) {
        @unlink("/etc/apache2/sites-enabled/000-default");
    }
    if (is_file("/etc/apache2/sites-available/default")) {
        @unlink("/etc/apache2/sites-available/default");
    }
    if (is_file("/etc/apache2/conf.d/zarafa-webaccess.conf")) {
        @unlink("/etc/apache2/conf.d/zarafa-webaccess.conf");
    }
    if (is_file("/etc/apache2/conf.d/zarafa-webaccess-mobile.conf")) {
        @unlink("/etc/apache2/conf.d/zarafa-webaccess-mobile.conf");
    }
    if (is_file("/etc/httpd/conf/extra/httpd-info.conf")) {
        @unlink("/etc/httpd/conf/extra/httpd-info.conf");
    }
    while (list($num, $file) = each($toremove)) {
        shell_exec("/bin/rm -f {$DAEMON_PATH}/mods-enabled/{$file} >/dev/null 2>&1");
        shell_exec("/bin/rm -f {$DAEMON_PATH}/mods-available/{$file} >/dev/null 2>&1");
    }
    $sql = "SELECT ServerPort FROM freeweb WHERE ServerPort>0 GROUP BY ServerPort";
    $q = new mysql();
    $conf[] = "NameVirtualHost {$FreeWebListenApache}:{$FreeWebListenPort}";
    $results = $q->QUERY_SQL($sql, 'artica_backup');
    if (!$q->ok) {
        if ($GLOBALS["VERBOSE"]) {
            echo $q->mysql_error . "\n";
            return;
        }
    }
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        $conf[] = "NameVirtualHost {$FreeWebListenApache}:{$ligne["ServerPort"]}";
    }
    $conf[] = "Listen {$FreeWebListenPort}";
    if ($FreeWebDisableSSL == 0) {
        $conf[] = "<IfModule mod_ssl.c>";
        $conf[] = "\tListen {$FreeWebListenSSLPort}";
        $conf[] = "\tNameVirtualHost {$FreeWebListen}:{$FreeWebListenSSLPort}";
        $conf[] = "</IfModule>";
        $conf[] = "";
        $conf[] = "<IfModule mod_gnutls.c>";
        $conf[] = "\tNameVirtualHost {$FreeWebListen}:{$FreeWebListenSSLPort}";
        $conf[] = "\tListen {$FreeWebListenSSLPort}";
        $conf[] = "</IfModule>";
        $conf[] = "<IfModule mod_fcgid.c>";
    }
    $conf[] = "\tPHP_Fix_Pathinfo_Enable 1";
    $conf[] = "";
    if (!is_dir("{$DAEMON_PATH}/sites-available")) {
        @mkdir("{$DAEMON_PATH}/sites-available", 666, true);
    }
    @file_put_contents("{$DAEMON_PATH}/ports.conf", @implode("\n", $conf));
    echo "Starting......: Apache {$DAEMON_PATH}/ports.conf for NameVirtualHost {$FreeWebListen}:{$FreeWebListenPort} done\n";
    if ($FreeWebsEnableModSecurity == 1) {
        $f[] = "<IfModule security2_module>";
        $f[] = "   SecRuleEngine On";
        $f[] = "   #SecServerSignature";
        //$f[]="   #SecFilterCheckURLEncoding {$Params["SecFilterCheckURLEncoding"]}";
        //$f[]="   #SecFilterCheckUnicodeEncoding {$Params["SecFilterCheckUnicodeEncoding"]}";
        //$f[]="   SecFilterForceByteRange 1 255";
        //$f[]="   SecAuditEngine RelevantOnly";
        $f[] = "   SecAuditEngine RelevantOnly";
        $f[] = "   SecAuditLog /var/log/apache2/modsec_audit_log";
        $f[] = "   SecDebugLog /var/log/apache2/modsec_debug_log";
        $f[] = "   SecDebugLogLevel 0";
        $f[] = "   SecRequestBodyAccess Off";
        $f[] = "   SecDefaultAction \"phase:2,deny,log,status:'Hello World!'\"";
        $f[] = "</IfModule>\n\n";
        echo "Starting......: Apache {$DAEMON_PATH}/mod_security.conf\n";
        @file_put_contents("{$DAEMON_PATH}/mod_security.conf", @implode("\n", $f));
        unset($f);
    }
    if ($FreeWebsEnableModEvasive == 1) {
        $Params = unserialize(base64_decode($sock->GET_INFO("modEvasiveDefault")));
        if (!is_numeric($Params["DOSHashTableSize"])) {
            $Params["DOSHashTableSize"] = 1024;
        }
        if (!is_numeric($Params["DOSPageCount"])) {
            $Params["DOSPageCount"] = 10;
        }
        if (!is_numeric($Params["DOSSiteCount"])) {
            $Params["DOSSiteCount"] = 150;
        }
        if (!is_numeric($Params["DOSPageInterval"])) {
            $Params["DOSPageInterval"] = 1.5;
        }
        if (!is_numeric($Params["DOSSiteInterval"])) {
            $Params["DOSSiteInterval"] = 1.5;
        }
        if (!is_numeric($Params["DOSBlockingPeriod"])) {
            $Params["DOSBlockingPeriod"] = 10.7;
        }
        $f[] = "   LoadModule evasive20_module modules/mod_evasive20.so";
        $f[] = "   ExtendedStatus On";
        $f[] = "   DOSHashTableSize {$Params["DOSHashTableSize"]}";
        $f[] = "   DOSPageCount {$Params["DOSPageCount"]}";
        $f[] = "   DOSSiteCount {$Params["DOSSiteCount"]}";
        $f[] = "   DOSPageInterval {$Params["DOSPageInterval"]}";
        $f[] = "   DOSSiteInterval {$Params["DOSSiteInterval"]}";
        $f[] = "   DOSBlockingPeriod {$Params["DOSBlockingPeriod"]}";
        $f[] = "   DOSLogDir  \"/var/log/apache2/mod_evasive.log\"";
        $f[] = "   DOSSystemCommand \"/bin/echo `date '+%F %T'` apache2  %s >> /var/log/apache2/dos_evasive_attacks.log\"";
        $f[] = "";
        echo "Starting......: Apache {$DAEMON_PATH}/mod_evasive.conf\n";
        @file_put_contents("{$DAEMON_PATH}/mod_evasive.conf", @implode("\n", $f));
        unset($f);
    }
    apache_security($DAEMON_PATH);
    $httpdconf_data = @file_get_contents($httpdconf);
    if (preg_match("#<Location \\/server-status>(.+?)<\\/Location>#is", $httpdconf_data, $re)) {
        $httpdconf_data = str_replace($re[0], "", $httpdconf_data);
    }
    $f = explode("\n", $httpdconf_data);
    while (list($num, $ligne) = each($f)) {
        if (preg_match("#^Include\\s+#", $ligne)) {
            echo "Starting......: Apache removing {$f[$num]}\n";
            $f[$num] = null;
        }
        if (preg_match("#\\#.*?Include\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#Listen\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#ProxyRequests#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#ProxyVia#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#AllowCONNECT#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#KeepAlive#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#Timeout\\s+[0-9]+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#MaxKeepAliveRequests\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#KeepAliveTimeout\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#MinSpareServers\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#MaxSpareServers\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#StartServers\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#MaxClients\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#MaxRequestsPerChild\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#LoadModule\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#ErrorLog\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#LogFormat\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#User\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#Group\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#CustomLog\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#LogLevel#", $ligne)) {
            $f[$num] = null;
        }
        if (trim($ligne) == "Loglevel info") {
            $f[$num] = null;
        }
    }
    $FreeWebPerformances = unserialize(base64_decode($sock->GET_INFO("FreeWebPerformances")));
    if (!isset($FreeWebPerformances["Timeout"])) {
        $FreeWebPerformances["Timeout"] = 300;
    }
    if (!isset($FreeWebPerformances["KeepAlive"])) {
        $FreeWebPerformances["KeepAlive"] = 0;
    }
    if (!isset($FreeWebPerformances["MaxKeepAliveRequests"])) {
        $FreeWebPerformances["MaxKeepAliveRequests"] = 100;
    }
    if (!isset($FreeWebPerformances["KeepAliveTimeout"])) {
        $FreeWebPerformances["KeepAliveTimeout"] = 15;
    }
    if (!isset($FreeWebPerformances["MinSpareServers"])) {
        $FreeWebPerformances["MinSpareServers"] = 5;
    }
    if (!isset($FreeWebPerformances["MaxSpareServers"])) {
        $FreeWebPerformances["MaxSpareServers"] = 10;
    }
    if (!isset($FreeWebPerformances["StartServers"])) {
        $FreeWebPerformances["StartServers"] = 5;
    }
    if (!isset($FreeWebPerformances["MaxClients"])) {
        $FreeWebPerformances["MaxClients"] = 50;
    }
    if (!isset($FreeWebPerformances["MaxRequestsPerChild"])) {
        $FreeWebPerformances["MaxRequestsPerChild"] = 10000;
    }
    if (!is_numeric($FreeWebPerformances["Timeout"])) {
        $FreeWebPerformances["Timeout"] = 300;
    }
    if (!is_numeric($FreeWebPerformances["KeepAlive"])) {
        $FreeWebPerformances["KeepAlive"] = 0;
    }
    if (!is_numeric($FreeWebPerformances["MaxKeepAliveRequests"])) {
        $FreeWebPerformances["MaxKeepAliveRequests"] = 100;
    }
    if (!is_numeric($FreeWebPerformances["KeepAliveTimeout"])) {
        $FreeWebPerformances["KeepAliveTimeout"] = 15;
    }
    if (!is_numeric($FreeWebPerformances["MinSpareServers"])) {
        $FreeWebPerformances["MinSpareServers"] = 5;
    }
    if (!is_numeric($FreeWebPerformances["MaxSpareServers"])) {
        $FreeWebPerformances["MaxSpareServers"] = 10;
    }
    if (!is_numeric($FreeWebPerformances["StartServers"])) {
        $FreeWebPerformances["StartServers"] = 5;
    }
    if (!is_numeric($FreeWebPerformances["MaxClients"])) {
        $FreeWebPerformances["MaxClients"] = 50;
    }
    if (!is_numeric($FreeWebPerformances["MaxRequestsPerChild"])) {
        $FreeWebPerformances["MaxRequestsPerChild"] = 10000;
    }
    reset($f);
    while (list($num, $ligne) = each($f)) {
        if (trim($ligne) == null) {
            continue;
        }
        if (substr($ligne, 0, 1) == "#") {
            continue;
        }
        $httpd[] = $ligne;
    }
    if ($FreeWebPerformances["KeepAlive"] == 1) {
        $FreeWebPerformances["KeepAlive"] = "On";
    } else {
        $FreeWebPerformances["KeepAlive"] = "Off";
    }
    $httpd[] = "User\t\t\t\t   {$APACHE_SRC_ACCOUNT}";
    $httpd[] = "Group\t\t\t\t   {$APACHE_SRC_GROUP}";
    $httpd[] = "Timeout              {$FreeWebPerformances["Timeout"]}";
    $httpd[] = "KeepAlive            {$FreeWebPerformances["KeepAlive"]}";
    $httpd[] = "KeepAliveTimeout     {$FreeWebPerformances["KeepAliveTimeout"]}";
    $httpd[] = "StartServers         {$FreeWebPerformances["StartServers"]}";
    $httpd[] = "MaxClients           {$FreeWebPerformances["MaxClients"]}";
    $httpd[] = "MinSpareServers      {$FreeWebPerformances["MinSpareServers"]}";
    $httpd[] = "MaxSpareServers      {$FreeWebPerformances["MaxSpareServers"]}";
    $httpd[] = "MaxRequestsPerChild  {$FreeWebPerformances["MaxRequestsPerChild"]}";
    $httpd[] = "MaxKeepAliveRequests {$FreeWebPerformances["MaxKeepAliveRequests"]}";
    if ($FreeWebsEnableOpenVPNProxy == 1) {
        if ($FreeWebsOpenVPNRemotPort != null) {
            $httpd[] = "ProxyRequests On";
            $httpd[] = "ProxyVia On";
            $httpd[] = "AllowCONNECT {$FreeWebsOpenVPNRemotPort}";
            $httpd[] = "KeepAlive On";
        }
    }
    //$dir_master=$unix->getmodpathfromconf();
    $httpd[] = "Include {$DAEMON_PATH}/mods-enabled/*.load";
    $httpd[] = "Include {$DAEMON_PATH}/mods-enabled/*.conf";
    $httpd[] = "Include {$DAEMON_PATH}/mods-enabled/*.init";
    if (basename($httpdconf) != "httpd.conf") {
        $httpd[] = "Include {$DAEMON_PATH}/httpd.conf";
    }
    $httpd[] = "Include {$DAEMON_PATH}/ports.conf";
    if ($FreeWebsEnableModSecurity == 1) {
        $httpd[] = "Include {$DAEMON_PATH}/mod_security.conf";
    }
    if ($FreeWebsEnableModEvasive == 1) {
        $httpd[] = "Include {$DAEMON_PATH}/mod_evasive.conf";
    }
    $httpd[] = 'Loglevel info';
    $httpd[] = 'ErrorLog /var/log/apache2/error.log';
    $httpd[] = 'LogFormat "%h %l %u %t \\"%r\\" %<s %b" common';
    $httpd[] = 'CustomLog /var/log/apache2/access.log common';
    $mod_status = $freeweb->mod_status();
    if ($mod_status != null) {
        $status[] = "<IfModule mod_status.c>";
        $status[] = "\tExtendedStatus On";
        $status[] = "{$mod_status}";
        $status[] = "</IfModule>";
        @file_put_contents("{$DAEMON_PATH}/mods-enabled/mod-status.init", @implode("\n", $status));
    }
    @unlink("{$DAEMON_PATH}/mods-enabled/pagespeed.conf");
    if ($users->APACHE_MOD_PAGESPEED) {
        if (!is_dir("/var/cache/apache2/mod_pagespeed/default/files")) {
            @mkdir("/var/cache/apache2/mod_pagespeed/default/files", 644, true);
        }
        $pspedd[] = "<IfModule pagespeed_module>";
        $pspedd[] = "\tModPagespeedFileCachePath            \"/var/cache/apache2/mod_pagespeed/default\"";
        $pspedd[] = "\tModPagespeedGeneratedFilePrefix      \"/var/cache/apache2/mod_pagespeed/files/\"";
        $pspedd[] = "\tSetOutputFilter MOD_PAGESPEED_OUTPUT_FILTER";
        $pspedd[] = "\tAddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html";
        $pspedd[] = "</IfModule>";
        @file_put_contents("{$DAEMON_PATH}/mods-enabled/pagespeed.conf", @implode("\n", $pspedd));
    }
    if ($users->APACHE_MOD_LOGSSQL) {
        $q = new mysql();
        if (!$q->DATABASE_EXISTS("apachelogs")) {
            $q->CREATE_DATABASE("apachelogs");
        }
        $APACHE_MOD_LOGSSQL[] = "<IfModule log_sql_mysql_module>";
        $APACHE_MOD_LOGSSQL[] = "\tLogSQLLoginInfo mysql://{$q->mysql_admin}:{$q->mysql_password}@{$q->mysql_server}:{$q->mysql_port}/apachelogs";
        $APACHE_MOD_LOGSSQL[] = "\tLogSQLMassVirtualHosting On";
        $APACHE_MOD_LOGSSQL[] = "\tLogSQLmachineID {$users->hostname}";
        $APACHE_MOD_LOGSSQL[] = "\tLogSQLTransferLogFormat AbcHhmMpRSstTUuvz";
        $APACHE_MOD_LOGSSQL[] = "</IfModule>";
        @file_put_contents("{$DAEMON_PATH}/mods-enabled/log_sql_module.conf", @implode("\n", $APACHE_MOD_LOGSSQL));
    }
    if (is_file("/etc/apache2/sysconfig.d/loadmodule.conf")) {
        $httpd[] = "Include /etc/apache2/sysconfig.d/loadmodule.conf";
    }
    if (is_file("/etc/apache2/uid.conf")) {
        $httpd[] = "Include /etc/apache2/uid.conf";
    }
    if (is_file("/etc/apache2/default-server.conf")) {
        patch_suse_default_server();
        $httpd[] = "Include /etc/apache2/default-server.conf";
    }
    $httpd[] = "Include {$DAEMON_PATH}/conf.d/";
    $httpd[] = "Include {$DAEMON_PATH}/sites-enabled/";
    if (is_file("{$APACHE_MODULES_PATH}/mod_php5.so")) {
        $httpd[] = "LoadModule php5_module {$APACHE_MODULES_PATH}/mod_php5.so";
    }
    if (is_file("{$APACHE_MODULES_PATH}/mod_ldap.so")) {
        $httpd[] = "LoadModule ldap_module {$APACHE_MODULES_PATH}/mod_ldap.so";
    }
    if ($ApacheDisableModDavFS == 0) {
        if (is_file("{$APACHE_MODULES_PATH}/mod_dav.so")) {
            echo "Starting......: Apache module 'dav_module' enabled\n";
            $httpd[] = "LoadModule dav_module {$APACHE_MODULES_PATH}/mod_dav.so";
        }
        if (is_file("{$APACHE_MODULES_PATH}/mod_dav_lock.so")) {
            echo "Starting......: Apache module 'dav_lock_module' enabled\n";
            $httpd[] = "LoadModule dav_lock_module {$APACHE_MODULES_PATH}/mod_dav_lock.so";
        }
        if (is_file("{$APACHE_MODULES_PATH}/mod_dav_fs.so")) {
            echo "Starting......: Apache module 'dav_fs_module' enabled\n";
            $httpd[] = "LoadModule dav_fs_module {$APACHE_MODULES_PATH}/mod_dav_fs.so";
        }
    }
    $httpd[] = "";
    echo "Starting......: Apache {$httpdconf} done\n";
    @file_put_contents($httpdconf, @implode("\n", $httpd));
    // MODULES -----------------------------------------------------------------------
    if (!is_dir("{$DAEMON_PATH}/mods-enabled")) {
        @mkdir("{$DAEMON_PATH}/mods-enabled", 666, true);
    }
    if (!is_file("{$DAEMON_PATH}/httpd.conf")) {
        @file_put_contents("{$DAEMON_PATH}/httpd.conf", "#");
    }
    @unlink("/etc/libapache2-mod-jk/workers.properties");
    @unlink("/etc/apache2/workers.properties");
    @unlink("{$DAEMON_PATH}/conf.d/jk.conf");
    $array["php5_module"] = "libphp5.so";
    //$array["access_module"]="mod_access.so";
    $array["qos_module"] = "mod_qos.so";
    $array["rewrite_module"] = "mod_rewrite.so";
    $array["cache_module"] = "mod_cache.so";
    $array["disk_cache_module"] = "mod_disk_cache.so";
    $array["mem_cache_module"] = "mod_mem_cache.so";
    $array["expires_module"] = "mod_expires.so";
    $array["status_module"] = "mod_status.so";
    $array["geoip_module"] = "mod_geoip.so";
    $array["info_module"] = "mod_info.so";
    $array["suexec_module"] = "mod_suexec.so";
    $array["fcgid_module"] = "mod_fcgid.so";
    $array["authz_host_module"] = "mod_authz_host.so";
    $array["dir_module"] = "mod_dir.so";
    $array["mime_module"] = "mod_mime.so";
    $array["log_config_module"] = "mod_log_config.so";
    $array["alias_module"] = "mod_alias.so";
    $array["autoindex_module"] = "mod_autoindex.so";
    $array["negotiation_module"] = "mod_negotiation.so";
    $array["setenvif_module"] = "mod_setenvif.so";
    $array["logio_module"] = "mod_logio.so";
    $array["auth_basic_module"] = "mod_auth_basic.so";
    $array["authn_file_module"] = "mod_authn_file.so";
    $array["vhost_alias_module"] = "mod_vhost_alias.so";
    $array["ssl_module"] = "mod_ssl.so";
    $array["log_sql_module"] = "mod_log_sql.so";
    $array["log_sql_mysql_module"] = "mod_log_sql_mysql.so";
    if (is_file("{$APACHE_MODULES_PATH}/mod_pagespeed.so")) {
        echo "Starting......: Apache module 'mod_pagespeed' enabled\n";
        $ppsped[] = "LoadModule pagespeed_module {$APACHE_MODULES_PATH}/mod_pagespeed.so";
        if (is_file("{$APACHE_MODULES_PATH}/mod_deflate.so")) {
            $ppsped[] = "# Only attempt to load mod_deflate if it hasn't been loaded already.";
            $ppsped[] = "<IfModule !mod_deflate.c>";
            $ppsped[] = "\tLoadModule deflate_module {$APACHE_MODULES_PATH}/mod_deflate.so";
            $ppsped[] = "</IfModule>";
        }
        @file_put_contents("{$DAEMON_PATH}/mods-enabled/mod_pagespeed.load", @implode("\n", $ppsped));
    } else {
        echo "Starting......: Apache module 'mod_pagespeed' {$APACHE_MODULES_PATH}/mod_pagespeed.so no such file\n";
    }
    if ($users->TOMCAT_INSTALLED) {
        if ($TomcatEnable == 1) {
            if (is_dir($users->TOMCAT_DIR)) {
                if (is_dir($users->TOMCAT_JAVA)) {
                    $array["jk_module"] = "mod_jk.so";
                    $ftom[] = "workers.tomcat_home={$users->TOMCAT_DIR}";
                    $ftom[] = "workers.java_home={$users->TOMCAT_JAVA}";
                    $ftom[] = "ps=/";
                    $ftom[] = "worker.list=ajp13_worker";
                    $ftom[] = "worker.ajp13_worker.port=8009";
                    $ftom[] = "worker.ajp13_worker.host=127.0.0.1";
                    $ftom[] = "worker.ajp13_worker.type=ajp13";
                    $ftom[] = "worker.ajp13_worker.lbfactor=1";
                    $ftom[] = "worker.loadbalancer.type=lb";
                    $ftom[] = "worker.loadbalancer.balance_workers=ajp13_worker";
                    $ftom[] = "";
                    @file_put_contents("/etc/apache2/workers.properties", @implode("\n", $ftom));
                    @mkdir("/etc/libapache2-mod-jk", 644);
                    @file_put_contents("/etc/libapache2-mod-jk/workers.properties", @implode("\n", $ftom));
                    $faptom[] = "<ifmodule mod_jk.c>";
                    $faptom[] = "\tJkWorkersFile /etc/apache2/workers.properties";
                    $faptom[] = "\tJkLogFile /var/log/apache2/mod_jk.log";
                    $faptom[] = "\tJkLogLevel error";
                    $faptom[] = "</ifmodule>";
                    @file_put_contents("{$DAEMON_PATH}/conf.d/jk.conf", @implode("\n", $faptom));
                }
            }
        }
    }
    @unlink("{$DAEMON_PATH}/mods-enabled/mod-security.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/mod_security.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/mod-evasive.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/mod_evasive.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/geoip.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/status.conf");
    @unlink("{$DAEMON_PATH}/mods-enabled/status.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/php5.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/jk.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/dav_lock_module.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/dav_module.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/dav_fs_module.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/pagespeed.load");
    $sock = new sockets();
    $FreeWebsDisableMOdQOS = $sock->GET_INFO("FreeWebsDisableMOdQOS");
    if (!is_numeric($FreeWebsDisableMOdQOS)) {
        $FreeWebsDisableMOdQOS = 0;
    }
    if ($FreeWebsEnableModQOS == 0) {
        $FreeWebsDisableMOdQOS = 1;
    }
    if ($FreeWebsDisableMOdQOS == 1) {
        unset($array["qos_module"]);
        @unlink("{$DAEMON_PATH}/mods-enabled/qos_module.load");
    }
    if ($FreeWebsEnableModSecurity == 1) {
        if (is_file("{$APACHE_MODULES_PATH}/mod_security2.so")) {
            $a[] = "LoadFile /usr/lib/libxml2.so.2";
            $a[] = "LoadModule security2_module {$APACHE_MODULES_PATH}/mod_security2.so";
            echo "Starting......: Apache module 'mod_security2' enabled\n";
            @file_put_contents("{$DAEMON_PATH}/mods-enabled/mod_security.load", @implode("\n", $a));
            unset($a);
        } else {
            echo "Starting......: Apache {$APACHE_MODULES_PATH}/mod_security2.so no such file\n";
        }
    } else {
        echo "Starting......: Apache module 'mod_security2' disabled\n";
    }
    if ($FreeWebsEnableModEvasive == 1) {
        if (is_file("{$APACHE_MODULES_PATH}/mod_evasive20.so")) {
            $a[] = "LoadModule evasive20_module {$APACHE_MODULES_PATH}/mod_evasive20.so";
            echo "Starting......: Apache module 'mod_evasive2' enabled\n";
            @file_put_contents("{$DAEMON_PATH}/mods-enabled/mod_evasive.load", @implode("\n", $a));
        } else {
            echo "Starting......: Apache {$APACHE_MODULES_PATH}/mod_evasive20.so no such file\n";
        }
    } else {
        echo "Starting......: Apache module 'mod_evasive2' disabled\n";
    }
    $sql = "SELECT COUNT(servername) as tcount FROM freeweb WHERE UseReverseProxy=1";
    $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, 'artica_backup'));
    $proxys_mods["proxy_module"] = "mod_proxy.so";
    $proxys_mods["proxy_http_module"] = "mod_proxy_http.so";
    $proxys_mods["proxy_ftp_module"] = "mod_proxy_ftp.so";
    $proxys_mods["proxy_connect_module"] = "mod_proxy_connect.so";
    $proxys_mods["headers_module"] = "mod_headers.so";
    $proxys_mods["deflate_module"] = "mod_deflate.so";
    $proxys_mods["xml2enc_module"] = "mod_xml2enc.so";
    $proxys_mods["proxy_html_module"] = "mod_proxy_html.so";
    $proxys_orgs[] = "proxy_ajp.load";
    $proxys_orgs[] = "proxy_balancer.load";
    $proxys_orgs[] = "proxy.conf";
    $proxys_orgs[] = "proxy_connect.load";
    $proxys_orgs[] = "proxy_ftp.load";
    $proxys_orgs[] = "proxy_html.conf";
    $proxys_orgs[] = "proxy_html.load";
    $proxys_orgs[] = "proxy_http.load";
    $proxys_orgs[] = "proxy.load";
    $proxys_orgs[] = "proxy_scgi.load";
    if (is_file("/etc/httpd/conf.d/proxy_ajp.conf")) {
        @unlink("/etc/httpd/conf.d/proxy_ajp.conf");
    }
    while (list($module, $lib) = each($proxys_orgs)) {
        if (is_file("{$DAEMON_PATH}/mods-enabled/{$lib}")) {
            @unlink("{$DAEMON_PATH}/mods-enabled/{$lib}");
        }
    }
    while (list($module, $lib) = each($proxys_mods)) {
        if (is_file("{$DAEMON_PATH}/mods-enabled/{$module}.load")) {
            @unlink("{$DAEMON_PATH}/mods-enabled/{$module}.load");
        }
    }
    echo "Starting......: Apache {$ligne["tcount"]} reverse proxy(s)\n";
    $countDeProxy = $ligne["tcount"];
    if ($FreeWebsEnableOpenVPNProxy == 1) {
        if ($FreeWebsOpenVPNRemotPort != null) {
            $countDeProxy = $countDeProxy + 1;
        }
    }
    if ($countDeProxy > 0) {
        reset($proxys_mods);
        while (list($module, $lib) = each($proxys_mods)) {
            if (!is_file("{$APACHE_MODULES_PATH}/{$lib}")) {
                echo "Starting......: Apache module '{$module}' '{$lib}' no such file\n";
                continue;
            }
            echo "Starting......: Apache module '{$module}' enabled\n";
            $final_proxys[] = "LoadModule {$module} {$APACHE_MODULES_PATH}/{$lib}";
        }
        @file_put_contents("{$DAEMON_PATH}/mods-enabled/proxy_module.load", @implode("\n", $final_proxys));
    }
    while (list($module, $lib) = each($array)) {
        if (!is_file("{$APACHE_MODULES_PATH}/{$lib}")) {
            echo "Starting......: Apache module '{$module}' '{$lib}' no such file\n";
            continue;
        }
        echo "Starting......: Apache module '{$module}' enabled\n";
        @file_put_contents("{$DAEMON_PATH}/mods-enabled/{$module}.load", "LoadModule {$module} {$APACHE_MODULES_PATH}/{$lib}");
    }
}
コード例 #10
0
ファイル: exec.bwm-ng.php プロジェクト: BillTheBest/1.6.x
function rotate()
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $TimeFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    if ($GLOBALS["VERBOSE"]) {
        echo "TimeFile={$TimeFile}\n";
    }
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $time = $unix->PROCCESS_TIME_MIN($pid);
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Already Artica task running PID {$pid} since {$time}mn\n";
        }
        return;
    }
    @file_put_contents($pidfile, getmypid());
    $xtime = $unix->file_time_min($TimeFile);
    if (!$GLOBALS['VERBOSE']) {
        if ($xtime < 5) {
            return;
        }
    }
    @unlink($TimeFile, time());
    @file_put_contents($TimeFile, time());
    $q = new mysql();
    $echo = $unix->find_program("echo");
    if (!$q->DATABASE_EXISTS("bwmng")) {
        $q->CREATE_DATABASE("bwmng");
    }
    if (!$q->DATABASE_EXISTS("bwmng", true)) {
        return;
    }
    @copy("/home/artica/bwm-ng/interfaces.csv", "/home/artica/bwm-ng/interfaces.csv." . time());
    @unlink("/home/artica/bwm-ng/interfaces.csv");
    $files = $unix->DirFiles("/home/artica/bwm-ng");
    if (system_is_overloaded(__FILE__)) {
        if ($GLOBALS["VERBOSE"]) {
            echo "OVERLOADED !!!!\n";
        }
        return;
    }
    while (list($filename, $notused) = each($files)) {
        if ($filename == "interfaces.csv") {
            continue;
        }
        $filepath = "/home/artica/bwm-ng/{$filename}";
        $filetime = $unix->file_time_min($filepath);
        if ($filetime > 60) {
            @unlink($filepath);
            continue;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "Open {$filepath} {$filetime}mn\n";
        }
        $row = 1;
        if (($handle = fopen($filepath, "r")) !== FALSE) {
            while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
                $num = count($data);
                if ($num == 0) {
                    continue;
                }
                $row++;
                $uniq_key = md5(serialize($data));
                $Unix_Timestamp = $data[0];
                if (!is_numeric($Unix_Timestamp)) {
                    continue;
                }
                $Interface_Name = $data[1];
                if (trim($Interface_Name) == null) {
                    print_r($data);
                    continue;
                }
                $BytesOut = intval($data[2]);
                $BytesIn = intval($data[3]);
                $BytesTotal = $data[4];
                $PacketsOut = $data[5];
                $PacketsIn = $data[6];
                $PacketsTotal = $data[7];
                if ($BytesOut == 0 && $BytesIn == 0) {
                    continue;
                }
                $Date = date("Y-m-d H:i:s", $Unix_Timestamp);
                $tableT = date("YmdH", $Unix_Timestamp) . "_bwmrt";
                if ($Interface_Name == "total") {
                    $array_total[$tableT][] = "('{$uniq_key}','{$Date}','{$BytesOut}','{$BytesIn}')";
                    continue;
                }
                $table = date("YmdH", $Unix_Timestamp) . "_bwmrh";
                $array_eths[$table][] = "('{$uniq_key}','{$Interface_Name}','{$Date}','{$BytesOut}','{$BytesIn}')";
            }
            fclose($handle);
            if (system_is_overloaded(__FILE__)) {
                break;
            }
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "{$filepath} CLOSED: " . count($array_eths) . " eths, " . count($array_total) . " total\n";
        }
        if (array_to_interfaces($array_eths)) {
            if (array_to_total($array_total)) {
                if ($GLOBALS["VERBOSE"]) {
                    echo "{$filepath} > DELETE\n";
                }
                @unlink($filepath);
            }
        } else {
            @unlink($filepath);
        }
        $array_eths = array();
        $array_total = array();
    }
    restart(true);
    if (system_is_overloaded(__FILE__)) {
        if ($GLOBALS["VERBOSE"]) {
            echo "OVERLOADED !!!!\n";
        }
        return;
    }
    build_days();
    build_current_time();
}
コード例 #11
0
function snapshot()
{
    $unix = new unix();
    $password = null;
    $mysqldump = $unix->find_program("mysqldump");
    $gzip = $unix->find_program("gzip");
    $sock = new sockets();
    $rm = $unix->find_program("rm");
    $BaseWorkDir = "/usr/share/artica-postfix/snapshots/" . time();
    $tar = $unix->find_program("tar");
    @mkdir($BaseWorkDir, 0755, true);
    $nice = $unix->EXEC_NICE();
    $q = new mysql();
    $LIST_TABLES_ARTICA_BACKUP = $q->LIST_TABLES_ARTICA_BACKUP();
    if ($q->mysql_password != null) {
        $password = "******" . $unix->shellEscapeChars($q->mysql_password);
    }
    $prefix = trim("{$nice} {$mysqldump} --add-drop-table --single-transaction --force --insert-ignore -S /var/run/mysqld/mysqld.sock -u {$q->mysql_admin}{$password} artica_backup");
    $ARRAY["artica_backup_blacklists"]["ipblocks_db"] = true;
    $ARRAY["artica_backup_blacklists"]["adgroups"] = true;
    $ARRAY["artica_backup_blacklists"]["adusers"] = true;
    $ARRAY["artica_backup_blacklists"]["drupal_queue_orders"] = true;
    $ARRAY["artica_backup_blacklists"]["haarp"] = true;
    $ARRAY["artica_backup_blacklists"]["icons_db"] = true;
    $ARRAY["artica_backup_blacklists"]["setup_center"] = true;
    $ARRAY["artica_backup_blacklists"]["clamavsig"] = true;
    $ARRAY["artica_backup_blacklists"]["kav4proxy_license"] = true;
    $ARRAY["artica_backup_blacklists"]["getent_groups"] = true;
    $ARRAY["artica_backup_blacklists"]["zarafa_orphaned"] = true;
    $c = 0;
    @mkdir("{$BaseWorkDir}/artica_backup", 0755, true);
    while (list($table_name, $val) = each($LIST_TABLES_ARTICA_BACKUP)) {
        $table_name = trim($table_name);
        if (isset($ARRAY["artica_backup_blacklists"][$table_name])) {
            continue;
        }
        if (preg_match("#^activedirectory#", $table_name)) {
            continue;
        }
        if (preg_match("#^amanda#", $table_name)) {
            continue;
        }
        if ($q->COUNT_ROWS($table_name, "artica_backup") == 0) {
            $GLOBALS["TRUNCATES"]["artica_backup"][$table_name] = true;
            continue;
        }
        progress(15, "{backup} {$table_name}");
        echo "{$BaseWorkDir}/artica_backup/{$table_name}.gz\n";
        $cmd = "{$prefix} {$table_name} | {$gzip} > {$BaseWorkDir}/artica_backup/{$table_name}.gz 2>&1";
        if ($GLOBALS["VERBOSE"]) {
            echo "{$cmd}\n";
        }
        exec($cmd, $results);
        if ($unix->MYSQL_BIN_PARSE_ERROR($results)) {
            echo "Failed to create snapshot\n " . @implode("\n", $results);
            system_admin_events("Failed to create snapshot " . @implode("\n", $results), __FUNCTION__, __FILE__, __LINE__);
            shell_exec("{$rm} -rf {$BaseWorkDir}");
            return;
        }
        $GLOBALS["ARRAY_CONTENT"]["artica_backup/{$table_name}.gz"] = @filesize("{$BaseWorkDir}/artica_backup/{$table_name}.gz");
        $c++;
    }
    $squidbin = $unix->LOCATE_SQUID_BIN();
    if (is_file($squidbin)) {
        if ($unix->is_socket("/var/run/mysqld/squid-db.sock")) {
            $q = new mysql_squid_builder();
            $LIST_TABLES_ARTICA_SQUIDLOGS = $q->LIST_TABLES_ARTICA_SQUIDLOGS();
            if ($q->mysql_password != null) {
                $password = "******" . $unix->shellEscapeChars($q->mysql_password);
            }
            $prefix = trim("{$nice} {$mysqldump} --add-drop-table --single-transaction --force --insert-ignore -S /var/run/mysqld/squid-db.sock -u root squidlogs");
            @mkdir("{$BaseWorkDir}/squidlogs", 0755, true);
            $BLACKLIST["tables_day"] = true;
            $BLACKLIST["quotachecked"] = true;
            $BLACKLIST["cached_total"] = true;
            $BLACKLIST["MySQLStats"] = true;
            $BLACKLIST["phraselists_weigthed"] = true;
            $BLACKLIST["squid_reports"] = true;
            $BLACKLIST["stats_appliance_events"] = true;
            $BLACKLIST["webfilter_catprivslogs"] = true;
            $BLACKLIST["webfilters_backupeddbs"] = true;
            $BLACKLIST["webfilters_bigcatzlogs"] = true;
            $BLACKLIST["FamilyCondensed"] = true;
            $BLACKLIST["catztemp"] = true;
            $BLACKLIST["hotspot_sessions"] = true;
            $BLACKLIST["instant_updates"] = true;
            $BLACKLIST["macscan"] = true;
            $BLACKLIST["members_uid"] = true;
            $BLACKLIST["members_macip"] = true;
            $BLACKLIST["members_mac"] = true;
            $BLACKLIST["webfilters_categories_caches"] = true;
            $BLACKLIST["webfilters_thumbnails"] = true;
            $BLACKLIST["wpad_events"] = true;
            while (list($table_name, $val) = each($LIST_TABLES_ARTICA_SQUIDLOGS)) {
                if (isset($BLACKLIST[$table_name])) {
                    continue;
                }
                if (preg_match("#[0-9]+#", $table_name)) {
                    continue;
                }
                if (preg_match("#[0-9]+#", $table_name)) {
                    continue;
                }
                if (preg_match("#updateev\$#", $table_name)) {
                    continue;
                }
                if (preg_match("#^traffic#", $table_name)) {
                    continue;
                }
                if (preg_match("#^www_#", $table_name)) {
                    continue;
                }
                if (preg_match("#^visited_#", $table_name)) {
                    continue;
                }
                if (preg_match("#^youtube_#", $table_name)) {
                    continue;
                }
                if (preg_match("#^UserAgents#", $table_name)) {
                    continue;
                }
                if (preg_match("#^UserAutDB#", $table_name)) {
                    continue;
                }
                if (preg_match("#^UserAuthDays#", $table_name)) {
                    continue;
                }
                if (preg_match("#^UserAuthDaysGrouped#", $table_name)) {
                    continue;
                }
                if (preg_match("#^UserSizeRTT#", $table_name)) {
                    continue;
                }
                if (preg_match("#^UsersAgentsDB#", $table_name)) {
                    continue;
                }
                if (preg_match("#^UsersTMP#", $table_name)) {
                    continue;
                }
                if (preg_match("#^UsersToTal#", $table_name)) {
                    continue;
                }
                if (preg_match("#^allsizes#", $table_name)) {
                    continue;
                }
                if (preg_match("#^alluid#", $table_name)) {
                    continue;
                }
                if (preg_match("#^categorize#", $table_name)) {
                    continue;
                }
                if (preg_match("#^blocked_#", $table_name)) {
                    continue;
                }
                if (preg_match("#^sites\$#", $table_name)) {
                    continue;
                }
                if (preg_match("#^users\$#", $table_name)) {
                    continue;
                }
                if (preg_match("#^ufdbunlock\$#", $table_name)) {
                    continue;
                }
                if (preg_match("#^updateblks_events\$#", $table_name)) {
                    continue;
                }
                if (preg_match("#^main_websites#", $table_name)) {
                    continue;
                }
                if (preg_match("#^notcategorized#", $table_name)) {
                    continue;
                }
                if ($q->COUNT_ROWS($table_name, "squidlogs") == 0) {
                    $GLOBALS["TRUNCATES"]["squidlogs"][$table_name] = true;
                    continue;
                }
                progress(30, "{backup} {$table_name}");
                echo "{$BaseWorkDir}/squidlogs/{$table_name}.gz\n";
                $cmd = "{$prefix} {$table_name} | {$gzip} > {$BaseWorkDir}/squidlogs/{$table_name}.gz 2>&1";
                if ($GLOBALS["VERBOSE"]) {
                    echo "{$cmd}\n";
                }
                exec($cmd, $results);
                if ($unix->MYSQL_BIN_PARSE_ERROR($results)) {
                    echo "Failed to create snapshot\n " . @implode("\n", $results);
                    shell_exec("{$rm} -rf {$BaseWorkDir}");
                    system_admin_events("Failed to create snapshot " . @implode("\n", $results), __FUNCTION__, __FILE__, __LINE__);
                    return;
                }
                $GLOBALS["ARRAY_CONTENT"]["squidlogs/{$table_name}.gz"] = @filesize("{$BaseWorkDir}/squidlogs/{$table_name}.gz");
                $c++;
            }
        }
    }
    progress(35, "{backup} OpenDLAP server");
    backup_ldap($BaseWorkDir);
    progress(40, "{backup} Reverse Proxy");
    backup_nginx($BaseWorkDir);
    progress(45, "{backup} PowerDNS");
    backup_mysql_powerdns($BaseWorkDir);
    progress(50, "{backup} Artica settings");
    backup_artica_settings($BaseWorkDir);
    @file_put_contents("{$BaseWorkDir}/TRUNCATE_TABLES", serialize($GLOBALS["TRUNCATES"]));
    $temp = $unix->FILE_TEMP() . ".tar.gz";
    $tempdir = $unix->TEMP_DIR();
    chdir($BaseWorkDir);
    progress(60, "{compressing}");
    system("{$tar} -czf {$temp} *");
    shell_exec("{$rm} -rf {$BaseWorkDir}");
    echo "{$temp}\n";
    $q = new mysql();
    $q->CREATE_DATABASE("artica_snapshots");
    $sql = "CREATE TABLE IF NOT EXISTS `snapshots` (\n\t`ID` int(11) NOT NULL AUTO_INCREMENT,\n\t`zmd5` VARCHAR(90) NOT NULL,\n\t`size` INT UNSIGNED NOT NULL,\n\t`zDate` DATETIME NOT NULL,\n\t`snap` LONGBLOB NOT NULL,\n\t `content` TEXT NOT NULL,\n\t PRIMARY KEY (`ID`),\n\t UNIQUE KEY `zmd5` (`zmd5`),\n\t KEY `zDate` (`zDate`)\n\t) ENGINE=MyISAM";
    $q->QUERY_SQL($sql, 'artica_snapshots');
    progress(70, "{saving}");
    if ($GLOBALS["SEND_META"]) {
        $articameta = new artica_meta();
        $filemeta = $tempdir . "/snapshot.tar.gz";
        if (@copy($temp, $filemeta)) {
            if (!$articameta->SendFile($filemeta, "SNAPSHOT")) {
                $articameta->events("{$temp} unable to upload", __FUNCTION__, __FILE__, __LINE__);
            }
        } else {
            $articameta->events("{$temp} unable to copy {$temp} to {$filemeta}", __FUNCTION__, __FILE__, __LINE__);
        }
        @unlink($filemeta);
    }
    $zmd5 = md5_file($temp);
    $data = mysql_escape_string2(@file_get_contents($temp));
    $size = @filesize($temp);
    $final_array = mysql_escape_string2(serialize($GLOBALS["ARRAY_CONTENT"]));
    $q->QUERY_SQL("INSERT IGNORE INTO `snapshots` (zDate,snap,size,content,zmd5) \n\t\t\tVALUES (NOW(),'{$data}','{$size}','{$final_array}','{$zmd5}')", "artica_snapshots");
    if (!$q->ok) {
        echo "{$q->mysql_error}\n";
        progress(70, "{failed}");
    }
    @unlink($temp);
    shell_exec("{$rm} -rf /usr/share/artica-postfix/snapshots");
    progress(100, "{success}");
}
コード例 #12
0
function testsDatabase()
{
    $f[] = "access_control";
    $f[] = "amavis_rules";
    $f[] = "checkhelo";
    $f[] = "checkhelo_blacklist";
    $f[] = "checkhelo_tracking";
    $f[] = "checkhelo_whitelist";
    $f[] = "checkspf";
    $f[] = "greylisting";
    $f[] = "greylisting_autoblacklist";
    $f[] = "greylisting_autowhitelist";
    $f[] = "greylisting_tracking";
    $f[] = "greylisting_whitelist";
    $f[] = "policies";
    $f[] = "policy_group_members";
    $f[] = "policy_groups";
    $f[] = "policy_members";
    $f[] = "quotas";
    $f[] = "quotas_limits";
    $f[] = "quotas_tracking";
    $f[] = "session_tracking";
    $rebuild = false;
    $q = new mysql();
    $unix = new unix();
    $dbfile = "/usr/share/artica-postfix/bin/install/cluebringer/policyd.mysql";
    if (!$q->DATABASE_EXISTS("policyd")) {
        $q->CREATE_DATABASE("policyd");
        $rebuild = true;
    }
    if (!$rebuild) {
        while (list($num, $val) = each($f)) {
            if ($q->TABLE_EXISTS($val, "policyd")) {
                echo "Starting......: cluebringer mysql table {$val} OK\n";
            } else {
                echo "Starting......: cluebringer mysql table {$val} FAILED\n";
                $rebuild = true;
                break;
            }
        }
    }
    if ($rebuild) {
        $mysqlbin = $unix->find_program("mysql");
        if (!is_file("{$mysqlbin}")) {
            echo "Starting......: cluebringer mysql binary no such file\n";
            return;
        }
        $cmd = "{$mysqlbin} --batch --host={$q->mysql_server} --port={$q->mysql_port} --user={$q->mysql_admin} --password={$q->mysql_password} --database=policyd";
        $cmd = $cmd . " <{$dbfile}";
        if ($GLOBALS["VERBOSE"]) {
            echo $cmd . "\n";
        }
        shell_exec($cmd);
    }
}
コード例 #13
0
ファイル: exec.freeweb.php プロジェクト: articatech/artica
function CheckHttpdConf()
{
    EnableMods();
    apache_user();
    $sock = $GLOBALS["CLASS_SOCKETS"];
    $unix = new unix();
    $users = new usersMenus();
    $GLOBALS["ToRestore"] = array();
    $freeweb = new freeweb();
    $chmod = $unix->find_program("chmod");
    $php5 = $unix->LOCATE_PHP5_BIN();
    $httpdconf = $unix->LOCATE_APACHE_CONF_PATH();
    if (!is_file($httpdconf)) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: Apache unable to stat configuration file\n";
        return;
    }
    $d_path = $unix->APACHE_DIR_SITES_ENABLED();
    $DAEMON_PATH = $unix->getmodpathfromconf($httpdconf);
    $APACHE_SRC_ACCOUNT = $unix->APACHE_SRC_ACCOUNT();
    $APACHE_SRC_GROUP = $unix->APACHE_SRC_GROUP();
    if (is_file("/etc/apache2/sites-available/default-ssl")) {
        @unlink("/etc/apache2/sites-available/default-ssl");
    }
    if (is_link("/etc/apache2/sites-enabled/000-default")) {
        @unlink("/etc/apache2/sites-enabled/000-default");
    }
    echo "Starting......: " . date("H:i:s") . " [INIT]: Apache daemon path: \"{$DAEMON_PATH}\" run has \"{$APACHE_SRC_ACCOUNT}:{$APACHE_SRC_GROUP}\"\n";
    if ($APACHE_SRC_ACCOUNT == null) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: Apache daemon unable to determine user that will run apache\n";
        die;
    }
    if (!is_dir("/var/log/apache2")) {
        @mkdir("/var/log/apache2", 0755, true);
    }
    if (!is_dir("/usr/share/GeoIP")) {
        @mkdir("/usr/share/GeoIP", 0755, true);
    }
    shell_exec("{$chmod} 755 /usr/share/GeoIP >/dev/null 2>&1");
    $ApacheDisableModDavFS = intval($sock->GET_INFO("ApacheDisableModDavFS"));
    $ApacheDisableModStatus = intval($sock->GET_INFO("ApacheDisableModStatus"));
    $FreeWebListenPort = $sock->GET_INFO("FreeWebListenPort");
    $FreeWebListenSSLPort = $sock->GET_INFO("FreeWebListenSSLPort");
    $FreeWebEnableModSUPhp = $sock->GET_INFO("FreeWebEnableModSUPhp");
    $FreeWebsEnableModSecurity = $sock->GET_INFO("FreeWebsEnableModSecurity");
    $FreeWebsEnableModEvasive = $sock->GET_INFO("FreeWebsEnableModEvasive");
    $FreeWebsEnableModQOS = $sock->GET_INFO("FreeWebsEnableModQOS");
    $FreeWebsEnableOpenVPNProxy = $sock->GET_INFO("FreeWebsEnableOpenVPNProxy");
    $FreeWebsOpenVPNRemotPort = trim($sock->GET_INFO("FreeWebsOpenVPNRemotPort"));
    $FreeWebDisableSSL = trim($sock->GET_INFO("FreeWebDisableSSL"));
    $FreeWebEnableSQLLog = trim($sock->GET_INFO("FreeWebEnableSQLLog"));
    $ApacheServerTokens = $sock->GET_INFO("ApacheServerTokens");
    if ($ApacheServerTokens == null) {
        $ApacheServerTokens = "Full";
    }
    $hostname = $sock->GET_INFO("ApacheServerName");
    if ($hostname == null) {
        $hostname = $sock->getFrameWork("system.php?hostname-g=yes");
        $sock->SET_INFO($hostname, "ApacheServerName");
    }
    $ZarafaWebAccessInFrontEnd = $sock->GET_INFO("ZarafaWebAccessInFrontEnd");
    if (!is_numeric($ZarafaWebAccessInFrontEnd)) {
        $ZarafaWebAccessInFrontEnd = 1;
    }
    $TomcatEnable = $sock->GET_INFO("TomcatEnable");
    if (!is_numeric($FreeWebDisableSSL)) {
        $FreeWebDisableSSL = 0;
    }
    if (!is_numeric($FreeWebListenSSLPort)) {
        $FreeWebListenSSLPort = 443;
    }
    if (!is_numeric($FreeWebListenPort)) {
        $FreeWebListenPort = 80;
    }
    if (!is_numeric($FreeWebsEnableModSecurity)) {
        $FreeWebsEnableModSecurity = 0;
    }
    if (!is_numeric($FreeWebsEnableModEvasive)) {
        $FreeWebsEnableModEvasive = 0;
    }
    if (!is_numeric($FreeWebsEnableModQOS)) {
        $FreeWebsEnableModQOS = 0;
    }
    if (!is_numeric($FreeWebsEnableOpenVPNProxy)) {
        $FreeWebsEnableOpenVPNProxy = 0;
    }
    if (!is_numeric($TomcatEnable)) {
        $TomcatEnable = 1;
    }
    if (!is_numeric($FreeWebEnableSQLLog)) {
        $FreeWebEnableSQLLog = 0;
    }
    if (!is_numeric($FreeWebEnableModSUPhp)) {
        $FreeWebEnableModSUPhp = 0;
    }
    if ($unix->isNGnx()) {
        $FreeWebListenSSLPort = 447;
        $FreeWebListenPort = 82;
    }
    if ($unix->IsSquidReverse()) {
        $FreeWebListenSSLPort = 447;
        $FreeWebListenPort = 82;
    }
    $APACHE_MODULES_PATH = $unix->APACHE_MODULES_PATH();
    $toremove[] = "mod-status.init";
    $toremove[] = "status.conf";
    $toremove[] = "fcgid.load";
    $toremove[] = "fcgid.conf";
    $toremove[] = "fastcgi.conf";
    $toremove[] = "fastcgi.load";
    $toremove[] = "fastcgi.conf";
    $toremove[] = "log_sql.load";
    $toremove[] = "log_sql_mysql.load";
    $toremove[] = "geoip.conf";
    $toremove[] = "bw.load";
    $toremove[] = "geoip_module.load";
    $toremove[] = "log_sql_module.conf";
    $toremove[] = "log_sql_module.load";
    $toremove[] = "log_sql_mysql_module.load";
    $toremove[] = "log_sql_ssl.load";
    $toremove[] = "unique_id.load";
    $toremove[] = "mime.conf";
    $toremove[] = "mime.load";
    $toremove[] = "php5.conf";
    $toremove[] = "php5.load";
    $toremove[] = "fcgid_module.load";
    $toremove[] = "php5-fpm.load";
    $toremove[] = "fastcgi.load";
    $toremove[] = "php5-fpm.conf";
    $toremove[] = "bw.load";
    $toremove[] = "status_module.load";
    $toremove[] = "autoindex.load";
    $toremove[] = "ldap.load";
    if (is_file("/etc/apache2/sites-enabled/000-default")) {
        $ToDeleteDefault = true;
        $q = new mysql();
        $ligne = @mysql_fetch_array($q->QUERY_SQL("SELECT servername,enabled FROM freeweb WHERE servername='_default_'", 'artica_backup'));
        if ($q->ok) {
            if ($ligne["servername"] == "_default_") {
                if ($ligne["enabled"] == 1) {
                    $ToDeleteDefault = false;
                }
            }
        } else {
            $ToDeleteDefault = false;
        }
        if ($ZarafaWebAccessInFrontEnd == 1) {
            $ToDeleteDefault = false;
        }
        if ($ToDeleteDefault) {
            @unlink("/etc/apache2/sites-enabled/000-default");
        }
    }
    if (is_file("/etc/apache2/conf.d/other-vhosts-access-log")) {
        @unlink("/etc/apache2/conf.d/other-vhosts-access-log");
    }
    @mkdir("/etc/apache2/htdocs", 0755, true);
    if (is_file("/etc/apache2/sites-enabled/default-www")) {
        @unlink("/etc/apache2/sites-enabled/default-www");
    }
    if (is_file("/etc/apache2/sites-available/default")) {
        @unlink("/etc/apache2/sites-available/default");
    }
    if (is_file("/etc/apache2/conf.d/zarafa-webaccess.conf")) {
        @unlink("/etc/apache2/conf.d/zarafa-webaccess.conf");
    }
    if (is_file("/etc/apache2/conf.d/zarafa-webaccess-mobile.conf")) {
        @unlink("/etc/apache2/conf.d/zarafa-webaccess-mobile.conf");
    }
    if (is_file("/etc/httpd/conf/extra/httpd-info.conf")) {
        @unlink("/etc/httpd/conf/extra/httpd-info.conf");
    }
    if (is_file("/etc/apache2/mods-enabled/ssl.conf")) {
        @unlink("/etc/apache2/mods-enabled/ssl.conf");
    }
    $FreeWebListen = $unix->APACHE_ListenDefaultAddress();
    while (list($num, $file) = each($toremove)) {
        if (is_file("{$DAEMON_PATH}/mods-enabled/{$file}")) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Apache remove mods-enabled/{$file}\n";
            shell_exec("/bin/rm -f {$DAEMON_PATH}/mods-enabled/{$file} >/dev/null 2>&1");
        }
        if (is_file("{$DAEMON_PATH}/mods-enabled/{$file}")) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Apache remove mods-available/{$file}\n";
            shell_exec("/bin/rm -f {$DAEMON_PATH}/mods-available/{$file} >/dev/null 2>&1");
        }
    }
    php5_conf($DAEMON_PATH);
    if ($FreeWebDisableSSL == 1) {
        $FreeWebListenSSLPort = 0;
    }
    $VirtualHostsIPAddresses = VirtualHostsIPAddresses($FreeWebListenPort, $FreeWebListen, $FreeWebListenSSLPort);
    if (count($VirtualHostsIPAddresses[0]) > 0) {
        $conf[] = @implode("\n", $VirtualHostsIPAddresses[0]);
    }
    if (count($VirtualHostsIPAddresses[1]) > 0) {
        $conf[] = @implode("\n", $VirtualHostsIPAddresses[1]);
    }
    if ($FreeWebDisableSSL == 0) {
        $conf[] = "<IfModule mod_ssl.c>";
        //$conf[]="\tListen $FreeWebListenSSLPort";
        $conf[] = "\tNameVirtualHost {$FreeWebListen}:{$FreeWebListenSSLPort}";
        if ($VirtualHostsIPAddresses[2] > 0) {
            $conf[] = @implode("\n", $VirtualHostsIPAddresses[2]);
        }
        $conf[] = "\tSSLPassPhraseDialog exec:/etc/apache2/ssl-tools/sslpass.sh";
        shell_exec("{$php5} /usr/share/artica-postfix/exec.openssl.php --pass");
        $conf[] = "</IfModule>";
        $conf[] = "";
        $conf[] = "<IfModule mod_gnutls.c>";
        $conf[] = "\tNameVirtualHost {$FreeWebListen}:{$FreeWebListenSSLPort}";
        if ($VirtualHostsIPAddresses[2] > 0) {
            $conf[] = @implode("\n", $VirtualHostsIPAddresses[2]);
        }
        //$conf[]="\tListen $FreeWebListenSSLPort";
        $conf[] = "</IfModule>";
    }
    $conf[] = "<IfModule mod_fcgid.c>";
    $conf[] = "\tPHP_Fix_Pathinfo_Enable 1";
    $conf[] = "</IfModule>";
    $conf[] = "<IfModule mod_fastcgi.c>";
    $conf[] = "\tAddHandler fastcgi-script .fcgi";
    $conf[] = "#FastCgiWrapper /usr/lib/apache2/suexec";
    $conf[] = "\tFastCgiIpcDir /var/lib/apache2/fastcgi";
    $conf[] = "</IfModule>";
    if (is_file("/usr/lib/apache2/modules/mod_cband.so")) {
        $conf[] = "<IfModule mod_cband.c>";
        $conf[] = "\tCBandScoreFlushPeriod 1";
        $conf[] = "\tCBandRandomPulse On";
        $conf[] = "</IfModule>";
    }
    $conf[] = "";
    if (!is_dir("{$DAEMON_PATH}/sites-available")) {
        @mkdir("{$DAEMON_PATH}/sites-available", 666, true);
    }
    if (!is_dir("{$DAEMON_PATH}/BackupConf")) {
        @mkdir("{$DAEMON_PATH}/BackupConf", 666, true);
    }
    if (is_file("{$DAEMON_PATH}/ports.conf")) {
        @unlink("{$DAEMON_PATH}/BackupConf/ports.conf");
        @copy("{$DAEMON_PATH}/ports.conf", "{$DAEMON_PATH}/BackupConf/ports.conf");
        $GLOBALS["ToRestore"][] = "{$DAEMON_PATH}/BackupConf/ports.conf";
    }
    @file_put_contents("{$DAEMON_PATH}/ports.conf", @implode("\n", $conf));
    echo "Starting......: " . date("H:i:s") . " [INIT]: Apache {$DAEMON_PATH}/ports.conf for NameVirtualHost {$FreeWebListen}:{$FreeWebListenPort} done\n";
    mod_security();
    if ($FreeWebsEnableModEvasive == 1) {
        $Params = unserialize(base64_decode($sock->GET_INFO("modEvasiveDefault")));
        if (!is_numeric($Params["DOSHashTableSize"])) {
            $Params["DOSHashTableSize"] = 1024;
        }
        if (!is_numeric($Params["DOSPageCount"])) {
            $Params["DOSPageCount"] = 10;
        }
        if (!is_numeric($Params["DOSSiteCount"])) {
            $Params["DOSSiteCount"] = 150;
        }
        if (!is_numeric($Params["DOSPageInterval"])) {
            $Params["DOSPageInterval"] = 1.5;
        }
        if (!is_numeric($Params["DOSSiteInterval"])) {
            $Params["DOSSiteInterval"] = 1.5;
        }
        if (!is_numeric($Params["DOSBlockingPeriod"])) {
            $Params["DOSBlockingPeriod"] = 10.7;
        }
        $f[] = "   LoadModule evasive20_module modules/mod_evasive20.so";
        $f[] = "   ExtendedStatus On";
        $f[] = "   DOSHashTableSize {$Params["DOSHashTableSize"]}";
        $f[] = "   DOSPageCount {$Params["DOSPageCount"]}";
        $f[] = "   DOSSiteCount {$Params["DOSSiteCount"]}";
        $f[] = "   DOSPageInterval {$Params["DOSPageInterval"]}";
        $f[] = "   DOSSiteInterval {$Params["DOSSiteInterval"]}";
        $f[] = "   DOSBlockingPeriod {$Params["DOSBlockingPeriod"]}";
        $f[] = "   DOSLogDir  \"/var/log/apache2/mod_evasive.log\"";
        $f[] = "   DOSSystemCommand \"/bin/echo `date '+%F %T'` apache2  %s >> /var/log/apache2/dos_evasive_attacks.log\"";
        $f[] = "";
        echo "Starting......: " . date("H:i:s") . " [INIT]: Apache {$DAEMON_PATH}/mod_evasive.conf\n";
        if (is_file("{$DAEMON_PATH}/mod_evasive.conf")) {
            @unlink("{$DAEMON_PATH}/BackupConf/mod_evasive.conf");
            @copy("{$DAEMON_PATH}/ports.conf", "{$DAEMON_PATH}/BackupConf/mod_evasive.conf");
            $GLOBALS["ToRestore"][] = "{$DAEMON_PATH}/BackupConf/mod_evasive.conf";
        }
        @file_put_contents("{$DAEMON_PATH}/mod_evasive.conf", @implode("\n", $f));
        unset($f);
    }
    @mkdir("/var/run/apache2", 0775, true);
    if (is_file("{$DAEMON_PATH}/ssl.conf")) {
        @unlink("{$DAEMON_PATH}/BackupConf/ssl.conf");
        @copy("{$DAEMON_PATH}/ports.conf", "{$DAEMON_PATH}/BackupConf/ssl.conf");
        $GLOBALS["ToRestore"][] = "{$DAEMON_PATH}/BackupConf/ssl.conf";
    }
    @unlink("{$DAEMON_PATH}/ssl.conf");
    if ($FreeWebDisableSSL == 0) {
        $f[] = "<IfModule mod_ssl.c>";
        $f[] = "\tSSLRandomSeed connect builtin";
        $f[] = "\tSSLRandomSeed connect file:/dev/urandom 512";
        $f[] = "\tAddType application/x-x509-ca-cert .crt";
        $f[] = "\tAddType application/x-pkcs7-crl    .crl";
        $f[] = "\tSSLPassPhraseDialog  builtin";
        $f[] = "\tSSLSessionCache        shmcb:/var/run/apache2/ssl_scache(512000)";
        $f[] = "\tSSLSessionCacheTimeout  300";
        $f[] = "\tSSLSessionCacheTimeout  300";
        $f[] = "\tSSLMutex  sem";
        //$f[]="	SSLMutex  file:/var/run/apache2/ssl_mutex";
        $f[] = "\tSSLCipherSuite HIGH:MEDIUM:!ADH";
        $f[] = "\tSSLProtocol all -SSLv2";
        $f[] = "</IfModule>";
        $f[] = "";
        @file_put_contents("{$DAEMON_PATH}/ssl.conf", @implode("\n", $f));
        unset($f);
    }
    apache_security($DAEMON_PATH);
    $httpdconf_data = @file_get_contents($httpdconf);
    $httpdconf_basename = basename($httpdconf);
    if (is_file($httpdconf)) {
        @unlink("{$DAEMON_PATH}/BackupConf/{$httpdconf_basename}");
        @copy("{$DAEMON_PATH}/{$httpdconf_basename}", "{$DAEMON_PATH}/BackupConf/{$httpdconf_basename}");
        $GLOBALS["ToRestore"][] = "{$DAEMON_PATH}/BackupConf/{$httpdconf_basename}";
    }
    if (preg_match("#<Location \\/server-status>(.+?)<\\/Location>#is", $httpdconf_data, $re)) {
        $httpdconf_data = str_replace($re[0], "", $httpdconf_data);
    }
    $f = explode("\n", $httpdconf_data);
    while (list($num, $ligne) = each($f)) {
        if (preg_match("#^Include\\s+#", $ligne)) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Apache removing {$f[$num]}\n";
            $f[$num] = null;
        }
        if (preg_match("#\\#.*?Include\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#Listen\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#ProxyRequests#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#ProxyVia#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#AllowCONNECT#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#KeepAlive#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#Timeout\\s+[0-9]+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#MaxKeepAliveRequests\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#KeepAliveTimeout\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#MinSpareServers\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#MaxSpareServers\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#StartServers\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#MaxClients\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#MaxRequestsPerChild\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#ExtendedStatus\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#LoadModule\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#ErrorLog\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#LogFormat\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#User\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#Group\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#CustomLog\\s+#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#LogLevel#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#ServerName#", $ligne)) {
            $f[$num] = null;
        }
        if (preg_match("#DavLockDB#", $ligne)) {
            $f[$num] = null;
        }
        if (trim($ligne) == "Loglevel info") {
            $f[$num] = null;
        }
    }
    $FreeWebPerformances = unserialize(base64_decode($sock->GET_INFO("FreeWebPerformances")));
    if (!isset($FreeWebPerformances["Timeout"])) {
        $FreeWebPerformances["Timeout"] = 300;
    }
    if (!isset($FreeWebPerformances["KeepAlive"])) {
        $FreeWebPerformances["KeepAlive"] = 0;
    }
    if (!isset($FreeWebPerformances["MaxKeepAliveRequests"])) {
        $FreeWebPerformances["MaxKeepAliveRequests"] = 100;
    }
    if (!isset($FreeWebPerformances["KeepAliveTimeout"])) {
        $FreeWebPerformances["KeepAliveTimeout"] = 15;
    }
    if (!isset($FreeWebPerformances["MinSpareServers"])) {
        $FreeWebPerformances["MinSpareServers"] = 1;
    }
    if (!isset($FreeWebPerformances["MaxSpareServers"])) {
        $FreeWebPerformances["MaxSpareServers"] = 2;
    }
    if (!isset($FreeWebPerformances["StartServers"])) {
        $FreeWebPerformances["StartServers"] = 1;
    }
    if (!isset($FreeWebPerformances["MaxClients"])) {
        $FreeWebPerformances["MaxClients"] = 50;
    }
    if (!isset($FreeWebPerformances["MaxRequestsPerChild"])) {
        $FreeWebPerformances["MaxRequestsPerChild"] = 10000;
    }
    if (!is_numeric($FreeWebPerformances["Timeout"])) {
        $FreeWebPerformances["Timeout"] = 300;
    }
    if (!is_numeric($FreeWebPerformances["KeepAlive"])) {
        $FreeWebPerformances["KeepAlive"] = 0;
    }
    if (!is_numeric($FreeWebPerformances["MaxKeepAliveRequests"])) {
        $FreeWebPerformances["MaxKeepAliveRequests"] = 100;
    }
    if (!is_numeric($FreeWebPerformances["KeepAliveTimeout"])) {
        $FreeWebPerformances["KeepAliveTimeout"] = 15;
    }
    if (!is_numeric($FreeWebPerformances["MinSpareServers"])) {
        $FreeWebPerformances["MinSpareServers"] = 1;
    }
    if (!is_numeric($FreeWebPerformances["MaxSpareServers"])) {
        $FreeWebPerformances["MaxSpareServers"] = 2;
    }
    if (!is_numeric($FreeWebPerformances["StartServers"])) {
        $FreeWebPerformances["StartServers"] = 1;
    }
    if (!is_numeric($FreeWebPerformances["MaxClients"])) {
        $FreeWebPerformances["MaxClients"] = 50;
    }
    if (!is_numeric($FreeWebPerformances["MaxRequestsPerChild"])) {
        $FreeWebPerformances["MaxRequestsPerChild"] = 10000;
    }
    reset($f);
    while (list($num, $ligne) = each($f)) {
        if (trim($ligne) == null) {
            continue;
        }
        if (substr($ligne, 0, 1) == "#") {
            continue;
        }
        $httpd[] = $ligne;
    }
    $php5 = $unix->LOCATE_PHP5_BIN();
    shell_exec("{$php5} /usr/share/artica-postfix/exec.samba.php --fix-etc-hosts >/dev/null 2>&1");
    if ($APACHE_SRC_GROUP == '${APACHE_RUN_GROUP}') {
        $APACHE_SRC_GROUP = $APACHE_SRC_ACCOUNT;
    }
    if ($FreeWebPerformances["KeepAlive"] == 1) {
        $FreeWebPerformances["KeepAlive"] = "On";
    } else {
        $FreeWebPerformances["KeepAlive"] = "Off";
    }
    $httpd[] = "User\t\t\t\t   {$APACHE_SRC_ACCOUNT}";
    $httpd[] = "Group\t\t\t\t   {$APACHE_SRC_GROUP}";
    $httpd[] = "Timeout              {$FreeWebPerformances["Timeout"]}";
    $httpd[] = "KeepAlive            {$FreeWebPerformances["KeepAlive"]}";
    $httpd[] = "KeepAliveTimeout     {$FreeWebPerformances["KeepAliveTimeout"]}";
    $httpd[] = "StartServers         {$FreeWebPerformances["StartServers"]}";
    $httpd[] = "MaxClients           {$FreeWebPerformances["MaxClients"]}";
    $httpd[] = "MinSpareServers      {$FreeWebPerformances["MinSpareServers"]}";
    $httpd[] = "MaxSpareServers      {$FreeWebPerformances["MaxSpareServers"]}";
    $httpd[] = "MaxRequestsPerChild  {$FreeWebPerformances["MaxRequestsPerChild"]}";
    $httpd[] = "MaxKeepAliveRequests {$FreeWebPerformances["MaxKeepAliveRequests"]}";
    $httpd[] = "ServerName {$hostname}";
    if ($FreeWebsEnableOpenVPNProxy == 1) {
        if ($FreeWebsOpenVPNRemotPort != null) {
            $httpd[] = "ProxyRequests On";
            $httpd[] = "ProxyVia On";
            $httpd[] = "AllowCONNECT {$FreeWebsOpenVPNRemotPort}";
            $httpd[] = "KeepAlive On";
        }
    }
    @unlink("{$DAEMON_PATH}/mods-enabled/klms.FastCgiExternalServer.conf");
    if ($users->KLMS_WEB_INSTALLED) {
        $sql = "SELECT COUNT(*) as tcount FROM freeweb WHERE groupware='KLMS'";
        $q = new mysql();
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
        $CountDeGroupware = $ligne["tcount"];
        echo "Starting......: " . date("H:i:s") . " {$CountDeGroupware} KLMS Groupware(s)\n";
        if ($CountDeGroupware > 0) {
            if (is_file("/opt/kaspersky/klmsui/share/htdocs/cgi-bin/klwi")) {
                @file_put_contents("{$DAEMON_PATH}/mods-enabled/klms.FastCgiExternalServer.conf", "FastCgiExternalServer /opt/kaspersky/klmsui/share/htdocs/cgi-bin/klwi -host 127.0.0.1:2711\n");
            }
        }
    }
    //$dir_master=$unix->getmodpathfromconf();
    if (is_file('/usr/lib/apache2/modules/mod_kav64.so')) {
        $sock = new sockets();
        $ApacheEnableKavModule = intval($sock->GET_INFO("ApacheEnableKavModule"));
        if ($ApacheEnableKavModule == 1) {
            $httpd[] = "LoadModule kav_module /usr/lib/apache2/modules/mod_kav64.so";
        }
    }
    if (!is_file("{$DAEMON_PATH}/videocache.conf")) {
        @touch("{$DAEMON_PATH}/videocache.conf");
    }
    $httpd[] = "Include {$DAEMON_PATH}/videocache.conf";
    if (is_file("{$DAEMON_PATH}/security.conf")) {
        $httpd[] = "Include {$DAEMON_PATH}/security.conf";
    }
    $httpd[] = "Include {$DAEMON_PATH}/mods-enabled/*.load";
    $httpd[] = "Include {$DAEMON_PATH}/mods-enabled/*.conf";
    $httpd[] = "Include {$DAEMON_PATH}/mods-enabled/*.init";
    $mod_php5[] = "<IfModule mod_php5.c>";
    $mod_php5[] = "    <FilesMatch \"\\.ph(p3?|tml)\$\">";
    $mod_php5[] = "\tSetHandler application/x-httpd-php";
    $mod_php5[] = "    </FilesMatch>";
    $mod_php5[] = "    <FilesMatch \"\\.phps\$\">";
    $mod_php5[] = "\tSetHandler application/x-httpd-php-source";
    $mod_php5[] = "    </FilesMatch>";
    $mod_php5[] = "    # To re-enable php in user directories comment the following lines";
    $mod_php5[] = "    # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it";
    $mod_php5[] = "    # prevents .htaccess files from disabling it.";
    $mod_php5[] = "    <IfModule mod_userdir.c>";
    $mod_php5[] = "        <Directory /home/*/public_html>";
    $mod_php5[] = "            php_admin_value engine Off";
    $mod_php5[] = "        </Directory>";
    $mod_php5[] = "    </IfModule>";
    $mod_php5[] = "</IfModule>";
    echo "Starting......: " . date("H:i:s") . " [INIT]: Apache saving: {$DAEMON_PATH}/mods-enabled/mod_php5.conf\n";
    @file_put_contents("{$DAEMON_PATH}/mods-enabled/mod_php5.conf", @implode("\n", $mod_php5));
    $httpd[] = "Include {$DAEMON_PATH}/mods-enabled/mod_php5.conf";
    $mod_php5 = array();
    if (basename($httpdconf) != "httpd.conf") {
        $httpd[] = "Include {$DAEMON_PATH}/httpd.conf";
    }
    $httpd[] = "Include {$DAEMON_PATH}/ports.conf";
    if ($FreeWebsEnableModSecurity == 1) {
        $httpd[] = "Include {$DAEMON_PATH}/mod_security.conf";
    }
    if ($FreeWebsEnableModEvasive == 1) {
        $httpd[] = "Include {$DAEMON_PATH}/mod_evasive.conf";
    }
    echo "Starting......: " . date("H:i:s") . " [INIT]: Apache checks WebDav (ApacheDisableModDavFS = {$ApacheDisableModDavFS})\n";
    $freeweb_tmp = new freeweb();
    $WebDavContainers = $freeweb_tmp->WebDavContainers();
    echo "Starting......: " . date("H:i:s") . " [INIT]: Apache checks WebDav " . strlen($WebDavContainers) . " bytes\n";
    @file_put_contents("{$DAEMON_PATH}/webdavcontainers.conf", $WebDavContainers);
    if ($ApacheDisableModDavFS == 0) {
        $httpd[] = "DavLockDB \"/var/www/.DavLockDB\"";
        @mkdir("/var/www", 0755, true);
        @chown("/var/www", $APACHE_SRC_ACCOUNT);
        @chgrp("/var/www", $APACHE_SRC_GROUP);
    }
    @mkdir("/var/lib/apache2/fastcgi", 0755, true);
    @chown("/var/lib/apache2/fastcgi", $APACHE_SRC_ACCOUNT);
    @chgrp("/var/lib/apache2/fastcgi", $APACHE_SRC_GROUP);
    $httpd[] = 'Loglevel info';
    $httpd[] = 'ErrorLog /var/log/apache2/error.log';
    $httpd[] = 'LogFormat "%h %l %u %t \\"%r\\" %<s %b" common';
    $httpd[] = 'CustomLog /var/log/apache2/access.log common';
    $mod_status = $freeweb->mod_status();
    if ($mod_status != null) {
        $status[] = "<IfModule mod_status.c>";
        $status[] = "\tExtendedStatus On";
        $status[] = "{$mod_status}";
        $status[] = "</IfModule>";
        @file_put_contents("{$DAEMON_PATH}/mods-enabled/mod-status.init", @implode("\n", $status));
    }
    @unlink("{$DAEMON_PATH}/mods-enabled/pagespeed.conf");
    if ($users->APACHE_MOD_PAGESPEED) {
        if (!is_dir("/var/cache/apache2/mod_pagespeed/default/files")) {
            @mkdir("/var/cache/apache2/mod_pagespeed/default/files", 644, true);
        }
        $pspedd[] = "<IfModule pagespeed_module>";
        $pspedd[] = "\tModPagespeedFileCachePath            \"/var/cache/apache2/mod_pagespeed/default\"";
        $pspedd[] = "\tModPagespeedGeneratedFilePrefix      \"/var/cache/apache2/mod_pagespeed/files/\"";
        $pspedd[] = "\tSetOutputFilter MOD_PAGESPEED_OUTPUT_FILTER";
        $pspedd[] = "\tAddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html";
        $pspedd[] = "</IfModule>";
        @file_put_contents("{$DAEMON_PATH}/mods-enabled/pagespeed.conf", @implode("\n", $pspedd));
    }
    if ($users->APACHE_MOD_LOGSSQL) {
        if ($FreeWebEnableSQLLog == 1) {
            $q = new mysql();
            if (!$q->DATABASE_EXISTS("apachelogs")) {
                $q->CREATE_DATABASE("apachelogs");
            }
            $APACHE_MOD_LOGSSQL[] = "<IfModule log_sql_mysql_module>";
            $APACHE_MOD_LOGSSQL[] = "\tLogSQLLoginInfo mysql://{$q->mysql_admin}:{$q->mysql_password}@{$q->mysql_server}:{$q->mysql_port}/apachelogs";
            $APACHE_MOD_LOGSSQL[] = "\tLogSQLMassVirtualHosting On";
            $APACHE_MOD_LOGSSQL[] = "\tLogSQLmachineID {$users->hostname}";
            $APACHE_MOD_LOGSSQL[] = "\tLogSQLTransferLogFormat AbcHhmMpRSstTUuvz";
            $APACHE_MOD_LOGSSQL[] = "</IfModule>";
            @file_put_contents("{$DAEMON_PATH}/mods-enabled/log_sql_module.conf", @implode("\n", $APACHE_MOD_LOGSSQL));
        }
    }
    CheckHttpdConf_mime_module();
    CheckHttpdConf_mailman();
    if (is_file("/etc/apache2/mailman.conf")) {
        $httpd[] = "Include /etc/apache2/mailman.conf";
    }
    if (is_file("/etc/apache2/sysconfig.d/loadmodule.conf")) {
        $httpd[] = "Include /etc/apache2/sysconfig.d/loadmodule.conf";
    }
    if (is_file("/etc/apache2/uid.conf")) {
        $httpd[] = "Include /etc/apache2/uid.conf";
    }
    if (is_file("/etc/apache2/default-server.conf")) {
        patch_suse_default_server();
        $httpd[] = "Include /etc/apache2/default-server.conf";
    }
    $httpd[] = "Include {$DAEMON_PATH}/mime.conf";
    $httpd[] = "Include {$DAEMON_PATH}/conf.d/";
    $httpd[] = "Include {$DAEMON_PATH}/sites-enabled/";
    $httpd[] = "Include {$DAEMON_PATH}/webdavcontainers.conf";
    //PHP5 MODULE
    //if(is_file("$APACHE_MODULES_PATH/mod_php5.so")){$httpd[]="LoadModule php5_module $APACHE_MODULES_PATH/mod_php5.so";}
    //if(is_file("$APACHE_MODULES_PATH/mod_ldap.so")){$httpd[]="LoadModule ldap_module $APACHE_MODULES_PATH/mod_ldap.so";}
    if ($ApacheDisableModDavFS == 0) {
        if (is_file("{$APACHE_MODULES_PATH}/mod_dav.so")) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Apache module 'dav_module' enabled\n";
            $httpd[] = "LoadModule dav_module {$APACHE_MODULES_PATH}/mod_dav.so";
        }
        if (is_file("{$APACHE_MODULES_PATH}/mod_dav_lock.so")) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Apache module 'dav_lock_module' enabled\n";
            $httpd[] = "LoadModule dav_lock_module {$APACHE_MODULES_PATH}/mod_dav_lock.so";
        }
        if (is_file("{$APACHE_MODULES_PATH}/mod_dav_fs.so")) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Apache module 'dav_fs_module' enabled\n";
            $httpd[] = "LoadModule dav_fs_module {$APACHE_MODULES_PATH}/mod_dav_fs.so";
        }
    }
    $httpd[] = "";
    $httpd[] = YfiAdds();
    echo "Starting......: " . date("H:i:s") . " [INIT]: Apache {$httpdconf} done\n";
    @file_put_contents($httpdconf, @implode("\n", $httpd));
    // MODULES -----------------------------------------------------------------------
    if (!is_dir("{$DAEMON_PATH}/mods-enabled")) {
        @mkdir("{$DAEMON_PATH}/mods-enabled", 666, true);
    }
    if (!is_file("{$DAEMON_PATH}/httpd.conf")) {
        @file_put_contents("{$DAEMON_PATH}/httpd.conf", "#");
    }
    @unlink("/etc/libapache2-mod-jk/workers.properties");
    @unlink("/etc/apache2/workers.properties");
    @unlink("{$DAEMON_PATH}/conf.d/jk.conf");
    $free = new freeweb();
    $array["php5_module"] = "libphp5.so";
    if ($users->APACHE_MOD_SUPHP) {
        if ($FreeWebEnableModSUPhp == 1) {
            $array["suphp_module"] = "mod_suphp.so";
        }
    }
    //$array["access_module"]="mod_access.so";
    $array["qos_module"] = "mod_qos.so";
    $array["rewrite_module"] = "mod_rewrite.so";
    $array["cache_module"] = "mod_cache.so";
    $array["disk_cache_module"] = "mod_disk_cache.so";
    $array["mem_cache_module"] = "mod_mem_cache.so";
    $array["expires_module"] = "mod_expires.so";
    $ApacheDisableModStatus = intval($sock->GET_INFO("ApacheDisableModStatus"));
    echo "Starting......: " . date("H:i:s") . " [INIT]: Apache module ApacheDisableModStatus={$ApacheDisableModStatus}\n";
    if ($ApacheDisableModStatus == 0) {
        $array["status_module"] = "mod_status.so";
    }
    if (is_file($free->locate_geoip_db())) {
        $array["geoip_module"] = "mod_geoip.so";
    }
    $array["info_module"] = "mod_info.so";
    $array["suexec_module"] = "mod_suexec.so";
    $array["fcgid_module"] = "mod_fcgid.so";
    $array["authz_host_module"] = "mod_authz_host.so";
    $array["dir_module"] = "mod_dir.so";
    $array["mime_module"] = "mod_mime.so";
    $array["log_config_module"] = "mod_log_config.so";
    $array["alias_module"] = "mod_alias.so";
    $array["autoindex_module"] = "mod_autoindex.so";
    $array["negotiation_module"] = "mod_negotiation.so";
    $array["setenvif_module"] = "mod_setenvif.so";
    $array["logio_module"] = "mod_logio.so";
    $array["auth_basic_module"] = "mod_auth_basic.so";
    $array["authn_file_module"] = "mod_authn_file.so";
    $array["vhost_alias_module"] = "mod_vhost_alias.so";
    $array["python_module"] = "mod_python.so";
    $array["auth_digest_module"] = "mod_auth_digest.so";
    $array["mime_module"] = "mod_mime.so";
    $array["ssl_module"] = "mod_ssl.so";
    if ($FreeWebEnableSQLLog == 1) {
        $array["log_sql_module"] = "mod_log_sql.so";
        $array["log_sql_mysql_module"] = "mod_log_sql_mysql.so";
    }
    if (mod_bw_module_must_be_enabled()) {
        $array["bw_module"] = "mod_bw.so";
    }
    $array["actions_module"] = "mod_actions.so";
    $array["expires_module"] = "mod_expires.so";
    $array["include_module"] = "mod_include.so";
    $array["rpaf_module"] = "mod_rpaf-2.0.so";
    $array["fastcgi_module"] = "mod_fastcgi.so";
    $array["deflate_module"] = "mod_deflate.so";
    $array["headers_module"] = "mod_headers.so";
    $array["cband_module"] = "mod_cband.so";
    if (is_file("{$APACHE_MODULES_PATH}/mod_rpaf-2.0.so")) {
        $net = new networking();
        $ips = $net->ALL_IPS_GET_ARRAY();
        while (list($ip, $line) = each($ips)) {
            $tip[] = $ip;
        }
        $rpfmod[] = "<IfModule mod_rpaf.c>";
        $rpfmod[] = "\tRPAFenable On";
        $rpfmod[] = "\tRPAFsethostname On";
        $rpfmod[] = "\tRPAFproxy_ips " . @implode(" ", $tip);
        $rpfmod[] = "\tRPAFheader X-Forwarded-For";
        $rpfmod[] = "</IfModule>";
        $rpfmod[] = "<IfModule rpaf_module>";
        $rpfmod[] = "\tRPAFenable On";
        $rpfmod[] = "\tRPAFsethostname On";
        $rpfmod[] = "\tRPAFproxy_ips " . @implode(" ", $tip);
        $rpfmod[] = "\tRPAFheader X-Forwarded-For";
        $rpfmod[] = "</IfModule>";
        @file_put_contents("{$DAEMON_PATH}/mods-enabled/rpaf.conf", @implode("\n", $rpfmod));
    }
    if (is_file("{$APACHE_MODULES_PATH}/mod_pagespeed.so")) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: Apache module 'mod_pagespeed' enabled\n";
        $ppsped[] = "LoadModule pagespeed_module {$APACHE_MODULES_PATH}/mod_pagespeed.so";
        if (is_file("{$APACHE_MODULES_PATH}/mod_deflate.so")) {
            $ppsped[] = "# Only attempt to load mod_deflate if it hasn't been loaded already.";
            $ppsped[] = "<IfModule !mod_deflate.c>";
            $ppsped[] = "\tLoadModule deflate_module {$APACHE_MODULES_PATH}/mod_deflate.so";
            $ppsped[] = "</IfModule>";
        }
        @file_put_contents("{$DAEMON_PATH}/mods-enabled/mod_pagespeed.load", @implode("\n", $ppsped));
    } else {
        echo "Starting......: " . date("H:i:s") . " [INIT]: Apache module 'mod_pagespeed' {$APACHE_MODULES_PATH}/mod_pagespeed.so no such file\n";
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "Starting......: " . date("H:i:s") . " [DEBUG] Apache TOMCAT_INSTALLED -> {$users->TOMCAT_INSTALLED}\n";
    }
    if ($users->TOMCAT_INSTALLED) {
        if ($TomcatEnable == 1) {
            if (is_dir($users->TOMCAT_DIR)) {
                if (is_dir($users->TOMCAT_JAVA)) {
                    $array["jk_module"] = "mod_jk.so";
                    $ftom[] = "workers.tomcat_home={$users->TOMCAT_DIR}";
                    $ftom[] = "workers.java_home={$users->TOMCAT_JAVA}";
                    $ftom[] = "ps=/";
                    $ftom[] = "worker.list=ajp13_worker";
                    $ftom[] = "worker.ajp13_worker.port=8009";
                    $ftom[] = "worker.ajp13_worker.host=127.0.0.1";
                    $ftom[] = "worker.ajp13_worker.type=ajp13";
                    $ftom[] = "worker.ajp13_worker.lbfactor=1";
                    $ftom[] = "worker.loadbalancer.type=lb";
                    $ftom[] = "worker.loadbalancer.balance_workers=ajp13_worker";
                    $ftom[] = "";
                    @file_put_contents("/etc/apache2/workers.properties", @implode("\n", $ftom));
                    @mkdir("/etc/libapache2-mod-jk", 644);
                    @file_put_contents("/etc/libapache2-mod-jk/workers.properties", @implode("\n", $ftom));
                    $faptom[] = "<ifmodule mod_jk.c>";
                    $faptom[] = "\tJkWorkersFile /etc/apache2/workers.properties";
                    $faptom[] = "\tJkLogFile /var/log/apache2/mod_jk.log";
                    $faptom[] = "\tJkLogLevel error";
                    $faptom[] = "</ifmodule>";
                    @file_put_contents("{$DAEMON_PATH}/conf.d/jk.conf", @implode("\n", $faptom));
                }
            }
        }
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "Starting......: " . date("H:i:s") . " [DEBUG] Apache cleaning mods...\n";
    }
    @unlink("{$DAEMON_PATH}/mods-enabled/mod-security.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/mod_security.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/mod-evasive.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/mod_evasive.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/geoip.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/status.conf");
    @unlink("{$DAEMON_PATH}/mods-enabled/status.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/php5.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/jk.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/dav_lock_module.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/dav_module.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/dav_fs_module.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/pagespeed.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/rpaf.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/alias.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/auth_basic.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/dir.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/deflate.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/negotiation.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/authn_file.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/authz_host.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/setenvif.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/ssl.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/ldap.load");
    @unlink("{$DAEMON_PATH}/mods-enabled/authnz_ldap.load");
    $sock = new sockets();
    $FreeWebsDisableMOdQOS = $sock->GET_INFO("FreeWebsDisableMOdQOS");
    if ($GLOBALS["VERBOSE"]) {
        echo "Starting......: " . date("H:i:s") . " [DEBUG] Apache FreeWebsDisableMOdQOS = {$FreeWebsDisableMOdQOS} ...\n";
    }
    if (!is_numeric($FreeWebsDisableMOdQOS)) {
        $FreeWebsDisableMOdQOS = 0;
    }
    if ($FreeWebsEnableModQOS == 0) {
        $FreeWebsDisableMOdQOS = 1;
    }
    if ($FreeWebsDisableMOdQOS == 1) {
        unset($array["qos_module"]);
        @unlink("{$DAEMON_PATH}/mods-enabled/qos_module.load");
    }
    if ($FreeWebsEnableModEvasive == 1) {
        if (is_file("{$APACHE_MODULES_PATH}/mod_evasive20.so")) {
            $a[] = "LoadModule evasive20_module {$APACHE_MODULES_PATH}/mod_evasive20.so";
            echo "Starting......: " . date("H:i:s") . " [INIT]: Apache module 'mod_evasive2' enabled\n";
            @file_put_contents("{$DAEMON_PATH}/mods-enabled/mod_evasive.load", @implode("\n", $a));
        } else {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Apache {$APACHE_MODULES_PATH}/mod_evasive20.so no such file\n";
        }
    } else {
        echo "Starting......: " . date("H:i:s") . " [INIT]: Apache module 'mod_evasive2' disabled\n";
    }
    $sql = "SELECT COUNT(servername) as tcount FROM freeweb WHERE UseReverseProxy=1";
    if ($GLOBALS["VERBOSE"]) {
        echo "Starting......: " . date("H:i:s") . " [DEBUG] Apache {$sql}\n";
    }
    $q = new mysql();
    $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, 'artica_backup'));
    echo "Starting......: " . date("H:i:s") . " [INIT]: Apache " . $ligne["tcount"] . " Reverse Proxy\n";
    $proxys_mods["proxy_module"] = "mod_proxy.so";
    $proxys_mods["proxy_http_module"] = "mod_proxy_http.so";
    $proxys_mods["proxy_ftp_module"] = "mod_proxy_ftp.so";
    $proxys_mods["proxy_connect_module"] = "mod_proxy_connect.so";
    $proxys_mods["headers_module"] = "mod_headers.so";
    $proxys_mods["deflate_module"] = "mod_deflate.so";
    $proxys_mods["xml2enc_module"] = "mod_xml2enc.so";
    $proxys_mods["proxy_html_module"] = "mod_proxy_html.so";
    $proxys_orgs[] = "proxy_ajp.load";
    $proxys_orgs[] = "proxy_balancer.load";
    $proxys_orgs[] = "proxy.conf";
    $proxys_orgs[] = "proxy_connect.load";
    $proxys_orgs[] = "proxy_ftp.load";
    $proxys_orgs[] = "proxy_html.conf";
    $proxys_orgs[] = "proxy_html.load";
    $proxys_orgs[] = "proxy_http.load";
    $proxys_orgs[] = "proxy.load";
    $proxys_orgs[] = "proxy_scgi.load";
    if (is_file("/etc/httpd/conf.d/proxy_ajp.conf")) {
        @unlink("/etc/httpd/conf.d/proxy_ajp.conf");
    }
    while (list($module, $lib) = each($proxys_orgs)) {
        if (is_file("{$DAEMON_PATH}/mods-enabled/{$lib}")) {
            @unlink("{$DAEMON_PATH}/mods-enabled/{$lib}");
        }
    }
    while (list($module, $lib) = each($proxys_mods)) {
        if (is_file("{$DAEMON_PATH}/mods-enabled/{$module}.load")) {
            @unlink("{$DAEMON_PATH}/mods-enabled/{$module}.load");
        }
    }
    echo "Starting......: " . date("H:i:s") . " [INIT]: Apache {$ligne["tcount"]} reverse proxy(s)\n";
    $countDeProxy = $ligne["tcount"];
    if ($FreeWebsEnableOpenVPNProxy == 1) {
        if ($FreeWebsOpenVPNRemotPort != null) {
            $countDeProxy = $countDeProxy + 1;
        }
    }
    if ($users->EJABBERD_INSTALLED) {
        if ($countDeProxy == 0) {
            $countDeProxy = 1;
        }
    }
    if ($countDeProxy > 0) {
        reset($proxys_mods);
        while (list($module, $lib) = each($proxys_mods)) {
            if (!is_file("{$APACHE_MODULES_PATH}/{$lib}")) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: Apache module '{$module}' '{$lib}' no such file\n";
                continue;
            }
            echo "Starting......: " . date("H:i:s") . " [INIT]: Apache module '{$module}' enabled\n";
            $final_proxys[] = "LoadModule {$module} {$APACHE_MODULES_PATH}/{$lib}";
        }
        @file_put_contents("{$DAEMON_PATH}/mods-enabled/proxy_module.load", @implode("\n", $final_proxys));
    }
    while (list($module, $lib) = each($array)) {
        if (!is_file("{$APACHE_MODULES_PATH}/{$lib}")) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Apache module '{$module}' '{$lib}' no such file\n";
            continue;
        }
        echo "Starting......: " . date("H:i:s") . " [INIT]: Apache module '{$module}' enabled\n";
        @file_put_contents("{$DAEMON_PATH}/mods-enabled/{$module}.load", "LoadModule {$module} {$APACHE_MODULES_PATH}/{$lib}");
    }
    ZarafaWebAccessInFrontEnd($DAEMON_PATH);
    echo "Starting......: " . date("H:i:s") . " [INIT]: Apache testing configuration file\n";
    if (!TestingApacheConfigurationFile()) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: Apache testing configuration file FAILED !! restore old config\n";
        while (list($index, $restorefile) = each($GLOBALS["ToRestore"])) {
            $basename = basename($restorefile);
            echo "Starting......: " . date("H:i:s") . " [INIT]: Apache Removing {$DAEMON_PATH}/{$basename}\n";
            @unlink("{$DAEMON_PATH}/{$basename}");
            echo "Starting......: " . date("H:i:s") . " [INIT]: Apache Restoring {$restorefile}\n";
            @copy($restorefile, "{$DAEMON_PATH}/{$basename}");
        }
    }
    echo "Starting......: " . date("H:i:s") . " [INIT]: Apache terminated... next process\n";
}
コード例 #14
0
ファイル: exec.greyhole.php プロジェクト: BillTheBest/1.6.x
function checkdb()
{
    $createtable = false;
    $q = new mysql();
    if (!$q->DATABASE_EXISTS("greyhole")) {
        $createtable = true;
        echo "Starting......: " . date("H:i:s") . " greyhole creating mysql database \"greyhole\"\n";
        $q->CREATE_DATABASE("greyhole");
        if (!$q->ok) {
            echo "Starting......: " . date("H:i:s") . " greyhole {$q->mysql_error}\n";
            return false;
        }
    }
    if (!$q->TABLE_EXISTS("settings", "greyhole")) {
        echo "Starting......: " . date("H:i:s") . " greyhole create table \"settings\"\n";
        $sql = "CREATE TABLE `settings` (\n\t\t`name` TINYTEXT NOT NULL,\n\t\t`value` TEXT NOT NULL,\n\t\tPRIMARY KEY ( `name`(255) )\n\t\t) ENGINE = MYISAM;";
        $q->QUERY_SQL($sql, "greyhole");
        $sql = "INSERT INTO `settings` (`name`, `value`) VALUES ('last_read_log_smbd_line', '0');";
        $q->QUERY_SQL($sql, "greyhole");
        $sql = "INSERT INTO `settings` (`name`, `value`) VALUES ('last_OOS_notification', '0');";
        $q->QUERY_SQL($sql, "greyhole");
    }
    if (!$q->TABLE_EXISTS("tasks", "greyhole")) {
        echo "Starting......: " . date("H:i:s") . " greyhole create table \"tasks\"\n";
        $sql = "CREATE TABLE `tasks` (\n\t\t`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t`action` VARCHAR( 10 ) NOT NULL,\n\t\t`share` TINYTEXT NOT NULL,\n\t\t`full_path` TINYTEXT NULL,\n\t\t`additional_info` TINYTEXT NULL,\n\t\t`complete` ENUM( 'yes',  'no', 'frozen', 'thawed', 'idle') NOT NULL,\n\t\t`event_date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n\t\t) ENGINE = MYISAM;";
        $q->QUERY_SQL($sql, "greyhole");
        $sql = "ALTER TABLE `tasks` ADD INDEX `find_next_task` ( `complete` , `share` (64) , `id` );";
        $q->QUERY_SQL($sql, "greyhole");
    }
    if (!$q->TABLE_EXISTS("tasks_completed", "greyhole")) {
        echo "Starting......: " . date("H:i:s") . " greyhole create table \"tasks_completed\"\n";
        $sql = "CREATE TABLE `tasks_completed` (\n\t\t`id` BIGINT UNSIGNED NOT NULL,\n\t\t`action` VARCHAR( 10 ) NOT NULL,\n\t\t`share` TINYTEXT NOT NULL,\n\t\t`full_path` TINYTEXT NULL,\n\t\t`additional_info` TINYTEXT NULL,\n\t\t`complete` ENUM( 'yes',  'no' ) NOT NULL,\n\t\t`event_date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n\t\t) ENGINE = MYISAM;";
        $q->QUERY_SQL($sql, "greyhole");
        if (!$q->ok) {
            echo "Starting......: " . date("H:i:s") . " greyhole {$q->mysql_error}\n";
        }
    }
    echo "Starting......: " . date("H:i:s") . " greyhole checking database and table done\n";
    return true;
}
コード例 #15
0
ファイル: exec.phpmyadmin.php プロジェクト: BillTheBest/1.6.x
function build_phpmyadmin()
{
    if (!is_dir("/usr/share/phpmyadmin/themes")) {
        echo "[INFO] phpmyadmin not detected\n";
    }
    $unix = new unix();
    $hostname = $unix->hostname_g();
    $blowfish_secret = md5($hostname);
    echo "[INFO] Starting building phpmyadmin\n";
    $f[] = "<?php";
    $f[] = "/* vim: set expandtab sw=4 ts=4 sts=4: */";
    $f[] = "/**";
    $f[] = " * phpMyAdmin sample configuration, you can use it as base for";
    $f[] = " * manual configuration. For easier setup you can use setup/";
    $f[] = " *";
    $f[] = " * All directives are explained in documentation in the doc/ folder";
    $f[] = " * or at <http://docs.phpmyadmin.net/>.";
    $f[] = " *";
    $f[] = " * @package PhpMyAdmin";
    $f[] = " */";
    $f[] = "";
    $f[] = "/*";
    $f[] = " * This is needed for cookie based authentication to encrypt password in";
    $f[] = " * cookie";
    $f[] = " */";
    $f[] = "\$cfg['blowfish_secret'] = '{$blowfish_secret}'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */";
    $f[] = "";
    $f[] = "/*";
    $f[] = " * Servers configuration";
    $f[] = " */";
    $f[] = "\$i = 0;";
    $f[] = "";
    $f[] = "/*";
    $f[] = " * First server";
    $f[] = " */";
    $f[] = "/* Authentication type */";
    $f[] = "/* Server parameters */";
    $f[] = "\$i++;";
    $f[] = "\$cfg['Servers'][\$i]['auth_type'] = 'cookie';";
    $f[] = "\$cfg['Servers'][\$i]['verbose'] = 'Local MySQL';";
    $f[] = "\$cfg['Servers'][\$i]['socket'] = '/var/run/mysqld/mysqld.sock';";
    $f[] = "\$cfg['Servers'][\$i]['host'] = 'localhost';";
    $f[] = "\$cfg['Servers'][\$i]['connect_type'] = 'socket';";
    $f[] = "\$cfg['Servers'][\$i]['compress'] = false;";
    $f[] = "\$cfg['Servers'][\$i]['AllowNoPassword'] = true;";
    $f[] = "\$cfg['Servers'][\$i]['nopassword'] = true;";
    $f[] = "\$cfg['Servers'][\$i]['AllowRoot'] = true;";
    $f[] = "\$cfg['Servers'][\$i]['AllowNoPasswordRoot'] = true;";
    if ($unix->is_socket("/var/run/mysqld/squid-db.sock")) {
        $f[] = "\$i++;";
        $f[] = "\$cfg['Servers'][\$i]['auth_type'] = 'cookie';";
        $f[] = "\$cfg['Servers'][\$i]['verbose'] = 'Proxy MySQL Statistics';";
        $f[] = "\$cfg['Servers'][\$i]['socket'] = '/var/run/mysqld/squid-db.sock';";
        $f[] = "\$cfg['Servers'][\$i]['host'] = 'localhost';";
        $f[] = "\$cfg['Servers'][\$i]['connect_type'] = 'socket';";
        $f[] = "\$cfg['Servers'][\$i]['compress'] = false;";
        $f[] = "\$cfg['Servers'][\$i]['AllowNoPassword'] = true;";
        $f[] = "\$cfg['Servers'][\$i]['nopassword'] = true;";
        $f[] = "\$cfg['Servers'][\$i]['AllowRoot'] = true;";
        $f[] = "\$cfg['Servers'][\$i]['AllowNoPasswordRoot'] = true;";
    }
    $f[] = "";
    $f[] = "/*";
    $f[] = " * phpMyAdmin configuration storage settings.";
    $f[] = " */";
    $f[] = "";
    $f[] = "\$i++;";
    $f[] = "/* User used to manipulate with storage */";
    $f[] = "// \$cfg['Servers'][\$i]['controlhost'] = '';";
    $f[] = "// \$cfg['Servers'][\$i]['controlport'] = '';";
    $f[] = "// \$cfg['Servers'][\$i]['controluser'] = '******';";
    $f[] = "// \$cfg['Servers'][\$i]['controlpass'] = '******';";
    $f[] = "";
    $f[] = "/* Storage database and tables */";
    $f[] = "\$cfg['Servers'][\$i]['pmadb'] = 'phpmyadmin';";
    $f[] = "\$cfg['Servers'][\$i]['bookmarktable'] = 'pma__bookmark';";
    $f[] = "\$cfg['Servers'][\$i]['relation'] = 'pma__relation';";
    $f[] = "\$cfg['Servers'][\$i]['table_info'] = 'pma__table_info';";
    $f[] = "\$cfg['Servers'][\$i]['table_coords'] = 'pma__table_coords';";
    $f[] = "\$cfg['Servers'][\$i]['pdf_pages'] = 'pma__pdf_pages';";
    $f[] = "\$cfg['Servers'][\$i]['column_info'] = 'pma__column_info';";
    $f[] = "\$cfg['Servers'][\$i]['history'] = 'pma__history';";
    $f[] = "\$cfg['Servers'][\$i]['table_uiprefs'] = 'pma__table_uiprefs';";
    $f[] = "\$cfg['Servers'][\$i]['tracking'] = 'pma__tracking';";
    $f[] = "\$cfg['Servers'][\$i]['designer_coords'] = 'pma__designer_coords';";
    $f[] = "\$cfg['Servers'][\$i]['userconfig'] = 'pma__userconfig';";
    $f[] = "\$cfg['Servers'][\$i]['recent'] = 'pma__recent';";
    $f[] = "\$cfg['Servers'][\$i]['favorite'] = 'pma__favorite';";
    $f[] = "\$cfg['Servers'][\$i]['users'] = 'pma__users';";
    $f[] = "\$cfg['Servers'][\$i]['usergroups'] = 'pma__usergroups';";
    $f[] = "\$cfg['Servers'][\$i]['navigationhiding'] = 'pma__navigationhiding';";
    $f[] = "\$cfg['Servers'][\$i]['savedsearches'] = 'pma__savedsearches';";
    $f[] = "/* Contrib / Swekey authentication */";
    $f[] = "// \$cfg['Servers'][\$i]['auth_swekey_config'] = '/etc/swekey-pma.conf';";
    $f[] = "";
    $f[] = "/*";
    $f[] = " * End of servers configuration";
    $f[] = " */";
    $f[] = "";
    $f[] = "/*";
    $f[] = " * Directories for saving/loading files from server";
    $f[] = " */";
    $f[] = "\$cfg['UploadDir'] = '';";
    $f[] = "\$cfg['SaveDir'] = '';";
    $f[] = "";
    $f[] = "/**";
    $f[] = " * Whether to display icons or text or both icons and text in table row";
    $f[] = " * action segment. Value can be either of 'icons', 'text' or 'both'.";
    $f[] = " */";
    $f[] = "//\$cfg['RowActionType'] = 'both';";
    $f[] = "";
    $f[] = "/**";
    $f[] = " * Defines whether a user should be displayed a \"show all (records)\"";
    $f[] = " * button in browse mode or not.";
    $f[] = " * default = false";
    $f[] = " */";
    $f[] = "//\$cfg['ShowAll'] = true;";
    $f[] = "";
    $f[] = "/**";
    $f[] = " * Number of rows displayed when browsing a result set. If the result";
    $f[] = " * set contains more rows, \"Previous\" and \"Next\".";
    $f[] = " * default = 30";
    $f[] = " */";
    $f[] = "//\$cfg['MaxRows'] = 50;";
    $f[] = "";
    $f[] = "/**";
    $f[] = " * disallow editing of binary fields";
    $f[] = " * valid values are:";
    $f[] = " *   false    allow editing";
    $f[] = " *   'blob'   allow editing except for BLOB fields";
    $f[] = " *   'noblob' disallow editing except for BLOB fields";
    $f[] = " *   'all'    disallow editing";
    $f[] = " * default = blob";
    $f[] = " */";
    $f[] = "//\$cfg['ProtectBinary'] = 'false';";
    $f[] = "";
    $f[] = "/**";
    $f[] = " * Default language to use, if not browser-defined or user-defined";
    $f[] = " * (you find all languages in the locale folder)";
    $f[] = " * uncomment the desired line:";
    $f[] = " * default = 'en'";
    $f[] = " */";
    $f[] = "//\$cfg['DefaultLang'] = 'en';";
    $f[] = "//\$cfg['DefaultLang'] = 'de';";
    $f[] = "//\$cfg['DefaultLang'] = 'fr';";
    $f[] = "";
    $f[] = "/**";
    $f[] = " * default display direction (horizontal|vertical|horizontalflipped)";
    $f[] = " */";
    $f[] = "//\$cfg['DefaultDisplay'] = 'vertical';";
    $f[] = "";
    $f[] = "";
    $f[] = "/**";
    $f[] = " * How many columns should be used for table display of a database?";
    $f[] = " * (a value larger than 1 results in some information being hidden)";
    $f[] = " * default = 1";
    $f[] = " */";
    $f[] = "//\$cfg['PropertiesNumColumns'] = 2;";
    $f[] = "";
    $f[] = "/**";
    $f[] = " * Set to true if you want DB-based query history.If false, this utilizes";
    $f[] = " * JS-routines to display query history (lost by window close)";
    $f[] = " *";
    $f[] = " * This requires configuration storage enabled, see above.";
    $f[] = " * default = false";
    $f[] = " */";
    $f[] = "//\$cfg['QueryHistoryDB'] = true;";
    $f[] = "";
    $f[] = "/**";
    $f[] = " * When using DB-based query history, how many entries should be kept?";
    $f[] = " *";
    $f[] = " * default = 25";
    $f[] = " */";
    $f[] = "//\$cfg['QueryHistoryMax'] = 100;";
    $f[] = "";
    $f[] = "/**";
    $f[] = " * Should error reporting be enabled for JavaScript errors";
    $f[] = " *";
    $f[] = " * default = 'ask'";
    $f[] = " */";
    $f[] = "//\$cfg['SendErrorReports'] = 'ask';";
    $f[] = "";
    $f[] = "/*";
    $f[] = " * You can find more configuration options in the documentation";
    $f[] = " * in the doc/ folder or at <http://docs.phpmyadmin.net/>.";
    $f[] = " */";
    $f[] = "?>";
    echo "slapd: [INFO] phpmyadmin success\n";
    @file_put_contents("/usr/share/phpmyadmin/config.inc.php", @implode("\n", $f));
    @chmod("/usr/share/phpmyadmin/config.inc.php", 0705);
    $q = new mysql();
    if (!$q->DATABASE_EXISTS("phpmyadmin")) {
        $q->CREATE_DATABASE("phpmyadmin");
    }
    $q->QUERY_SQL("CREATE TABLE IF NOT EXISTS `pma__bookmark` (\n`id` int(11) NOT NULL auto_increment,\n`dbase` varchar(255) NOT NULL default '',\n`user` varchar(255) NOT NULL default '',\n`label` varchar(255) COLLATE utf8_general_ci NOT NULL default '',\n`query` text NOT NULL,\nPRIMARY KEY  (`id`)\n)\nCOMMENT='Bookmarks'\nDEFAULT CHARACTER SET utf8 COLLATE utf8_bin;", "phpmyadmin");
    $q->QUERY_SQL("CREATE TABLE IF NOT EXISTS `pma__column_info` (\n\t\t`id` int(5) unsigned NOT NULL auto_increment,\n\t\t`db_name` varchar(64) NOT NULL default '',\n\t\t`table_name` varchar(64) NOT NULL default '',\n\t\t`column_name` varchar(64) NOT NULL default '',\n\t\t`comment` varchar(255) COLLATE utf8_general_ci NOT NULL default '',\n\t\t`mimetype` varchar(255) COLLATE utf8_general_ci NOT NULL default '',\n\t\t`transformation` varchar(255) NOT NULL default '',\n\t\t`transformation_options` varchar(255) NOT NULL default '',\n\t\tPRIMARY KEY  (`id`),\n\t\tUNIQUE KEY `db_name` (`db_name`,`table_name`,`column_name`)\n)\nCOMMENT='Column information for phpMyAdmin'\n\t\tDEFAULT CHARACTER SET utf8 COLLATE utf8_bin;", "phpmyadmin");
    $q->QUERY_SQL("CREATE TABLE IF NOT EXISTS `pma__history` (\n\t\t`id` bigint(20) unsigned NOT NULL auto_increment,\n\t\t`username` varchar(64) NOT NULL default '',\n\t\t`db` varchar(64) NOT NULL default '',\n\t\t`table` varchar(64) NOT NULL default '',\n\t\t`timevalue` timestamp NOT NULL,\n\t\t`sqlquery` text NOT NULL,\n\t\tPRIMARY KEY  (`id`),\n\t\tKEY `username` (`username`,`db`,`table`,`timevalue`)\n)\nCOMMENT='SQL history for phpMyAdmin'\n\t\tDEFAULT CHARACTER SET utf8 COLLATE utf8_bin;", "phpmyadmin");
    $q->QUERY_SQL("CREATE TABLE IF NOT EXISTS `pma__pdf_pages` (\n\t\t`db_name` varchar(64) NOT NULL default '',\n\t\t`page_nr` int(10) unsigned NOT NULL auto_increment,\n\t\t`page_descr` varchar(50) COLLATE utf8_general_ci NOT NULL default '',\n\t\tPRIMARY KEY  (`page_nr`),\n\t\tKEY `db_name` (`db_name`)\n)\nCOMMENT='PDF relation pages for phpMyAdmin'\n\t\tDEFAULT CHARACTER SET utf8 COLLATE utf8_bin;", "phpmyadmin");
    $q->QUERY_SQL("CREATE TABLE IF NOT EXISTS `pma__recent` (\n\t\t`username` varchar(64) NOT NULL,\n\t\t`tables` text NOT NULL,\n\t\tPRIMARY KEY (`username`)\n)\nCOMMENT='Recently accessed tables'\n\t\tDEFAULT CHARACTER SET utf8 COLLATE utf8_bin;", "phpmyadmin");
    $q->QUERY_SQL("CREATE TABLE IF NOT EXISTS `pma__favorite` (\n\t\t`username` varchar(64) NOT NULL,\n\t\t`tables` text NOT NULL,\n\t\tPRIMARY KEY (`username`)\n)\nCOMMENT='Favorite tables'\n\t\tDEFAULT CHARACTER SET utf8 COLLATE utf8_bin;", "phpmyadmin");
    $q->QUERY_SQL("CREATE TABLE IF NOT EXISTS `pma__table_uiprefs` (\n\t\t`username` varchar(64) NOT NULL,\n\t\t`db_name` varchar(64) NOT NULL,\n\t\t`table_name` varchar(64) NOT NULL,\n\t\t`prefs` text NOT NULL,\n\t\t`last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n\t\tPRIMARY KEY (`username`,`db_name`,`table_name`)\n)\nCOMMENT='Tables'' UI preferences'\n\t\tDEFAULT CHARACTER SET utf8 COLLATE utf8_bin;", "phpmyadmin");
    $q->QUERY_SQL("CREATE TABLE IF NOT EXISTS `pma__relation` (\n\t\t`master_db` varchar(64) NOT NULL default '',\n\t\t`master_table` varchar(64) NOT NULL default '',\n\t\t`master_field` varchar(64) NOT NULL default '',\n\t\t`foreign_db` varchar(64) NOT NULL default '',\n\t\t`foreign_table` varchar(64) NOT NULL default '',\n\t\t`foreign_field` varchar(64) NOT NULL default '',\n\t\tPRIMARY KEY  (`master_db`,`master_table`,`master_field`),\n\t\tKEY `foreign_field` (`foreign_db`,`foreign_table`)\n)\nCOMMENT='Relation table'\n\t\tDEFAULT CHARACTER SET utf8 COLLATE utf8_bin;", "phpmyadmin");
    $q->QUERY_SQL("CREATE TABLE IF NOT EXISTS `pma__table_coords` (\n\t\t`db_name` varchar(64) NOT NULL default '',\n\t\t`table_name` varchar(64) NOT NULL default '',\n\t\t`pdf_page_number` int(11) NOT NULL default '0',\n\t\t`x` float unsigned NOT NULL default '0',\n\t\t`y` float unsigned NOT NULL default '0',\n\t\tPRIMARY KEY  (`db_name`,`table_name`,`pdf_page_number`)\n)\nCOMMENT='Table coordinates for phpMyAdmin PDF output'\n\t\tDEFAULT CHARACTER SET utf8 COLLATE utf8_bin;", "phpmyadmin");
    $q->QUERY_SQL("CREATE TABLE IF NOT EXISTS `pma__table_info` (\n\t\t`db_name` varchar(64) NOT NULL default '',\n\t\t`table_name` varchar(64) NOT NULL default '',\n\t\t`display_field` varchar(64) NOT NULL default '',\n\t\tPRIMARY KEY  (`db_name`,`table_name`)\n)\nCOMMENT='Table information for phpMyAdmin'\n\t\tDEFAULT CHARACTER SET utf8 COLLATE utf8_bin;", "phpmyadmin");
    $q->QUERY_SQL("CREATE TABLE IF NOT EXISTS `pma__designer_coords` (\n\t\t`db_name` varchar(64) NOT NULL default '',\n\t\t`table_name` varchar(64) NOT NULL default '',\n\t\t`x` INT,\n\t\t`y` INT,\n\t\t`v` TINYINT,\n\t\t`h` TINYINT,\n\t\tPRIMARY KEY (`db_name`,`table_name`)\n)\nCOMMENT='Table coordinates for Designer'\n\t\tDEFAULT CHARACTER SET utf8 COLLATE utf8_bin;", "phpmyadmin");
    $q->QUERY_SQL("CREATE TABLE IF NOT EXISTS `pma__tracking` (\n\t\t`db_name` varchar(64) NOT NULL,\n\t\t`table_name` varchar(64) NOT NULL,\n\t\t`version` int(10) unsigned NOT NULL,\n\t\t`date_created` datetime NOT NULL,\n\t\t`date_updated` datetime NOT NULL,\n\t\t`schema_snapshot` text NOT NULL,\n\t\t`schema_sql` text,\n\t\t`data_sql` longtext,\n\t\t`tracking` set('UPDATE','REPLACE','INSERT','DELETE','TRUNCATE','CREATE DATABASE','ALTER DATABASE','DROP DATABASE','CREATE TABLE','ALTER TABLE','RENAME TABLE','DROP TABLE','CREATE INDEX','DROP INDEX','CREATE VIEW','ALTER VIEW','DROP VIEW') default NULL,\n\t\t`tracking_active` int(1) unsigned NOT NULL default '1',\n\t\tPRIMARY KEY  (`db_name`,`table_name`,`version`)\n)\nCOMMENT='Database changes tracking for phpMyAdmin'\n\t\tDEFAULT CHARACTER SET utf8 COLLATE utf8_bin;", "phpmyadmin");
    $q->QUERY_SQL("CREATE TABLE IF NOT EXISTS `pma__userconfig` (\n\t\t`username` varchar(64) NOT NULL,\n\t\t`timevalue` timestamp NOT NULL,\n\t\t`config_data` text NOT NULL,\n\t\tPRIMARY KEY  (`username`)\n)\nCOMMENT='User preferences storage for phpMyAdmin'\n\t\tDEFAULT CHARACTER SET utf8 COLLATE utf8_bin;", "phpmyadmin");
    $q->QUERY_SQL("CREATE TABLE IF NOT EXISTS `pma__users` (\n\t\t`username` varchar(64) NOT NULL,\n\t\t`usergroup` varchar(64) NOT NULL,\n\t\tPRIMARY KEY (`username`,`usergroup`)\n)\nCOMMENT='Users and their assignments to user groups'\n\t\tDEFAULT CHARACTER SET utf8 COLLATE utf8_bin;", "phpmyadmin");
    $q->QUERY_SQL("CREATE TABLE IF NOT EXISTS `pma__usergroups` (\n\t\t`usergroup` varchar(64) NOT NULL,\n\t\t`tab` varchar(64) NOT NULL,\n\t\t`allowed` enum('Y','N') NOT NULL DEFAULT 'N',\n\t\tPRIMARY KEY (`usergroup`,`tab`,`allowed`)\n)\nCOMMENT='User groups with configured menu items'\n\t\tDEFAULT CHARACTER SET utf8 COLLATE utf8_bin;", "phpmyadmin");
    $q->QUERY_SQL("CREATE TABLE IF NOT EXISTS `pma__navigationhiding` (\n\t\t`username` varchar(64) NOT NULL,\n\t\t`item_name` varchar(64) NOT NULL,\n\t\t`item_type` varchar(64) NOT NULL,\n\t\t`db_name` varchar(64) NOT NULL,\n\t\t`table_name` varchar(64) NOT NULL,\n\t\tPRIMARY KEY (`username`,`item_name`,`item_type`,`db_name`,`table_name`)\n)\nCOMMENT='Hidden items of navigation tree'\n\t\tDEFAULT CHARACTER SET utf8 COLLATE utf8_bin;", "phpmyadmin");
    $q->QUERY_SQL("CREATE TABLE IF NOT EXISTS `pma__savedsearches` (\n\t\t`id` int(5) unsigned NOT NULL auto_increment,\n\t\t`username` varchar(64) NOT NULL default '',\n\t\t`db_name` varchar(64) NOT NULL default '',\n\t\t`search_name` varchar(64) NOT NULL default '',\n\t\t`search_data` text NOT NULL,\n\t\tPRIMARY KEY  (`id`),\n\t\tUNIQUE KEY `u_savedsearches_username_dbname` (`username`,`db_name`,`search_name`)\n)", "phpmyadmin");
}
コード例 #16
0
ファイル: exec.pdns.php プロジェクト: BillTheBest/1.6.x
function checkMysql($nollop = false)
{
    $unix = new unix();
    $timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    if ($unix->file_time_min($timefile) < 1) {
        echo "Starting......: " . date("H:i:s") . " PowerDNS need at least 1mn, aborting\n";
        return;
    }
    @unlink($timefile);
    @file_put_contents($timefile, time());
    $passwdcmdline = null;
    $mysql = $unix->find_program("mysql");
    $q = new mysql();
    if (!$q->TestingConnection(true)) {
        echo "Starting......: " . date("H:i:s") . " PowerDNS creating, MySQL seems not ready..\n";
        return;
    }
    forward_zones();
    if (!$q->DATABASE_EXISTS("powerdns")) {
        echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'powerdns' database\n";
        if (!$q->CREATE_DATABASE("powerdns")) {
            echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'powerdns' database failed\n";
            return;
        }
    }
    echo "Starting......: " . date("H:i:s") . " PowerDNS 'powerdns' database OK\n";
    $f["cryptokeys"] = true;
    $f["domainmetadata"] = true;
    $f["domains"] = true;
    $f["perm_items"] = true;
    $f["perm_templ"] = true;
    $f["perm_templ_items"] = true;
    $f["records"] = true;
    $f["supermasters"] = true;
    $f["tsigkeys"] = true;
    $f["users"] = true;
    $f["zones"] = true;
    $f["zone_templ"] = true;
    $f["zone_templ_records"] = true;
    $resultTables = true;
    while (list($tablename, $line2) = each($f)) {
        if (!$q->TABLE_EXISTS($tablename, "powerdns")) {
            echo "Starting......: " . date("H:i:s") . " PowerDNS Table `{$tablename}` failed...\n";
            $resultTables = false;
            continue;
        }
        echo "Starting......: " . date("H:i:s") . " PowerDNS Table `{$tablename}` OK...\n";
    }
    if ($resultTables) {
        echo "Starting......: " . date("H:i:s") . " PowerDNS pass tests Success...\n";
        return true;
    }
    $dumpfile = "/usr/share/artica-postfix/bin/install/pdns/powerdns.sql";
    if (!is_file($dumpfile)) {
        echo "Starting......: " . date("H:i:s") . " PowerDNS /usr/share/artica-postfix/bin/install/pdns/powerdns.sql no such file...\n";
        return;
    }
    echo "Starting......: " . date("H:i:s") . " PowerDNS installing database...\n";
    if ($q->mysql_password != null) {
        $passwdcmdline = " -p{$q->mysql_password}";
    }
    $cmd = "{$mysql} -B -u {$q->mysql_admin}{$passwdcmdline} --database=powerdns -E < {$dumpfile} >/dev/null 2>&1";
    shell_exec($cmd);
    reset($f);
    $resultTables = true;
    while (list($tablename, $line2) = each($f)) {
        if (!$q->TABLE_EXISTS($tablename, "powerdns")) {
            echo "Starting......: " . date("H:i:s") . " PowerDNS Table `{$tablename}` failed...\n";
            $resultTables = false;
            continue;
        }
        echo "Starting......: " . date("H:i:s") . " PowerDNS Table `{$tablename}` OK...\n";
    }
    if ($resultTables) {
        echo "Starting......: " . date("H:i:s") . " PowerDNS Success...\n";
        return true;
    }
    if (!$q->TABLE_EXISTS("domains", "powerdns")) {
        echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'domains' table\n";
        $sql = "CREATE TABLE IF NOT EXISTS domains (\n\t\t\t id\t\t INT auto_increment,\n\t\t\t name\t\t VARCHAR(255) NOT NULL,\n\t\t\t master\t\t VARCHAR(128) DEFAULT NULL,\n\t\t\t last_check\t INT DEFAULT NULL,\n\t\t\t type\t\t VARCHAR(6) NOT NULL,\n\t\t\t notified_serial INT DEFAULT NULL, \n\t\t\t account         VARCHAR(40) DEFAULT NULL,\n\t\t\t primary key (id)\n\t\t\t) Engine=InnoDB;";
        $q->QUERY_SQL($sql, "powerdns");
        if (!$q->ok) {
            echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'domains' table FAILED\n";
        } else {
            return;
        }
        echo "Starting......: " . date("H:i:s") . " PowerDNS table 'domains' Success\n";
    } else {
        echo "Starting......: " . date("H:i:s") . " PowerDNS table 'domains' Success\n";
        $q->QUERY_SQL("CREATE UNIQUE INDEX name_index ON domains(name);", "powerdns");
    }
    if (!$q->TABLE_EXISTS("records", "powerdns")) {
        echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'records' table\n";
        $sql = "CREATE TABLE IF NOT EXISTS records (\n\t\t\t  id              INT auto_increment,\n\t\t\t  domain_id       INT DEFAULT NULL,\n\t\t\t  name            VARCHAR(255) DEFAULT NULL,\n\t\t\t  type            VARCHAR(10) DEFAULT NULL,\n\t\t\t  content         VARCHAR(255) DEFAULT NULL,\n\t\t\t  ttl             INT DEFAULT NULL,\n\t\t\t  prio            INT DEFAULT NULL,\n\t\t\t  change_date     INT DEFAULT NULL,\n\t\t\t  explainthis     VARCHAR(255) DEFAULT NULL,\n\t\t\t  primary key(id)\n\t\t\t)Engine=InnoDB;";
        $q->QUERY_SQL($sql, "powerdns");
        if (!$q->ok) {
            echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'records' table FAILED\n";
            return;
        }
        $q->QUERY_SQL("CREATE INDEX rec_name_index ON records(name);", "powerdns");
        $q->QUERY_SQL("CREATE INDEX nametype_index ON records(name,type);", "powerdns");
        $q->QUERY_SQL("CREATE INDEX domain_id ON records(domain_id);", "powerdns");
        $q->QUERY_SQL("alter table records add ordername VARCHAR(255);", "powerdns");
        $q->QUERY_SQL("alter table records add auth bool;", "powerdns");
        $q->QUERY_SQL("create index orderindex on records(ordername);", "powerdns");
        $q->QUERY_SQL("alter table records change column type type VARCHAR(10);", "powerdns");
        echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'records' table success\n";
    } else {
        echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'records' table success\n";
    }
    if (!$q->TABLE_EXISTS("supermasters", "powerdns")) {
        echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'supermasters' table\n";
        $sql = "CREATE TABLE IF NOT EXISTS supermasters (\n\t\t\t\t  ip VARCHAR(25) NOT NULL, \n\t\t\t\t  nameserver VARCHAR(255) NOT NULL, \n\t\t\t\t  account VARCHAR(40) DEFAULT NULL\n\t\t\t\t) Engine=InnoDB;";
        $q->QUERY_SQL($sql, "powerdns");
        if (!$q->ok) {
            echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'supermasters' table FAILED\n";
            return;
        }
        $q->QUERY_SQL("CREATE INDEX rec_name_index ON records(name);", "powerdns");
        $q->QUERY_SQL("CREATE INDEX nametype_index ON records(name,type);", "powerdns");
        $q->QUERY_SQL("CREATE INDEX domain_id ON records(domain_id);", "powerdns");
        echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'supermasters' table success\n";
    } else {
        echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'supermasters' table success\n";
    }
    if (!$q->TABLE_EXISTS("domainmetadata", "powerdns")) {
        echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'domainmetadata' table\n";
        $sql = "CREATE TABLE IF NOT EXISTS domainmetadata (\n\t\t\t id              INT auto_increment,\n\t\t\t domain_id       INT NOT NULL,\n\t\t\t kind            VARCHAR(16),\n\t\t\t content        TEXT,\n\t\t\t primary key(id)\n\t\t\t);";
        $q->QUERY_SQL($sql, "powerdns");
        if (!$q->ok) {
            echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'domainmetadata' table FAILED\n";
            return;
        }
        echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'domainmetadata' table success\n";
        $q->QUERY_SQL("create index domainmetaidindex on domainmetadata(domain_id);", "powerdns");
    } else {
        echo "Starting......: " . date("H:i:s") . " PowerDNS 'domainmetadata' table success\n";
    }
    if (!$q->TABLE_EXISTS("cryptokeys", "powerdns")) {
        echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'cryptokeys' table\n";
        $sql = "CREATE TABLE IF NOT EXISTS cryptokeys (\n\t\t\t id             INT auto_increment,\n\t\t\t domain_id      INT NOT NULL,\n\t\t\t flags          INT NOT NULL,\n\t\t\t active         BOOL,\n\t\t\t content        TEXT,\n\t\t\t primary key(id)\n\t\t\t); ";
        $q->QUERY_SQL($sql, "powerdns");
        if (!$q->ok) {
            echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'cryptokeys' table FAILED\n";
            return;
        }
        echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'cryptokeys' table success\n";
        $q->QUERY_SQL("create index domainidindex on cryptokeys(domain_id);", "powerdns");
    } else {
        echo "Starting......: " . date("H:i:s") . " PowerDNS 'cryptokeys' table success\n";
    }
    if (!$q->TABLE_EXISTS("tsigkeys", "powerdns")) {
        echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'tsigkeys' table\n";
        $sql = "CREATE TABLE IF NOT EXISTS tsigkeys (\n\t\t\t id             INT auto_increment,\n\t\t\t name           VARCHAR(255), \n\t\t\t algorithm      VARCHAR(255),\n\t\t\t secret         VARCHAR(255),\n\t\t\t primary key(id)\n\t\t\t);";
        $q->QUERY_SQL($sql, "powerdns");
        if (!$q->ok) {
            echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'tsigkeys' table FAILED\n";
            return;
        }
        echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'tsigkeys' table success\n";
        $q->QUERY_SQL("create unique index namealgoindex on tsigkeys(name, algorithm);", "powerdns");
    } else {
        echo "Starting......: " . date("H:i:s") . " PowerDNS 'tsigkeys' table success\n";
    }
    if (!$q->TABLE_EXISTS("users", "powerdns")) {
        echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'users' table\n";
        $sql = "CREATE TABLE IF NOT EXISTS `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(16) NOT NULL DEFAULT '0', `password` varchar(34) NOT NULL DEFAULT '0', `fullname` varchar(255) NOT NULL DEFAULT '0', `email` varchar(255) NOT NULL DEFAULT '0', `description` varchar(1024) NOT NULL DEFAULT '0', `perm_templ` tinyint(4) NOT NULL DEFAULT '0', `active` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`id`))";
        $q->QUERY_SQL($sql, "powerdns");
        if (!$q->ok) {
            echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'users' table FAILED\n";
            return;
        }
        echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'users' table success\n";
    } else {
        echo "Starting......: " . date("H:i:s") . " PowerDNS 'users' table success\n";
    }
    if (!$q->TABLE_EXISTS("perm_items", "powerdns")) {
        echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'perm_items' table\n";
        $sql = "CREATE TABLE IF NOT EXISTS `perm_items` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(64) NOT NULL DEFAULT '0', `descr` varchar(1024) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=62 ;";
        $q->QUERY_SQL($sql, "powerdns");
        if (!$q->ok) {
            echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'perm_items' table FAILED\n";
            return;
        }
        echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'perm_items' table success\n";
        $sql = "INSERT INTO `perm_items` (`id`, `name`, `descr`) VALUES (41, 'zone_master_add', 'User is allowed to add new master zones.'), (42, 'zone_slave_add', 'User is allowed to add new slave zones.'), (43, 'zone_content_view_own', 'User is allowed to see the content and meta data of zones he owns.'), (44, 'zone_content_edit_own', 'User is allowed to edit the content of zones he owns.'), (45, 'zone_meta_edit_own', 'User is allowed to edit the meta data of zones he owns.'), (46, 'zone_content_view_others', 'User is allowed to see the content and meta data of zones he does not own.'), (47, 'zone_content_edit_others', 'User is allowed to edit the content of zones he does not own.'), (48, 'zone_meta_edit_others', 'User is allowed to edit the meta data of zones he does not own.'), (49, 'search', 'User is allowed to perform searches.'), (50, 'supermaster_view', 'User is allowed to view supermasters.'), (51, 'supermaster_add', 'User is allowed to add new supermasters.'), (52, 'supermaster_edit', 'User is allowed to edit supermasters.'), (53, 'user_is_ueberuser', 'User has full access. God-like. Redeemer.'), (54, 'user_view_others', 'User is allowed to see other users and their details.'), (55, 'user_add_new', 'User is allowed to add new users.'), (56, 'user_edit_own', 'User is allowed to edit their own details.'), (57, 'user_edit_others', 'User is allowed to edit other users.'), (58, 'user_passwd_edit_others', 'User is allowed to edit the password of other users.'), (59, 'user_edit_templ_perm', 'User is allowed to change the permission template that is assigned to a user.'), (60, 'templ_perm_add', 'User is allowed to add new permission templates.'), (61, 'templ_perm_edit', 'User is allowed to edit existing permission templates.');";
        $q->QUERY_SQL($sql, "powerdns");
    } else {
        echo "Starting......: " . date("H:i:s") . " PowerDNS 'perm_items' table success\n";
    }
    if (!$q->TABLE_EXISTS("perm_templ", "powerdns")) {
        echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'perm_templ' table\n";
        $sql = "CREATE TABLE IF NOT EXISTS `perm_templ` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(128) NOT NULL DEFAULT '0', `descr` varchar(1024) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;";
        $q->QUERY_SQL($sql, "powerdns");
        if (!$q->ok) {
            echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'perm_templ' table FAILED\n";
        } else {
            $sql = "INSERT INTO `perm_templ` (`id`, `name`, `descr`) VALUES (1, 'Administrator', 'Administrator template with full rights.');";
            $q->QUERY_SQL($sql, "powerdns");
        }
    }
    if (!$q->TABLE_EXISTS("perm_templ_items", "powerdns")) {
        echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'perm_templ_items' table\n";
        $sql = "CREATE TABLE IF NOT EXISTS `perm_templ_items` ( `id` int(11) NOT NULL AUTO_INCREMENT, `templ_id` int(11) NOT NULL DEFAULT '0', `perm_id` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=250 ;";
        $q->QUERY_SQL($sql, "powerdns");
        if (!$q->ok) {
            echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'perm_templ_items' table FAILED\n";
            return;
        }
        echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'perm_templ_items' table success\n";
        $sql = "INSERT INTO `perm_templ_items` (`id`, `templ_id`, `perm_id`) VALUES (249, 1, 53);";
        $q->QUERY_SQL($sql, "powerdns");
    } else {
        echo "Starting......: " . date("H:i:s") . " PowerDNS 'perm_templ_items' table success\n";
    }
    if (!$q->TABLE_EXISTS("zones", "powerdns")) {
        echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'zones' table\n";
        $sql = "CREATE TABLE IF NOT EXISTS `zones` ( `id` int(11) NOT NULL AUTO_INCREMENT, `domain_id` int(11) NOT NULL DEFAULT '0', `owner` int(11) NOT NULL DEFAULT '0', `comment` varchar(1024) DEFAULT '0', `zone_templ_id` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;";
        $q->QUERY_SQL($sql, "powerdns");
        if (!$q->ok) {
            echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'zones' table FAILED\n";
            return;
        }
    } else {
        echo "Starting......: " . date("H:i:s") . " PowerDNS 'zones' table success\n";
    }
    if (!$q->TABLE_EXISTS("zone_templ", "powerdns")) {
        echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'zone_templ' table\n";
        $sql = "CREATE TABLE IF NOT EXISTS `zone_templ` ( \n\t\t\t\t`id` bigint(20) NOT NULL AUTO_INCREMENT, \n\t\t\t\t`name` varchar(128) NOT NULL DEFAULT '0', \n\t\t\t\t`descr` varchar(1024) NOT NULL DEFAULT '0', \n\t\t\t\t`owner` bigint(20) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) \n\t\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;";
        $q->QUERY_SQL($sql, "powerdns");
        if (!$q->ok) {
            echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'zone_templ' table FAILED\n";
            return;
        }
        echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'zone_templ' table success\n";
    } else {
        echo "Starting......: " . date("H:i:s") . " PowerDNS 'zone_templ' table success\n";
    }
    $q->QUERY_SQL("CREATE TABLE IF NOT EXISTS zone_templ_records (\n\tid            INTEGER      NOT NULL AUTO_INCREMENT,\n\tzone_templ_id INTEGER      NOT NULL,\n\tname          VARCHAR(255) NOT NULL,\n\t`type`        VARCHAR(6)   NOT NULL,\n\tcontent       VARCHAR(255) NOT NULL,\n\tttl           INTEGER      NOT NULL,\n\tprio          INTEGER      NOT NULL,\n\tPRIMARY KEY (id)\n\t) ENGINE=InnoDB DEFAULT CHARSET=latin1;", "powerdns");
    $q->QUERY_SQL("CREATE TABLE IF NOT EXISTS records_zone_templ (\n\tdomain_id INTEGER NOT NULL,\n\trecord_id INTEGER NOT NULL,\n\tzone_templ_id INTEGER NOT NULL\n\t) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
    if (!$q->TABLE_EXISTS("zone_templ_records", "powerdns")) {
        echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'zone_templ_records' table\n";
        $sql = "CREATE TABLE IF NOT EXISTS `zone_templ_records` (\n\t\t  `id` bigint(20) NOT NULL AUTO_INCREMENT,\n\t\t  `zone_templ_id` bigint(20) NOT NULL DEFAULT '0',\n\t\t  `name` varchar(255) NOT NULL DEFAULT '0',\n\t\t  `type` varchar(6) NOT NULL DEFAULT '0',\n\t\t  `content` varchar(255) NOT NULL DEFAULT '0',\n\t\t  `ttl` bigint(20) NOT NULL DEFAULT '0',\n\t\t  `prio` bigint(20) NOT NULL DEFAULT '0',\n\t\t  PRIMARY KEY (`id`)\n\t\t) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;";
        $q->QUERY_SQL($sql, "powerdns");
        if (!$q->ok) {
            echo "Starting......: " . date("H:i:s") . " PowerDNS creating 'zone_templ_records' table FAILED\n";
        }
    }
    if (!$q->TABLE_EXISTS("domainmetadata", "powerdns")) {
        $q->QUERY_SQL("create table domainmetadata ( id INT auto_increment, domain_id INT NOT NULL, kind VARCHAR(16), content TEXT, primary key(id) );", "powerdns");
        if (!$q->ok) {
            echo "Starting......: " . date("H:i:s") . " PowerDNS patching database/domainmetadata failed {$q->mysql_error}\n";
            return;
        }
        echo "Starting......: " . date("H:i:s") . " PowerDNS patching database/domainmetadata success\n";
        $q->QUERY_SQL("create index domainmetaidindex on domainmetadata(domain_id);", "powerdns");
        if (!$q->ok) {
            echo "Starting......: " . date("H:i:s") . " PowerDNS patching database/domainmetadata failed {$q->mysql_error}\n";
        }
    } else {
        echo "Starting......: " . date("H:i:s") . " PowerDNS patching database/domainmetadata OK\n";
    }
    if (!$q->TABLE_EXISTS("cryptokeys", "powerdns")) {
        $q->QUERY_SQL("create table cryptokeys (\n\tid             INT auto_increment,\n \tdomain_id      INT NOT NULL,\n\tflags          INT NOT NULL,\n \tactive         BOOL,\n \tcontent        TEXT,\n\tprimary key(id)\n\t);", "powerdns");
        if (!$q->ok) {
            echo "Starting......: " . date("H:i:s") . " PowerDNS patching database/cryptokeys failed {$q->mysql_error}\n";
        } else {
            echo "Starting......: " . date("H:i:s") . " PowerDNS patching database/cryptokeys success\n";
            $q->QUERY_SQL("create index domainidindex on cryptokeys(domain_id);", "powerdns");
            if (!$q->ok) {
                echo "Starting......: " . date("H:i:s") . " PowerDNS patching database/cryptokeys failed {$q->mysql_error}\n";
            }
        }
    } else {
        echo "Starting......: " . date("H:i:s") . " PowerDNS patching database/cryptokeys OK\n";
    }
    if ($q->TABLE_EXISTS("records", "powerdns")) {
        if (!$q->FIELD_EXISTS("records", "ordername", "powerdns")) {
            $q->QUERY_SQL("alter table records add ordername  VARCHAR(255)", "powerdns");
            if (!$q->ok) {
                echo "Starting......: " . date("H:i:s") . " PowerDNS patching database/records failed {$q->mysql_error}\n";
            }
            $q->QUERY_SQL("create index orderindex on records(ordername)", "powerdns");
        }
        if (!$q->FIELD_EXISTS("records", "auth", "powerdns")) {
            $q->QUERY_SQL("alter table records add auth bool", "powerdns");
            if (!$q->ok) {
                echo "Starting......: " . date("H:i:s") . " PowerDNS patching database/records failed {$q->mysql_error}\n";
            }
        }
        if (!$q->FIELD_EXISTS("records", "disabled", "powerdns")) {
            $q->QUERY_SQL("alter table records add `disabled` TINYINT(1) DEFAULT 0, ADD INDEX `disabled`(`disabled`)", "powerdns");
            if (!$q->ok) {
                echo "Starting......: " . date("H:i:s") . " PowerDNS patching database/records/disabled failed {$q->mysql_error}\n";
            }
        }
        $q->QUERY_SQL("alter table records change column type type VARCHAR(10);", "powerdns");
    }
    if (!$q->TABLE_EXISTS("tsigkeys", "powerdns")) {
        $q->QUERY_SQL("create table tsigkeys (\n\t\t id             INT auto_increment,\n\t\t name           VARCHAR(255), \n\t\t algorithm      VARCHAR(50),\n\t\t secret         VARCHAR(255),\n\t\t primary key(id)\n\t\t);", "powerdns");
        if (!$q->ok) {
            echo "Starting......: " . date("H:i:s") . " PowerDNS patching database/tsigkeys failed {$q->mysql_error}\n";
        } else {
            echo "Starting......: " . date("H:i:s") . " PowerDNS patching database/tsigkeys success\n";
            $q->QUERY_SQL("create unique index namealgoindex on tsigkeys(name, algorithm);", "powerdns");
            if (!$q->ok) {
                echo "Starting......: " . date("H:i:s") . " PowerDNS patching database/tsigkeys failed {$q->mysql_error}\n";
            }
        }
    } else {
        echo "Starting......: " . date("H:i:s") . " PowerDNS patching database/tsigkeys OK\n";
    }
    echo "Starting......: " . date("H:i:s") . " PowerDNS Mysql done...\n";
    poweradmin();
}
コード例 #17
0
function Save()
{
    $servername = trim(strtolower($_GET["servername"]));
    if (substr($servername, 0, 1) == '.') {
        echo $servername . " FAILED\n";
        return;
    }
    $users = new usersMenus();
    $sock = new sockets();
    $FreewebsStorageDirectory = $sock->GET_INFO("FreewebsStorageDirectory");
    if (!$users->AsWebMaster) {
        return "FALSE";
    }
    $uid = $_GET["uid"];
    $mysql_database = format_mysql_table($_GET["mysql_database"]);
    $mysql_password = $_GET["mysql_password"];
    $mysql_username = $_GET["mysql_username"];
    $lvm_vg = $_GET["lvm_vg"];
    $vg_size = $_GET["vg_size"];
    $ServerPort = $_GET["ServerPort"];
    if (!is_numeric($ServerPort)) {
        $ServerPort = 0;
    }
    if ($_GET["UseDefaultPort"] == 1) {
        $ServerPort = 0;
    }
    if (!is_numeric($vg_size)) {
        $vg_size = 5000;
    }
    $ftpuser = $_GET["ftpuser"];
    $ftppassword = $_GET["ftppassword"];
    $useSSL = $_GET["useSSL"];
    if (!$users->PUREFTP_INSTALLED) {
        $_GET["useFTP"] = 0;
        $ftpuser = null;
        $ftppassword = null;
    }
    $sql = "SELECT servername FROM freeweb WHERE servername='{$_GET["servername"]}'";
    $q = new mysql();
    $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, 'artica_backup'));
    if ($ligne["servername"] != null) {
        if ($uid != null) {
            $u = new user($uid);
            $ou = $u->ou;
        }
        if (!$users->AsSystemAdministrator) {
            $ou = $_SESSION["ou"];
        }
        $sql = "UPDATE freeweb SET \n\t\t\tmysql_password='******',\n\t\t\tmysql_username='******',\n\t\t\tmysql_database='{$mysql_database}',\n\t\t\tftpuser='******',\n\t\t\tftppassword='******',\n\t\t\tuid='{$uid}',\n\t\t\tuseMysql='{$_GET["useMysql"]}',\n\t\t\tuseFTP='{$_GET["useFTP"]}',\n\t\t\tlvm_vg='{$_GET["lvm_vg"]}',\n\t\t\tlvm_size='{$_GET["vg_size"]}',\n\t\t\tUseLoopDisk='{$_GET["UseLoopDisk"]}',\n\t\t\tLoopMounts='{$_GET["LoopMounts"]}',\n\t\t\tUseReverseProxy='{$_GET["UseReverseProxy"]}',\n\t\t\tProxyPass='******',\n\t\t\tuseSSL='{$useSSL}',\n\t\t\tServerPort='{$ServerPort}',\n\t\t\tou='{$ou}',\n\t\t\tForwarder='{$_GET["Forwarder"]}',\n\t\t\tForwardTo='{$_GET["ForwardTo"]}'\n\t\t\t\n\t\t\tWHERE servername='{$servername}'\n\t\t";
    } else {
        if ($uid != null) {
            $u = new user($uid);
            $ou = $u->ou;
        }
        if ($ou != null) {
            if ($FreewebsStorageDirectory != null) {
                $www_dir = "{$FreewebsStorageDirectory}/{$servername}";
            }
        }
        $sock = new sockets();
        $servername = str_replace('..', '.', $servername);
        $servername = str_replace('/', '.', $servername);
        $servername = str_replace('\\', '.', $servername);
        $servername = str_replace(' ', '.', $servername);
        $servername = str_replace('$', '.', $servername);
        $servername = str_replace('#', '.', $servername);
        $servername = str_replace('%', '.', $servername);
        $servername = str_replace('*', '.', $servername);
        if (substr($servername, strlen($servername) - 1, 1) == '.') {
            $servername = substr($servername, 0, strlen($servername) - 1);
        }
        if (substr($servername, 0, 1) == '.') {
            $servername = substr($servername, 1, strlen($servername));
        }
        $sock->getFrameWork("freeweb.php?force-resolv=yes");
        $sql = "INSERT INTO freeweb (mysql_password,mysql_username,ftpuser,ftppassword,useSSL,servername,mysql_database,\n\t\tuid,useMysql,useFTP,lvm_vg,lvm_size,UseLoopDisk,LoopMounts,ou,domainname,www_dir,ServerPort,UseReverseProxy,ProxyPass,Forwarder,ForwardTo)\n\t\tVALUES('{$mysql_password}','{$mysql_username}','{$ftpuser}','{$ftppassword}','{$useSSL}','{$servername}','{$mysql_database}',\n\t\t'{$uid}','{$_GET["useMysql"]}',\n\t\t'{$_GET["useFTP"]}','{$_GET["lvm_vg"]}','{$_GET["vg_size"]}','{$_GET["UseLoopDisk"]}','{$_GET["LoopMounts"]}','{$ou}',\n\t\t'{$_GET["domainname"]}','{$FreewebsStorageDirectory}','{$ServerPort}','{$_GET["UseReverseProxy"]}','{$_GET["ProxyPass"]}',\n\t\t'{$_GET["Forwarder"]}','{$_GET["ForwardTo"]}'\n\t\t)";
    }
    writelogs("{$sql}", __FUNCTION__, __FILE__, __LINE__);
    $q = new mysql();
    $q->BuildTables();
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    $sock = new sockets();
    if ($_GET["useFTP"] == 1) {
        if ($users->PUREFTP_INSTALLED) {
            if (trim($ftpuser) != null) {
                if (trim($ftppassword) != null) {
                    $pure = new pureftpd_user();
                    if (!$pure->CreateUser($ftpuser, $ftppassword, $servername)) {
                        echo "FTP: Failed\n";
                        return;
                    }
                    $sock->getFrameWork("services.php?reload-pure-ftpd=yes");
                }
            }
        }
    }
    if ($_GET["useMysql"] == 1) {
        if (!$q->DATABASE_EXISTS($mysql_database)) {
            $q->CREATE_DATABASE("{$mysql_database}");
        }
        if (!$q->PRIVILEGES($mysql_username, $mysql_password, $mysql_database)) {
            echo "GRANT {$mysql_database} FAILED FOR {$mysql_username}\n{$q->mysql_error}";
        }
    }
    if (isset($_GET["ADD_DNS_ENTRY"])) {
        $dnsDOM = explode(".", $_GET["servername"]);
        $netbiosname = $dnsDOM[0];
        unset($dnsDOM[0]);
        $domainname = implode(".", $dnsDOM);
        include_once dirname(__FILE__) . "/ressources/class.pdns.inc";
        $pdns = new pdns($domainname);
        $pdns->EditIPName($netbiosname, $_GET["ADD_DNS_ENTRY"], "A");
    }
    $sock->getFrameWork("cmd.php?freeweb-restart=yes");
}
コード例 #18
0
function CreateDatabase($arrayconfig)
{
    $q = new mysql();
    $errors = null;
    $lang = $arrayconfig["LANG"];
    $DBcreated = false;
    $DBtype = 'mysql';
    $DBhostname = $q->mysql_server;
    $DBuserName = $q->mysql_admin;
    $DBpassword = $q->mysql_password;
    $DBname = $arrayconfig["DB"];
    $DBPrefix = 'jos_';
    $DBOld = "bu";
    $DBversion = null;
    if ($q->DATABASE_EXISTS($arrayconfig["DB"])) {
        write_events("Database already exists");
        return true;
    }
    $q->CREATE_DATABASE($arrayconfig["DB"]);
    if (!$q->ok) {
        write_events("Error: {$q->mysql_error}");
    }
    if (!$q->DATABASE_EXISTS($arrayconfig["DB"])) {
        write_events("Failed to create database {$arrayconfig["DB"]} \"{$q->mysql_error}\"");
        set_status("{failed}");
        return false;
    }
    write_events("Database successfully created");
    $dbscheme = '/usr/local/share/artica/joomla_src/installation/sql/mysql/joomla.sql';
    populateDatabase($dbscheme, $arrayconfig["DB"]);
    $dbscheme = '/usr/local/share/artica/joomla_src/installation/sql/mysql/sample_data.sql';
    populateDatabase($dbscheme, $arrayconfig["DB"]);
    WriteAdmin($arrayconfig["uid"], $arrayconfig["DB"]);
    return true;
}
コード例 #19
0
function checks()
{
    $GLOBALS["DEBUG"] = true;
    $GLOBALS["VERBOSE"] = true;
    ini_set('display_errors', 1);
    ini_set('error_reporting', E_ALL);
    ini_set('error_prepend_string', null);
    ini_set('error_append_string', null);
    $q = new mysql();
    $q->BuildTables();
    $execute = false;
    $tableEngines = array("hardware" => "InnoDB", "accesslog" => "InnoDB", "bios" => "InnoDB", "memories" => "InnoDB", "slots" => "InnoDB", "registry" => "InnoDB", "monitors" => "InnoDB", "ports" => "InnoDB", "storages" => "InnoDB", "drives" => "InnoDB", "inputs" => "InnoDB", "modems" => "InnoDB", "networks" => "InnoDB", "printers" => "InnoDB", "sounds" => "InnoDB", "videos" => "InnoDB", "softwares" => "InnoDB", "accountinfo" => "InnoDB", "netmap" => "InnoDB", "devices" => "InnoDB", "locks" => "HEAP");
    if (is_file("/usr/share/artica-postfix/bin/install/ocsbase_new.sql")) {
        if (!$q->DATABASE_EXISTS("ocsweb")) {
            $execute = true;
        }
        if (!$execute) {
            while (list($table, $ligne) = each($tableEngines)) {
                if (!$q->TABLE_EXISTS($table, "ocsweb")) {
                    $execute = true;
                    break;
                }
            }
        }
    }
    reset($tableEngines);
    if ($execute) {
        $unix = new unix();
        $q->CREATE_DATABASE("ocsweb");
        $mysql = $unix->find_program("mysql");
        $password = $q->mysql_password;
        if (strlen($password) > 0) {
            $password = "******";
        }
        $cmd = "{$mysql} -u {$q->mysql_admin}{$password} --batch -h {$q->mysql_server} -P {$q->mysql_port} -D ocsweb < /usr/share/artica-postfix/bin/install/ocsbase_new.sql";
        exec($cmd, $results);
        exec($cmd, $results);
        exec($cmd, $results);
        while (list($table, $ligne) = each($tableEngines)) {
            if (!$q->TABLE_EXISTS($table, "ocsweb")) {
                $unix->send_email_events("Unable to create OCS table (missing {$table}) table", "{$cmd}\nmysql results\n" . @implode("\n", $results), "system");
                break;
            }
        }
    }
}
コード例 #20
0
ファイル: exec.barnyard.php プロジェクト: articatech/artica
function mysql_checks()
{
    $q = new mysql();
    if (!$q->DATABASE_EXISTS("ids")) {
        $q->CREATE_DATABASE("ids");
        if (!$q->ok) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} MySQL Error {$q->mysql_error}\n";
            }
            return;
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} creating IDS database\n";
        }
    }
    if (!$q->TABLE_EXISTS("schema", "ids")) {
        $q->QUERY_SQL("CREATE TABLE `schema` ( vseq        INT      UNSIGNED NOT NULL,\n\tctime       DATETIME NOT NULL,\n\tPRIMARY KEY (vseq));", "ids");
        $q->QUERY_SQL("INSERT INTO `schema`  (vseq, ctime) VALUES ('107', now());", "ids");
        if (!$q->ok) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} MySQL Error {$q->mysql_error}\n";
            }
            return;
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} creating IDS/schema\n";
        }
    }
    if (!$q->TABLE_EXISTS("event", "ids")) {
        $q->QUERY_SQL("CREATE TABLE event  ( sid \t  INT \t   UNSIGNED NOT NULL,\n\t\tcid \t  INT \t   UNSIGNED NOT NULL,\n\t\tsignature   INT      UNSIGNED NOT NULL,\n\t\ttimestamp \t   DATETIME NOT NULL,\n\t\tPRIMARY KEY (sid,cid),\n\t\tINDEX       sig (signature),\n\t\tINDEX       time (timestamp));", "ids");
        if (!$q->ok) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} MySQL Error {$q->mysql_error}\n";
            }
            return;
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} creating IDS/event\n";
        }
    }
    if (!$q->TABLE_EXISTS("signature", "ids")) {
        $q->QUERY_SQL("CREATE TABLE signature ( sig_id       INT          UNSIGNED NOT NULL AUTO_INCREMENT,\n\tsig_name     VARCHAR(255) NOT NULL,\n\tsig_class_id INT          UNSIGNED NOT NULL,\n\tsig_priority INT          UNSIGNED,\n\tsig_rev      INT          UNSIGNED,\n\tsig_sid      INT          UNSIGNED,\n\tsig_gid      INT          UNSIGNED,\n\tPRIMARY KEY (sig_id),\n\tINDEX   sign_idx (sig_name(20)),\n\tINDEX   sig_class_id_idx (sig_class_id));", "ids");
        if (!$q->ok) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} MySQL Error {$q->mysql_error}\n";
            }
            return;
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} creating IDS/signature\n";
        }
    }
    if (!$q->TABLE_EXISTS("sig_reference", "ids")) {
        $q->QUERY_SQL("CREATE TABLE sig_reference (sig_id  INT    UNSIGNED NOT NULL,\n\t\tref_seq INT    UNSIGNED NOT NULL,\n\t\tref_id  INT    UNSIGNED NOT NULL,\n\t\tPRIMARY KEY(sig_id, ref_seq));", "ids");
        if (!$q->ok) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} MySQL Error {$q->mysql_error}\n";
            }
            return;
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} creating IDS/sig_reference\n";
        }
    }
    if (!$q->TABLE_EXISTS("reference", "ids")) {
        $q->QUERY_SQL("CREATE TABLE reference (  ref_id        INT         UNSIGNED NOT NULL AUTO_INCREMENT,\n\tref_system_id INT         UNSIGNED NOT NULL,\n\tref_tag       TEXT NOT NULL,\n\tPRIMARY KEY (ref_id));", "ids");
        if (!$q->ok) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} MySQL Error {$q->mysql_error}\n";
            }
            return;
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} creating IDS/reference\n";
        }
    }
    if (!$q->TABLE_EXISTS("reference_system", "ids")) {
        $q->QUERY_SQL("CREATE TABLE reference_system ( ref_system_id   INT         UNSIGNED NOT NULL AUTO_INCREMENT,\n\tref_system_name VARCHAR(20),\n\tPRIMARY KEY (ref_system_id));", "ids");
        if ($GLOBALS["OUTPUT"]) {
            echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} creating IDS/reference_system\n";
        }
    }
    if (!$q->TABLE_EXISTS("sig_class", "ids")) {
        $q->QUERY_SQL("CREATE TABLE sig_class ( sig_class_id        INT    UNSIGNED NOT NULL AUTO_INCREMENT,\n\tsig_class_name      VARCHAR(60) NOT NULL,\n\tPRIMARY KEY (sig_class_id),\n\tINDEX       (sig_class_id),\n\tINDEX       (sig_class_name));", "ids");
        if (!$q->ok) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} MySQL Error {$q->mysql_error}\n";
            }
            return;
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} creating IDS/sig_class\n";
        }
    }
    # store info about the sensor supplying data
    if (!$q->TABLE_EXISTS("sensor", "ids")) {
        $q->QUERY_SQL("CREATE TABLE sensor ( sid\t  INT \t   UNSIGNED NOT NULL AUTO_INCREMENT,\n\thostname    TEXT,\n\tinterface   TEXT,\n\tfilter\t  TEXT,\n\tdetail\t  TINYINT,\n\tencoding\t  TINYINT,\n\tlast_cid    INT      UNSIGNED NOT NULL,\n\tPRIMARY KEY (sid));", "ids");
        if (!$q->ok) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} MySQL Error {$q->mysql_error}\n";
            }
            return;
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} creating IDS/sensor\n";
        }
    }
    # All of the fields of an ip header
    if (!$q->TABLE_EXISTS("iphdr", "ids")) {
        $q->QUERY_SQL("CREATE TABLE iphdr  ( sid \t  INT \t   UNSIGNED NOT NULL,\n\tcid \t  INT \t   UNSIGNED NOT NULL,\n\tip_src      INT      UNSIGNED NOT NULL,\n\tip_dst      INT      UNSIGNED NOT NULL,\n\tip_ver      TINYINT  UNSIGNED,\n\tip_hlen     TINYINT  UNSIGNED,\n\tip_tos  \t  TINYINT  UNSIGNED,\n\tip_len \t  SMALLINT UNSIGNED,\n\tip_id    \t  SMALLINT UNSIGNED,\n\tip_flags    TINYINT  UNSIGNED,\n\tip_off      SMALLINT UNSIGNED,\n\tip_ttl   \t  TINYINT  UNSIGNED,\n\tip_proto \t  TINYINT  UNSIGNED NOT NULL,\n\tip_csum \t  SMALLINT UNSIGNED,\n\tPRIMARY KEY (sid,cid),\n\tINDEX ip_src (ip_src),\n\tINDEX ip_dst (ip_dst));", "ids");
        if (!$q->ok) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} MySQL Error {$q->mysql_error}\n";
            }
            return;
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} creating IDS/iphdr\n";
        }
    }
    # All of the fields of a tcp header
    if (!$q->TABLE_EXISTS("tcphdr", "ids")) {
        $q->QUERY_SQL("CREATE TABLE tcphdr(  sid \t  INT \t   UNSIGNED NOT NULL,\n\tcid \t  INT \t   UNSIGNED NOT NULL,\n\ttcp_sport   SMALLINT UNSIGNED NOT NULL,\n\ttcp_dport   SMALLINT UNSIGNED NOT NULL,\n\ttcp_seq     INT      UNSIGNED,\n\ttcp_ack     INT      UNSIGNED,\n\ttcp_off     TINYINT  UNSIGNED,\n\ttcp_res     TINYINT  UNSIGNED,\n\ttcp_flags   TINYINT  UNSIGNED NOT NULL,\n\ttcp_win     SMALLINT UNSIGNED,\n\ttcp_csum    SMALLINT UNSIGNED,\n\ttcp_urp     SMALLINT UNSIGNED,\n\tPRIMARY KEY (sid,cid),\n\tINDEX       tcp_sport (tcp_sport),\n\tINDEX       tcp_dport (tcp_dport),\n\tINDEX       tcp_flags (tcp_flags));", "ids");
        if (!$q->ok) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} MySQL Error {$q->mysql_error}\n";
            }
            return;
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} creating IDS/tcphdr\n";
        }
    }
    # All of the fields of a udp header
    if (!$q->TABLE_EXISTS("udphdr", "ids")) {
        $q->QUERY_SQL("CREATE TABLE udphdr(  sid \t  INT \t   UNSIGNED NOT NULL,\n\tcid \t  INT \t   UNSIGNED NOT NULL,\n\tudp_sport   SMALLINT UNSIGNED NOT NULL,\n\tudp_dport   SMALLINT UNSIGNED NOT NULL,\n\tudp_len     SMALLINT UNSIGNED,\n\tudp_csum    SMALLINT UNSIGNED,\n\tPRIMARY KEY (sid,cid),\n\tINDEX       udp_sport (udp_sport),\n\tINDEX       udp_dport (udp_dport));", "ids");
        if (!$q->ok) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} MySQL Error {$q->mysql_error}\n";
            }
            return;
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} creating IDS/udphdr\n";
        }
    }
    # All of the fields of an icmp header
    if (!$q->TABLE_EXISTS("icmphdr", "ids")) {
        $q->QUERY_SQL("CREATE TABLE icmphdr( sid \t  INT \t   UNSIGNED NOT NULL,\n\tcid \t  INT  \t   UNSIGNED NOT NULL,\n\ticmp_type   TINYINT  UNSIGNED NOT NULL,\n\ticmp_code   TINYINT  UNSIGNED NOT NULL,\n\ticmp_csum   SMALLINT UNSIGNED,\n\ticmp_id     SMALLINT UNSIGNED,\n\ticmp_seq    SMALLINT UNSIGNED,\n\tPRIMARY KEY (sid,cid),\n\tINDEX       icmp_type (icmp_type));", "ids");
        if ($GLOBALS["OUTPUT"]) {
            echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} creating IDS/icmphdr\n";
        }
    }
    # Protocol options
    if (!$q->TABLE_EXISTS("opt", "ids")) {
        $q->QUERY_SQL("CREATE TABLE opt    ( sid         INT      UNSIGNED NOT NULL,\n\tcid         INT      UNSIGNED NOT NULL,\n\toptid       INT      UNSIGNED NOT NULL,\n\topt_proto   TINYINT  UNSIGNED NOT NULL,\n\topt_code    TINYINT  UNSIGNED NOT NULL,\n\topt_len     SMALLINT,\n\topt_data    TEXT,\n\tPRIMARY KEY (sid,cid,optid));", "ids");
        if (!$q->ok) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} MySQL Error {$q->mysql_error}\n";
            }
            return;
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} creating IDS/opt\n";
        }
    }
    # Packet payload
    if (!$q->TABLE_EXISTS("data", "ids")) {
        $q->QUERY_SQL("CREATE TABLE data   ( sid           INT      UNSIGNED NOT NULL,\n\tcid           INT      UNSIGNED NOT NULL,\n\tdata_payload  TEXT,\n\tPRIMARY KEY (sid,cid));", "ids");
        if ($GLOBALS["OUTPUT"]) {
            echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} creating IDS/data\n";
        }
    }
    # encoding is a lookup table for storing encoding types
    if (!$q->TABLE_EXISTS("encoding", "ids")) {
        $q->QUERY_SQL("CREATE TABLE encoding(encoding_type TINYINT UNSIGNED NOT NULL,\n\tencoding_text TEXT NOT NULL,\n\tPRIMARY KEY (encoding_type));", "ids");
        if (!$q->ok) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} MySQL Error {$q->mysql_error}\n";
            }
            return;
        }
        $q->QUERY_SQL("INSERT INTO encoding (encoding_type, encoding_text) VALUES (0, 'hex');", "ids");
        if (!$q->ok) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} MySQL Error {$q->mysql_error}\n";
            }
            return;
        }
        $q->QUERY_SQL("INSERT INTO encoding (encoding_type, encoding_text) VALUES (1, 'base64');", "ids");
        if (!$q->ok) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} MySQL Error {$q->mysql_error}\n";
            }
            return;
        }
        $q->QUERY_SQL("INSERT INTO encoding (encoding_type, encoding_text) VALUES (2, 'ascii');", "ids");
        if (!$q->ok) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} MySQL Error {$q->mysql_error}\n";
            }
            return;
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} creating IDS/encoding\n";
        }
    }
    # detail is a lookup table for storing different detail levels
    if (!$q->TABLE_EXISTS("detail", "ids")) {
        $q->QUERY_SQL("CREATE TABLE detail  (detail_type TINYINT UNSIGNED NOT NULL,\n\tdetail_text TEXT NOT NULL,\n\tPRIMARY KEY (detail_type));", "ids");
        if (!$q->ok) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} MySQL Error {$q->mysql_error}\n";
            }
            return;
        }
        $q->QUERY_SQL("INSERT INTO detail (detail_type, detail_text) VALUES (0, 'fast');", "ids");
        if (!$q->ok) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} MySQL Error {$q->mysql_error}\n";
            }
            return;
        }
        $q->QUERY_SQL("INSERT INTO detail (detail_type, detail_text) VALUES (1, 'full');", "ids");
        if (!$q->ok) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} MySQL Error {$q->mysql_error}\n";
            }
            return;
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Setting.......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} creating IDS/detail\n";
        }
    }
}
コード例 #21
0
function OBM2_INSTALL($servername, $root, $hash = array())
{
    $GLOBALS["ADDLOG"] = "{$GLOBALS["ARTICALOGDIR"]}/{$servername}.log";
    if ($root == null) {
        events("Starting install OBM2 Unable to stat root dir");
        return false;
    }
    if (!is_dir("/opt/artica/install/sources/obm")) {
        events("Starting install OBM2 Unable to stat /opt/artica/install/sources/obm");
        return false;
    }
    $sqlfiles = array("create_obmdb_2.3.mysql.sql", "obmdb_prefs_values_2.3.sql", "obmdb_default_values_2.3.sql", "obmdb_test_values_2.3.sql", "data-fr/obmdb_nafcode_2.3.sql", "data-fr/obmdb_ref_2.3.sql", "data-en/obmdb_nafcode_2.3.sql", "data-en/obmdb_ref_2.3.sql");
    $user = $hash["wwwmysqluser"][0];
    $mysql_password = $hash[strtolower("WWWMysqlPassword")][0];
    $appli_user = $hash["wwwappliuser"];
    $appli_password = $hash["wwwapplipassword"];
    if ($user == null) {
        events("Starting install OBM2 Unable to stat Mysql username");
        return false;
    }
    if ($mysql_password == null) {
        events("Starting install OBM2 Unable to stat Mysql password");
        return false;
    }
    @mkdir($root, 0755, true);
    $server_database = str_replace(".", "_", $servername);
    $server_database = str_replace("-", "_", $server_database);
    $q = new mysql();
    if (!$q->DATABASE_EXISTS($server_database)) {
        events("Starting install OBM2 sub-system mysql database {$server_database}...");
        $q->CREATE_DATABASE($server_database);
        if (!$q->DATABASE_EXISTS($server_database)) {
            events("Starting install OBM2 unable to create MYSQL Database");
            return false;
        }
    }
    events("Starting install OBM2 installing source code in {$root}");
    shell_exec("/bin/cp -rf /opt/artica/install/sources/obm/* {$root}/");
    if ($q->mysql_password != null) {
        $password = "******";
    } else {
        events("Starting install OBM2 installing tables datas with null password");
    }
    $unix = new unix();
    //<$sql_file
    $cmd = $unix->find_program("mysql") . " --port={$q->mysql_port} --skip-column-names --database={$server_database} --silent --xml ";
    $cmd = $cmd . " --user={$q->mysql_admin}{$password}";
    if (!OBM2_CheckObmTables($server_database)) {
        while (list($num, $filesql) = each($sqlfiles)) {
            if (is_file("/opt/artica/install/sources/obm/scripts/2.3/{$filesql}")) {
                events("installing {$filesql} SQL commands");
                shell_exec($cmd . " </opt/artica/install/sources/obm/scripts/2.3/{$filesql}");
            }
        }
    }
    $version = OBM2_VERSION($root);
    if ($version == null) {
        events("Starting install unable to stat version");
        return false;
    }
    events("Starting install OBM2 version {$version}");
    if (is_file("{$root}/scripts/2.3/updates/update-2.3.1-{$version}.mysql.sql")) {
        events("Starting updating OBM2 version 2.3.1-{$version}");
        shell_exec($cmd . " <{$root}/scripts/2.3/updates/update-2.3.1-{$version}.mysql.sql");
    } else {
        events("Starting updating unable to stat {$root}/scripts/2.3/updates/update-2.3.1-{$version}.mysql.sql");
    }
    //scripts/2.3/updates/update-2.3.1-2.3.2.mysql.sql
    $q->PRIVILEGES($user, $mysql_password, $server_database);
    OBM2_INSTALL_SCRIPTS($root, $servername, $server_database, $user, $mysql_password);
}
コード例 #22
0
ファイル: exec.openemm.php プロジェクト: BillTheBest/1.6.x
function checkdb()
{
    $unix = new unix();
    $q = new mysql();
    $JAVA_HOME = $unix->JAVA_HOME_GET();
    if (strlen($JAVA_HOME) == 0) {
        echo "Starting......: " . date("H:i:s") . " OpenEMM JAVA_HOME failed\n";
        return;
    }
    echo "Starting......: " . date("H:i:s") . " OpenEMM JAVA_HOME {$JAVA_HOME}\n";
    if (!is_file("/home/openemm/bin/openemm.sh")) {
        echo "Starting......: " . date("H:i:s") . " OpenEMM /home/openemm/bin/openemm.sh no such file\n";
        return;
    }
    if (!is_file("/opt/openemm/tomcat6/bin/startup.sh")) {
        echo "Starting......: " . date("H:i:s") . " OpenEMM tomcat 6.x is not installed\n";
        return;
    }
    if (!$q->DATABASE_EXISTS("openemm")) {
        $q->CREATE_DATABASE("openemm");
    }
    if (!$q->DATABASE_EXISTS("openemm")) {
        echo "Starting......: " . date("H:i:s") . " OpenEMM failed creating database openemm\n";
        return;
    }
    echo "Starting......: " . date("H:i:s") . " OpenEMM database openemm OK\n";
    if (!$q->DATABASE_EXISTS("openemm_cms")) {
        $q->CREATE_DATABASE("openemm_cms");
    }
    if (!$q->DATABASE_EXISTS("openemm_cms")) {
        echo "Starting......: " . date("H:i:s") . " OpenEMM failed creating database openemm_cms\n";
        return;
    }
    if (!test_cms_tables()) {
        if (is_file("/home/openemm/USR_SHARE/openemm_cms-2011.sql")) {
            $mysql = $unix->find_program("mysql");
            $cmd = "{$mysql} -u {$q->mysql_admin} -p\"{$q->mysql_password}\" --batch --database=openemm_cms < /home/openemm/USR_SHARE/openemm_cms-2011.sql";
            shell_exec($cmd);
        }
    }
    if (!testtables()) {
        $mysql = $unix->find_program("mysql");
        if (is_file("/home/openemm/USR_SHARE/openemm-2011.sql")) {
            $cmd = "{$mysql} -u {$q->mysql_admin} -p\"{$q->mysql_password}\" --batch --database=openemm < /home/openemm/USR_SHARE/openemm-2011.sql";
            shell_exec($cmd);
        }
    }
    if (!testtables()) {
        echo "Starting......: " . date("H:i:s") . " OpenEMM failed creating openemm tables\n";
        return;
    }
    if (!test_cms_tables()) {
        echo "Starting......: " . date("H:i:s") . " OpenEMM failed creating openemm_cms tables\n";
        return;
    }
    echo "Starting......: " . date("H:i:s") . " OpenEMM tables in openemm base OK\n";
    echo "Starting......: " . date("H:i:s") . " OpenEMM tables in openemm_cms base OK\n";
    if (!$unix->CreateUnixUser("openemm")) {
        echo "Starting......: " . date("H:i:s") . " OpenEMM unix user openemm failed\n";
        return;
    }
    echo "Starting......: " . date("H:i:s") . " OpenEMM unix user openemm OK\n";
    patch_javahome($JAVA_HOME);
    patch_tomcat_dir("/opt/openemm/tomcat6");
    if (!is_dir("/home/openemm/logs")) {
        echo "Starting......: " . date("H:i:s") . " OpenEMM creating /home/openemm/logs directory\n";
        @mkdir("/home/openemm/logs", 0755, true);
    }
    $aa_complain = $unix->find_program("aa-complain");
    if (is_file($aa_complain)) {
        shell_exec("{$aa_complain} {$JAVA_HOME}/bin/java");
    }
    if (!is_file("/home/openemm/webapps/openemm/WEB-INF/classes/messages_en_US.properties")) {
        shell_exec("/bin/cp /home/openemm/webapps/openemm/WEB-INF/classes/messages_en.properties /home/openemm/webapps/openemm/WEB-INF/classes/messages_en_US.properties");
    }
    cms_properties();
    if (!is_dir("/home/openemm/work/Catalina/openemm/_")) {
        @mkdir("/home/openemm/work/Catalina/openemm/_", 0755, true);
    }
    shell_exec("/bin/chown openemm /home/openemm");
    shell_exec("/bin/chown -R openemm /home/openemm");
    if (is_numeric(is_tomcat_running())) {
        echo "Starting......: " . date("H:i:s") . " OpenEMM stopping tomcat first...\n";
        shell_exec("/etc/init.d/artica-postfix stop tomcat");
    }
    @unlink("/home/openemm/logs/catalina.out");
    @unlink("/home/openemm/logs/openemm/openemm_axis.log");
    @unlink("/home/openemm/logs/openemm/openemm_axis.log");
    @unlink("/home/openemm/logs/openemm/openemm_core.log");
    @unlink("/home/openemm/logs/openemm/userlogs.log");
}
コード例 #23
0
function SAVE_FREEWEB_MYSQL()
{
    $servername = trim(strtolower($_POST["servername"]));
    if (substr($servername, 0, 1) == '.') {
        echo $servername . " FAILED\n";
        return;
    }
    $users = new usersMenus();
    $sock = new sockets();
    $FreewebsStorageDirectory = $sock->GET_INFO("FreewebsStorageDirectory");
    if (!$users->AsWebMaster) {
        return "FALSE";
    }
    $uid = $_POST["uid"];
    $mysql_database = format_mysql_table($_POST["mysql_database"]);
    $mysql_password = $_POST["mysql_password"];
    $mysql_username = $_POST["mysql_username"];
    $lvm_vg = $_POST["lvm_vg"];
    $vg_size = $_POST["vg_size"];
    $ServerIP = $_POST["ServerIP"];
    $ServerPort = 0;
    if (preg_match("#(.+?):([0-9]+)#", $ServerIP, $re)) {
        $ServerIP = $re[1];
        $ServerPort = $re[2];
    }
    if (!is_numeric($vg_size)) {
        $vg_size = 5000;
    }
    $ftpuser = $_POST["ftpuser"];
    $ftppassword = $_POST["ftppassword"];
    $useSSL = $_POST["useSSL"];
    if (!$users->PUREFTP_INSTALLED) {
        $_POST["useFTP"] = 0;
        $ftpuser = null;
        $ftppassword = null;
    }
    if ($_POST["useFTP"] == 1) {
        if ($ftpuser == null) {
            $_POST["useFTP"] = 0;
            $ftpuser = null;
            $ftppassword = null;
        }
    }
    $sql = "SELECT servername FROM freeweb WHERE servername='{$_POST["servername"]}'";
    $q = new mysql();
    $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, 'artica_backup'));
    if ($ligne["servername"] != null) {
        if ($uid != null) {
            $u = new user($uid);
            $ou = $u->ou;
        }
        if (!$users->AsSystemAdministrator) {
            $ou = $_SESSION["ou"];
        }
        $sql = "UPDATE freeweb SET \n\t\t\tmysql_password='******',\n\t\t\tmysql_username='******',\n\t\t\tmysql_database='{$mysql_database}',\n\t\t\tmysql_instance_id='{$_POST["mysql_instance_id"]}',\n\t\t\tftpuser='******',\n\t\t\tftppassword='******',\n\t\t\tuseMysql='{$_POST["useMysql"]}',\n\t\t\tuseFTP='{$_POST["useFTP"]}'\n\t\t\tWHERE servername='{$servername}'\n\t\t";
    }
    writelogs("{$sql}", __FUNCTION__, __FILE__, __LINE__);
    $q = new mysql();
    $q->BuildTables();
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        if (preg_match("#Unknown column#i", $q->mysql_error)) {
            $q->BuildTables();
            $q->QUERY_SQL($sql, "artica_backup");
        }
    }
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    $sock = new sockets();
    if ($_POST["useFTP"] == 1) {
        if ($users->PUREFTP_INSTALLED) {
            if (trim($ftpuser) != null) {
                if (trim($ftppassword) != null) {
                    $pure = new pureftpd_user();
                    if (!$pure->CreateUser($ftpuser, $ftppassword, $servername)) {
                        echo "FTP: Failed\n";
                        return;
                    }
                    $sock->getFrameWork("services.php?reload-pure-ftpd=yes");
                }
            }
        }
    }
    if ($_POST["useMysql"] == 1) {
        if (!$q->DATABASE_EXISTS($mysql_database)) {
            $q->CREATE_DATABASE("{$mysql_database}");
        }
        if (!$q->PRIVILEGES($mysql_username, $mysql_password, $mysql_database)) {
            echo "GRANT {$mysql_database} FAILED FOR {$mysql_username}\n{$q->mysql_error}";
        }
    }
    if (isset($_POST["ADD_DNS_ENTRY"])) {
        $dnsDOM = explode(".", $_POST["servername"]);
        $netbiosname = $dnsDOM[0];
        unset($dnsDOM[0]);
        $domainname = implode(".", $dnsDOM);
        include_once dirname(__FILE__) . "/ressources/class.pdns.inc";
        $pdns = new pdns($domainname);
        $pdns->EditIPName($netbiosname, $_POST["ADD_DNS_ENTRY"], "A");
    }
    if ($ligne["servername"] == null) {
        if ($_POST["force-groupware"] != null) {
            $sql = "INSERT INTO drupal_queue_orders(`ORDER`,`servername`) VALUES('INSTALL_GROUPWARE','{$servername}')";
            $q = new mysql();
            $q->QUERY_SQL($sql, "artica_backup");
            $sock->getFrameWork("freeweb.php?rebuild-vhost=yes&servername={$servername}");
        }
    }
    $sock->getFrameWork("services.php?freeweb-start=yes");
    sleep(2);
    $sock->getFrameWork("cmd.php?freeweb-restart=yes");
}
コード例 #24
0
ファイル: admin.index.php プロジェクト: BillTheBest/1.6.x
function status_mysql()
{
    $tpl = new templates();
    $q = new mysql();
    $sock = new sockets();
    $page = CurrentPageName();
    include_once dirname(__FILE__) . "/ressources/class.mysql.syslogs.inc";
    $EnableSyslogDB = $sock->GET_INFO("EnableSyslogDB");
    if (!is_numeric($EnableSyslogDB)) {
        $EnableSyslogDB = 0;
    }
    $MySQLSyslogType = $sock->GET_INFO("MySQLSyslogType");
    $MySqlMemoryCheck = $sock->GET_INFO("MySqlMemoryCheck");
    if (!is_numeric($MySqlMemoryCheck)) {
        $MySqlMemoryCheck = 0;
    }
    if ($MySqlMemoryCheck == 0) {
        $status_computer_mysql_memory_check = status_computer_mysql_memory_check();
        if ($status_computer_mysql_memory_check != null) {
            $status_computer_mysql_memory_check = $status_computer_mysql_memory_check . "<br>";
        }
    }
    if (is_file("ressources/logs/zarafa.notify.MySQLIssue")) {
        echo "<center>" . $tpl->_ENGINE_parse_body(Paragraphe('danger64.png', "{ZARAFA_ISSUE}", @file_get_contents("ressources/logs/zarafa.notify.MySQLIssue"), null, null, 420, 80)) . "</center>";
    }
    if (is_file("ressources/logs/zarafa.notify.licenseover")) {
        echo "<center>" . $tpl->_ENGINE_parse_body(Paragraphe('danger64.png', "{ZARAFA_ISSUE}", @file_get_contents("ressources/logs/zarafa.notify.licenseover"), null, null, 420, 80)) . "</center>";
    }
    $sql = "SELECT count(*) FROM admin_cnx";
    OutputDebugVerbose($sql);
    $q = new mysql();
    $q->QUERY_SQL($sql, "artica_events");
    if (!$q->ok) {
        if (preg_match("#Access denied for user#", $q->mysql_error)) {
            $error = urlencode(base64_encode("{$q->mysql_error}"));
            return "\n\t\t\t{$status_computer_mysql_memory_check}\n\t\t\t<script>\n\t\t\t\tLoadjs('admin.mysql.error.php?error={$error}',true);\n\t\t\t</script>\n\t\t\t";
        }
        if (preg_match("#Unknown database.+?artica_.+?#", $q->mysql_error)) {
            $q->CREATE_DATABASE("artica_events");
            $q->QUERY_SQL($sql, "artica_events");
        }
        if (preg_match("#Unknown database.+?artica_.+?#", $q->mysql_error)) {
            $q->BuildTables();
            $q = new mysql();
            $sql = "SELECT count(*) FROM admin_cnx";
            $q->QUERY_SQL($sql, "artica_events");
            if (!$q->ok) {
                $t2 = time();
                $error = urlencode(base64_encode($q->mysql_error));
                return $status_computer_mysql_memory_check . "<center>" . $tpl->_ENGINE_parse_body(Paragraphe('danger64.png', "{mysql_error} [" . __LINE__ . "]", "{$q->mysql_error}", "javascript:Loadjs('admin.mysql.restart.progress.php');", "{$q->mysql_error}", 420, 80)) . "</center>\n\t\t\t\t<br>\n\t\t\t\t<script>\n\t\t\t\t\tfunction RefreshMySQL{$t2}(){ LoadAjaxTiny('admin-index-status-mysql','{$page}?admin-index-status-mysql=yes'); }\n\t\t\t\t\tsetTimeout('RefreshMySQL{$t2}()',5000);\n\t\t\t\t</script>\n\t\t\t\t\n\t\t\t\t";
                return;
            }
        }
        if (preg_match("#table.+?admin_cnx.+?doesn.*?exist#i", $q->mysql_error)) {
            $q = new mysql();
            $q->BuildTables();
            $sql = "SELECT count(*) FROM admin_cnx";
            $q->QUERY_SQL($sql, "artica_events");
            if (!$q->ok) {
                return $status_computer_mysql_memory_check . "<center>" . $tpl->_ENGINE_parse_body(Paragraphe('danger64.png', "{mysql_error} [" . __LINE__ . "]", "{$q->mysql_error}", "javascript:Loadjs('admin.mysql.restart.progress.php')", "{$q->mysql_error}", 420, 80)) . "</center><br>";
                return;
            }
        }
        if (trim($q->mysql_error) != null) {
            $t2 = time();
            $error = urlencode(base64_encode($q->mysql_error));
            return $status_computer_mysql_memory_check . "\n\t\t\t\t<center>" . RoundedLightGrey($tpl->_ENGINE_parse_body(Paragraphe('danger64.png', "nowrap:{mysql_error} [" . __LINE__ . "]", "\n\t\t\t\t\t\t{$q->mysql_error}<br>{please_wait}...", "javascript:Loadjs('admin.mysql.restart.progress.php');", "{$q->mysql_error}", 330, 80))) . "\n\t\t\t\t</center>\n\t\t\t\t<script>\n\t\t\t\t\tfunction RefreshMySQL{$t2}(){\n\t\t\t\t\t\tLoadAjaxTiny('admin-index-status-mysql','{$page}?admin-index-status-mysql=yes');\n\t\t\t\t\t}\n\t\t\t\t\tsetTimeout('RefreshMySQL{$t2}()',5000);\n\t\t\t\t</script>\n\t\t\t\t<br>";
        }
    }
    return $status_computer_mysql_memory_check;
}
コード例 #25
0
ファイル: exec.wordpress.php プロジェクト: brucewu16899/1.6.x
function duplicate_wordpress($servername)
{
    $unix = new unix();
    $q = new mysql();
    $free = new freeweb($servername);
    $WORKING_DIRECTORY = $free->www_dir;
    if ($free->groupware_duplicate == null) {
        build_progress("{$servername}: {duplicate} {$servername} no duplicate set...", 42);
        sleep(2);
        return false;
    }
    $free2 = new freeweb($free->groupware_duplicate);
    if ($free2->mysql_database == null) {
        echo "Fatal: {$free->groupware_duplicate} did not have any such DB set, try to find it..\n";
        $free2->mysql_database = $free2->CreateDatabaseName();
        echo "Fatal: {$free->groupware_duplicate} = {$free2->mysql_database}\n";
    }
    if (!$q->DATABASE_EXISTS($free2->mysql_database, true)) {
        build_progress("{$servername}: {duplicate} {$free->groupware_duplicate} did not have any database...", 42);
        sleep(2);
        return false;
    }
    $srcdir = $free2->www_dir;
    $Mysqlpassword = null;
    $cp = $unix->find_program("cp");
    $rm = $unix->find_program("rm");
    if (@is_link($WORKING_DIRECTORY)) {
        $WORKING_DIRECTORY = @readlink($WORKING_DIRECTORY);
    }
    if (is_dir($WORKING_DIRECTORY)) {
        build_progress("{$servername}: {removing} {$WORKING_DIRECTORY}...", 42);
        sleep(2);
        shell_exec("{$rm} -rf {$WORKING_DIRECTORY}/*");
    }
    @mkdir($WORKING_DIRECTORY, 0755, true);
    build_progress("{$servername}: {installing} {from} {$srcdir}...", 42);
    shell_exec("{$cp} -rf {$srcdir}/* {$WORKING_DIRECTORY}/");
    $wordpressDB = $free->mysql_database;
    if ($wordpressDB == null) {
        $wordpressDB = $free->CreateDatabaseName();
    }
    if ($q->DATABASE_EXISTS($wordpressDB)) {
        build_progress("{$servername}: {remove_database} {$wordpressDB}...", 42);
        sleep(2);
        if (!$q->DELETE_DATABASE($wordpressDB)) {
            build_progress("{$servername}: {remove_database} {$wordpressDB} {failed}...", 42);
            return false;
        }
        if (!$q->CREATE_DATABASE($wordpressDB, true)) {
            build_progress("{$servername}: {create_database} {$wordpressDB} {failed}...", 42);
            return false;
        }
    }
    if (!$q->DATABASE_EXISTS($wordpressDB)) {
        if (!$q->CREATE_DATABASE($wordpressDB, true)) {
            build_progress("{$servername}: {create_database} {$wordpressDB} {failed}...", 42);
            return false;
        }
    }
    build_progress("{$servername}: {backup_database} {from} {$free2->mysql_database}...", 42);
    $mysqldump = $unix->find_program("mysqldump");
    $q = new mysql();
    if ($q->mysql_password != null) {
        $Mysqlpassword = "******" . $unix->shellEscapeChars($q->mysql_password);
    }
    $t = time();
    $TMP_FILE = $unix->FILE_TEMP();
    $cmdline = trim("{$mysqldump} --add-drop-table --single-transaction --force --insert-ignore -S /var/run/mysqld/mysqld.sock -u {$q->mysql_admin}{$Mysqlpassword} {$free2->mysql_database} >{$TMP_FILE} 2>&1");
    if ($GLOBALS["VERBOSE"]) {
        echo "{$cmdline}\n";
    }
    $results = array();
    exec($cmdline, $results);
    while (list($num, $ligne) = each($results)) {
        echo "{$ligne}\n";
        if (preg_match("#ERROR\\s+([0-9]+)#", $ligne)) {
            build_progress("{$servername}: {restore_database} {to} {$wordpressDB} {failed}..", 42);
            sleep(3);
            return false;
        }
    }
    build_progress("{$servername}: {restore_database} {to} {$wordpressDB}..", 42);
    $mysqlbin = $unix->find_program("mysql");
    $cmd = "{$mysqlbin} --batch --force -S /var/run/mysqld/mysqld.sock -u {$q->mysql_admin}{$Mysqlpassword} --database={$wordpressDB} <{$TMP_FILE} 2>&1";
    if ($GLOBALS["VERBOSE"]) {
        echo "{$cmd}\n";
    }
    exec($cmd, $results);
    while (list($num, $ligne) = each($results)) {
        echo "{$ligne}\n";
        if (preg_match("#ERROR\\s+([0-9]+)#", $ligne)) {
            build_progress("{$servername}: {restore_database} {to} {$wordpressDB} {failed}..", 42);
            sleep(3);
            return false;
        }
    }
    build_progress("{$servername}: {restore_database} {to} {$wordpressDB}..{done}", 42);
    @unlink($TMP_FILE);
    if (!scan($WORKING_DIRECTORY)) {
        build_progress("{$servername}: {install} {failed}", 42);
        sleep(3);
        return false;
    }
    $proto = "http";
    if ($free->useSSL == 1) {
        $proto = "https";
    }
    $sql = "UPDATE `wp_options` SET `option_value`='{$proto}://{$servername}' WHERE `option_name`='siteurl'";
    $q->QUERY_SQL($sql, $wordpressDB);
    if (!$q->ok) {
        echo $q->mysql_error;
        build_progress("{$servername}: {install} {failed}", 42);
        sleep(3);
        return false;
    }
    $sql = "UPDATE `wp_options` SET `option_value`='{$proto}://{$servername}' WHERE `option_name`='home'";
    $q->QUERY_SQL($sql, $wordpressDB);
    if (!$q->ok) {
        echo $q->mysql_error;
        build_progress("{$servername}: {install} {failed}", 42);
        sleep(3);
        return false;
    }
    $free->groupware_duplicate = null;
    $free->CreateSite(true);
    return true;
}
コード例 #26
0
function transfert_tomysql()
{
    $q = new mysql_squid_builder();
    $unix = new unix();
    $mysqldump = $unix->find_program("mysqldump");
    $mysql = $unix->find_program("mysql");
    if ($q->mysql_password != null) {
        $password = "******" . $unix->shellEscapeChars($q->mysql_password);
    }
    $prefix = trim("{$mysqldump} --add-drop-table --force --single-transaction --insert-ignore -S /var/run/mysqld/squid-db.sock -u {$q->mysql_admin}{$password} squidlogs");
    build_progress("{exporting}", 10);
    shell_exec("{$prefix} >/home/toMysql.sql");
    $q = new mysql();
    build_progress("{creating_database}", 15);
    $q->CREATE_DATABASE("squidlogs");
    if (!$q->ok) {
        build_progress("{creating_database} {failed}", 15);
        return;
    }
    system("{$mysql} -e \"CREATE DATABASE IF NOT EXISTS squidlogs\"");
    $MYSQL_CMDLINES = $q->MYSQL_CMDLINES;
    $MYSQL_CMDLINES = "{$mysql} {$MYSQL_CMDLINES} squidlogs < /home/toMysql.sql";
    build_progress("{importing}", 20);
    system($MYSQL_CMDLINES);
    return true;
}
コード例 #27
0
 private function autoinstall()
 {
     $q = new mysql();
     writelogs("FREEWEB: running autoinstall()", __CLASS__ . '/' . __FUNCTION__, __FILE__, __LINE__);
     if (!$q->DATABASE_EXISTS($this->database)) {
         writelogs("[{$this->servername}] DATABASE DOES NOT EXISTS Create e new one", __CLASS__ . '/' . __FUNCTION__, __FILE__, __LINE__);
         $q->CREATE_DATABASE($this->database);
     }
     global $GO_LANGUAGE, $lang, $GO_EVENTS;
     require "{$this->www_dir}/Group-Office.php";
     require_once "{$this->www_dir}/classes/filesystem.class.inc";
     require_once "{$this->www_dir}/install/gotest.php";
     include_once "{$this->www_dir}/classes/base/events.class.inc.php";
     require "{$this->www_dir}/language/languages.inc.php";
     require "{$this->www_dir}/install/sql/updates.inc.php";
     require_once "{$this->www_dir}/classes/base/users.class.inc.php";
     require_once "{$this->www_dir}/classes/base/groups.class.inc.php";
     require $GO_LANGUAGE->get_base_language_file('countries');
     require_once "{$this->www_dir}/classes/base/theme.class.inc.php";
     $GO_THEME = new GO_THEME();
     $db = new db();
     $GO_EVENTS = new GO_EVENTS();
     $GO_CONFIG->save_setting('version', count($updates));
     $GO_LANGUAGE->set_language($GO_CONFIG->language);
     $GO_USERS = new GO_USERS();
     $user['id'] = $GO_USERS->nextid("go_users");
     echo "Starting......: " . date("H:i:s") . " Apache \"{$this->servername}\" userid \"{$user['id']}\"\n";
     $GO_GROUPS = new GO_GROUPS();
     $GO_GROUPS->query("DELETE FROM go_db_sequence WHERE seq_name='groups'");
     $GO_GROUPS->query("DELETE FROM go_groups");
     $admin_group_id = $GO_GROUPS->add_group(1, $lang['common']['group_admins']);
     $everyone_group_id = $GO_GROUPS->add_group(1, $lang['common']['group_everyone']);
     $internal_group_id = $GO_GROUPS->add_group(1, $lang['common']['group_internal']);
     $GO_MODULES->load_modules();
     require_once "{$this->www_dir}/install/upgrade.php";
     $fs = new filesystem();
     $module_folders = $fs->get_folders($GO_CONFIG->root_path . 'modules/');
     $available_modules = array();
     foreach ($module_folders as $folder) {
         if (!file_exists($folder['path'] . '/install/noautoinstall')) {
             echo "Starting......: " . date("H:i:s") . " Apache \"{$this->servername}\" checking module {$folder['name']}\n";
             $available_modules[] = $folder['name'];
         }
     }
     $priority_modules = array('summary', 'email', 'calendar', 'tasks', 'addressbook', 'files', 'notes', 'projects', 'ldapauth');
     for ($i = 0; $i < count($priority_modules); $i++) {
         if (in_array($priority_modules[$i], $available_modules)) {
             echo "Starting......: " . date("H:i:s") . " Apache \"{$this->servername}\" add module \"{$priority_modules[$i]}\" [" . $i . "/" . count($priority_modules) . "]\n";
             $GO_MODULES->add_module($priority_modules[$i]);
         }
     }
     for ($i = 0; $i < count($available_modules); $i++) {
         if (!in_array($available_modules[$i], $priority_modules)) {
             if ($available_modules[$i] == "mailings") {
                 continue;
             }
             /*
             if($available_modules[$i]=="blacklist"){continue;}
             if($available_modules[$i]=="search"){continue;}
             if($available_modules[$i]=="modules"){continue;}
             //if($available_modules[$i]=="users"){continue;}
             //if($available_modules[$i]=="comments"){continue;}
             //if($available_modules[$i]=="sieve"){continue;}
             //if($available_modules[$i]=="bookmarks"){continue;}
             //if($available_modules[$i]=="links"){continue;}
             */
             echo "Starting......: " . date("H:i:s") . " Apache \"{$this->servername}\" add module \"{$available_modules[$i]}\" [" . $i . "/" . count($available_modules) . "]\n";
             try {
                 $GO_MODULES->add_module($available_modules[$i]);
             } catch (Exception $e) {
                 echo "Starting......: " . date("H:i:s") . " Apache \"{$this->servername}\" failed adding \"{$available_modules[$i]}\" module\n";
             }
         }
     }
     writelogs("Adding LDAPAUTH Module GO_MODULES->add_module('ldapauth')", __CLASS__ . '/' . __FUNCTION__, __FILE__, __LINE__);
     $GO_MODULES->add_module('ldapauth');
     echo "Starting......: " . date("H:i:s") . " Apache \"{$this->servername}\" save_setting upgrade_mtime\n";
     $GO_CONFIG->save_setting('upgrade_mtime', $GO_CONFIG->mtime);
     if ($this->uid != null) {
         $u = new user($this->uid);
         $password = $u->password;
         $mail = $u->mail;
         $uid = $this->uid;
         writelogs("Adding {$this->uid}/{$u->password}/{$mail} Module GO_USERS->add_user", __CLASS__ . '/' . __FUNCTION__, __FILE__, __LINE__);
     } else {
         $ldap = new clladp();
         $uid = $ldap->ldap_admin;
         $password = $ldap->ldap_password;
         $mail = "*****@*****.**";
     }
     $GO_USERS->nextid('go_users');
     writelogs("Starting......: " . date("H:i:s") . " Apache \"{$this->servername}\" adding \"{$uid}\" language {$GO_LANGUAGE->language} user {$mail}", __CLASS__ . '/' . __FUNCTION__, __FILE__, __LINE__);
     $user['id'] = 1;
     $user['language'] = $GO_LANGUAGE->language;
     $user['first_name'] = $GO_CONFIG->product_name;
     $user['middle_name'] = '';
     $user['last_name'] = "en";
     $user['username'] = "******";
     $user['password'] = "******";
     $user['email'] = "{$mail}";
     $user['sex'] = 'M';
     $user['enabled'] = '1';
     $user['country'] = $GO_CONFIG->default_country;
     $user['work_country'] = $GO_CONFIG->default_country;
     //$GO_USERS->debug=true;
     $GO_USERS->add_user($user, array(1, 2, 3), array($GO_CONFIG->group_everyone));
     writelogs("Starting......: " . date("H:i:s") . " Apache installtion of group office success", __CLASS__ . '/' . __FUNCTION__, __FILE__, __LINE__);
 }
コード例 #28
0
ファイル: freeweb.edit.php プロジェクト: articatech/artica
function Save()
{
    $servername = trim(strtolower($_GET["servername"]));
    if (substr($servername, 0, 1) == '.') {
        echo $servername . " FAILED\n";
        return;
    }
    $users = new usersMenus();
    $sock = new sockets();
    $tpl = new templates();
    $FreewebsStorageDirectory = $sock->GET_INFO("FreewebsStorageDirectory");
    if (!$users->AsWebMaster) {
        return "FALSE";
    }
    $uid = $_GET["uid"];
    $mysql_database = format_mysql_table($_GET["mysql_database"]);
    $mysql_password = $_GET["mysql_password"];
    $mysql_username = $_GET["mysql_username"];
    $lvm_vg = $_GET["lvm_vg"];
    $vg_size = $_GET["vg_size"];
    $ServerIP = $_GET["ServerIP"];
    $ServerPort = 0;
    if (preg_match("#(.+?):([0-9]+)#", $ServerIP, $re)) {
        $ServerIP = $re[1];
        $ServerPort = $re[2];
    }
    if (!is_numeric($vg_size)) {
        $vg_size = 5000;
    }
    $ftpuser = $_GET["ftpuser"];
    $ftppassword = $_GET["ftppassword"];
    $useSSL = $_GET["useSSL"];
    if (!$users->PUREFTP_INSTALLED) {
        $_GET["useFTP"] = 0;
        $ftpuser = null;
        $ftppassword = null;
    }
    $sql = "SELECT servername FROM freeweb WHERE servername='{$_GET["servername"]}'";
    $q = new mysql();
    $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, 'artica_backup'));
    if ($ligne["servername"] != null) {
        if ($uid != null) {
            $u = new user($uid);
            $ou = $u->ou;
        }
        if (!$users->AsSystemAdministrator) {
            $ou = $_SESSION["ou"];
        }
        $sql = "UPDATE freeweb SET \n\t\t\tmysql_password='******',\n\t\t\tmysql_username='******',\n\t\t\tmysql_database='{$mysql_database}',\n\t\t\tmysql_instance_id='{$_GET["mysql_instance_id"]}',\n\t\t\tftpuser='******',\n\t\t\tftppassword='******',\n\t\t\tuid='{$uid}',\n\t\t\tgpid='{$_GET["gpid"]}',\n\t\t\tuseMysql='{$_GET["useMysql"]}',\n\t\t\tuseFTP='{$_GET["useFTP"]}',\n\t\t\tlvm_vg='{$_GET["lvm_vg"]}',\n\t\t\tlvm_size='{$_GET["vg_size"]}',\n\t\t\tUseLoopDisk='{$_GET["UseLoopDisk"]}',\n\t\t\tLoopMounts='{$_GET["LoopMounts"]}',\n\t\t\twww_dir='{$_GET["www_dir"]}',\n\t\t\tUseReverseProxy='{$_GET["UseReverseProxy"]}',\n\t\t\tProxyPass='******',\n\t\t\tuseSSL='{$useSSL}',\n\t\t\tServerPort='{$ServerPort}',\n\t\t\tou='{$ou}',\n\t\t\tForwarder='{$_GET["Forwarder"]}',\n\t\t\tForwardTo='{$_GET["ForwardTo"]}',\n\t\t\tServerIP='{$ServerIP}'\n\t\t\tWHERE servername='{$servername}'\n\t\t";
    } else {
        $ApacheServerName = $sock->GET_INFO("ApacheServerName");
        if ($ApacheServerName == null) {
            $ApacheServerName = $users->fqdn;
        }
        if ($uid != null) {
            $u = new user($uid);
            $ou = $u->ou;
        }
        if ($ou != null) {
            if ($FreewebsStorageDirectory != null) {
                $www_dir = "{$FreewebsStorageDirectory}/{$servername}";
            }
        }
        $sock = new sockets();
        $servername = str_replace('..', '.', $servername);
        $servername = str_replace('/', '.', $servername);
        $servername = str_replace('\\', '.', $servername);
        $servername = str_replace(' ', '.', $servername);
        $servername = str_replace('$', '.', $servername);
        $servername = str_replace('#', '.', $servername);
        $servername = str_replace('%', '.', $servername);
        $servername = str_replace('*', '.', $servername);
        if (substr($servername, strlen($servername) - 1, 1) == '.') {
            $servername = substr($servername, 0, strlen($servername) - 1);
        }
        if (substr($servername, 0, 1) == '.') {
            $servername = substr($servername, 1, strlen($servername));
        }
        if ($servername == $ApacheServerName) {
            echo $tpl->javascript_parse_text("{virtual_hostname_cannot_same_main_hostname}", 1);
            return;
        }
        if ($_GET["force-groupware"] != null) {
            $groupware_field = ",groupware";
            $groupware_value = ",'{$_GET["force-groupware"]}'";
        }
        if ($_GET["www_dir"] != null) {
            $www_dir_field = ",www_dir";
            $www_dir_value = ",'{$_GET["www_dir"]}'";
        }
        $sock->getFrameWork("freeweb.php?force-resolv=yes");
        $sql = "INSERT INTO freeweb (mysql_password,mysql_username,ftpuser,ftppassword,useSSL,servername,mysql_database,\n\t\tuid,gpid,useMysql,useFTP,lvm_vg,lvm_size,UseLoopDisk,LoopMounts,ou,domainname,www_dir,ServerPort,UseReverseProxy,\n\t\tProxyPass,Forwarder,ForwardTo,ForceInstanceZarafaID,mysql_instance_id,ServerIP{$groupware_field}{$www_dir_field})\n\t\tVALUES('{$mysql_password}','{$mysql_username}','{$ftpuser}','{$ftppassword}','{$useSSL}','{$servername}','{$mysql_database}',\n\t\t'{$uid}','{$_GET["gpid"]}','{$_GET["useMysql"]}',\n\t\t'{$_GET["useFTP"]}','{$_GET["lvm_vg"]}','{$_GET["vg_size"]}','{$_GET["UseLoopDisk"]}','{$_GET["LoopMounts"]}','{$ou}',\n\t\t'{$_GET["domainname"]}','{$FreewebsStorageDirectory}','{$ServerPort}','{$_GET["UseReverseProxy"]}','{$_GET["ProxyPass"]}',\n\t\t'{$_GET["Forwarder"]}','{$_GET["ForwardTo"]}','{$_GET["ForceInstanceZarafaID"]}','{$_GET["mysql_instance_id"]}','{$ServerIP}'{$groupware_value}{$www_dir_value}\n\t\t)";
    }
    writelogs("{$sql}", __FUNCTION__, __FILE__, __LINE__);
    $q = new mysql();
    $q->BuildTables();
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    $sock = new sockets();
    $sock->getFrameWork("system.php?dns-linker=yes");
    if ($_GET["useFTP"] == 1) {
        if ($users->PUREFTP_INSTALLED) {
            if (trim($ftpuser) != null) {
                if (trim($ftppassword) != null) {
                    $pure = new pureftpd_user();
                    if (!$pure->CreateUser($ftpuser, $ftppassword, $servername)) {
                        echo "FTP: Failed\n";
                        return;
                    }
                    $sock->getFrameWork("services.php?reload-pure-ftpd=yes");
                }
            }
        }
    }
    if ($_GET["useMysql"] == 1) {
        if (!$q->DATABASE_EXISTS($mysql_database)) {
            $q->CREATE_DATABASE("{$mysql_database}");
        }
        if (!$q->PRIVILEGES($mysql_username, $mysql_password, $mysql_database)) {
            echo "GRANT {$mysql_database} FAILED FOR {$mysql_username}\n{$q->mysql_error}";
        }
    }
    if (isset($_GET["ADD_DNS_ENTRY"])) {
        $dnsDOM = explode(".", $_GET["servername"]);
        $netbiosname = $dnsDOM[0];
        unset($dnsDOM[0]);
        $domainname = implode(".", $dnsDOM);
        include_once dirname(__FILE__) . "/ressources/class.pdns.inc";
        $pdns = new pdns($domainname);
        $pdns->EditIPName($netbiosname, $_GET["ADD_DNS_ENTRY"], "A");
    }
    if ($ligne["servername"] == null) {
        if ($_GET["force-groupware"] != null) {
            $sql = "INSERT INTO drupal_queue_orders(`ORDER`,`servername`) VALUES('INSTALL_GROUPWARE','{$servername}')";
            $q = new mysql();
            $q->QUERY_SQL($sql, "artica_backup");
            $sock->getFrameWork("freeweb.php?rebuild-vhost=yes&servername={$servername}");
        }
    }
    $sock->getFrameWork("services.php?freeweb-start=yes");
    sleep(2);
    $sock->getFrameWork("cmd.php?freeweb-restart=yes");
}
コード例 #29
0
function checkMysql()
{
    $q = new mysql();
    if (!$q->DATABASE_EXISTS("powerdns")) {
        echo "Starting......: PowerDNS creating 'powerdns' database\n";
        if (!$q->CREATE_DATABASE("powerdns")) {
            echo "Starting......: PowerDNS creating 'powerdns' database failed\n";
            return;
        }
    }
    echo "Starting......: PowerDNS 'powerdns' database OK\n";
    if (!$q->TABLE_EXISTS("domains", "powerdns")) {
        echo "Starting......: PowerDNS creating 'domains' table\n";
        $sql = "create table domains (\n\t\t\t id\t\t INT auto_increment,\n\t\t\t name\t\t VARCHAR(255) NOT NULL,\n\t\t\t master\t\t VARCHAR(128) DEFAULT NULL,\n\t\t\t last_check\t INT DEFAULT NULL,\n\t\t\t type\t\t VARCHAR(6) NOT NULL,\n\t\t\t notified_serial INT DEFAULT NULL, \n\t\t\t account         VARCHAR(40) DEFAULT NULL,\n\t\t\t primary key (id)\n\t\t\t) Engine=InnoDB;";
        $q->QUERY_SQL($sql, "powerdns");
        if (!$q->ok) {
            echo "Starting......: PowerDNS creating 'domains' table FAILED\n";
        } else {
            $q->QUERY_SQL("CREATE UNIQUE INDEX name_index ON domains(name);", "powerdns");
        }
    }
    if (!$q->TABLE_EXISTS("records", "powerdns")) {
        echo "Starting......: PowerDNS creating 'records' table\n";
        $sql = "CREATE TABLE records (\n\t\t\t  id              INT auto_increment,\n\t\t\t  domain_id       INT DEFAULT NULL,\n\t\t\t  name            VARCHAR(255) DEFAULT NULL,\n\t\t\t  type            VARCHAR(10) DEFAULT NULL,\n\t\t\t  content         VARCHAR(255) DEFAULT NULL,\n\t\t\t  ttl             INT DEFAULT NULL,\n\t\t\t  prio            INT DEFAULT NULL,\n\t\t\t  change_date     INT DEFAULT NULL,\n\t\t\t  primary key(id)\n\t\t\t)Engine=InnoDB;";
        $q->QUERY_SQL($sql, "powerdns");
        if (!$q->ok) {
            echo "Starting......: PowerDNS creating 'records' table FAILED\n";
        }
        $q->QUERY_SQL("CREATE INDEX rec_name_index ON records(name);", "powerdns");
        $q->QUERY_SQL("CREATE INDEX nametype_index ON records(name,type);", "powerdns");
        $q->QUERY_SQL("CREATE INDEX domain_id ON records(domain_id);", "powerdns");
        $q->QUERY_SQL("alter table records add ordername VARCHAR(255);", "powerdns");
        $q->QUERY_SQL("alter table records add auth bool;", "powerdns");
        $q->QUERY_SQL("create index orderindex on records(ordername);", "powerdns");
        $q->QUERY_SQL("alter table records change column type type VARCHAR(10);", "powerdns");
    }
    if (!$q->TABLE_EXISTS("supermasters", "powerdns")) {
        echo "Starting......: PowerDNS creating 'supermasters' table\n";
        $sql = "create table supermasters (\n\t\t\t\t  ip VARCHAR(25) NOT NULL, \n\t\t\t\t  nameserver VARCHAR(255) NOT NULL, \n\t\t\t\t  account VARCHAR(40) DEFAULT NULL\n\t\t\t\t) Engine=InnoDB;";
        $q->QUERY_SQL($sql, "powerdns");
        if (!$q->ok) {
            echo "Starting......: PowerDNS creating 'supermasters' table FAILED\n";
        }
        $q->QUERY_SQL("CREATE INDEX rec_name_index ON records(name);", "powerdns");
        $q->QUERY_SQL("CREATE INDEX nametype_index ON records(name,type);", "powerdns");
        $q->QUERY_SQL("CREATE INDEX domain_id ON records(domain_id);", "powerdns");
    }
    if (!$q->TABLE_EXISTS("domainmetadata", "powerdns")) {
        echo "Starting......: PowerDNS creating 'domainmetadata' table\n";
        $sql = "create table domainmetadata (\n\t\t\t id              INT auto_increment,\n\t\t\t domain_id       INT NOT NULL,\n\t\t\t kind            VARCHAR(16),\n\t\t\t content        TEXT,\n\t\t\t primary key(id)\n\t\t\t);";
        $q->QUERY_SQL($sql, "powerdns");
        if (!$q->ok) {
            echo "Starting......: PowerDNS creating 'domainmetadata' table FAILED\n";
        } else {
            $q->QUERY_SQL("create index domainmetaidindex on domainmetadata(domain_id);", "powerdns");
        }
    }
    if (!$q->TABLE_EXISTS("cryptokeys", "powerdns")) {
        echo "Starting......: PowerDNS creating 'cryptokeys' table\n";
        $sql = "create table cryptokeys (\n\t\t\t id             INT auto_increment,\n\t\t\t domain_id      INT NOT NULL,\n\t\t\t flags          INT NOT NULL,\n\t\t\t active         BOOL,\n\t\t\t content        TEXT,\n\t\t\t primary key(id)\n\t\t\t); ";
        $q->QUERY_SQL($sql, "powerdns");
        if (!$q->ok) {
            echo "Starting......: PowerDNS creating 'cryptokeys' table FAILED\n";
        } else {
            $q->QUERY_SQL("create index domainidindex on cryptokeys(domain_id);", "powerdns");
        }
    }
    if (!$q->TABLE_EXISTS("tsigkeys", "powerdns")) {
        echo "Starting......: PowerDNS creating 'tsigkeys' table\n";
        $sql = "create table tsigkeys (\n\t\t\t id             INT auto_increment,\n\t\t\t name           VARCHAR(255), \n\t\t\t algorithm      VARCHAR(255),\n\t\t\t secret         VARCHAR(255),\n\t\t\t primary key(id)\n\t\t\t);";
        $q->QUERY_SQL($sql, "powerdns");
        if (!$q->ok) {
            echo "Starting......: PowerDNS creating 'tsigkeys' table FAILED\n";
        } else {
            $q->QUERY_SQL("create unique index namealgoindex on tsigkeys(name, algorithm);", "powerdns");
        }
    }
    if (!$q->TABLE_EXISTS("users", "powerdns")) {
        echo "Starting......: PowerDNS creating 'users' table\n";
        $sql = "CREATE TABLE IF NOT EXISTS `users` (\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t  `username` varchar(16) NOT NULL DEFAULT '0',\n\t\t\t  `password` varchar(34) NOT NULL DEFAULT '0',\n\t\t\t  `fullname` varchar(255) NOT NULL DEFAULT '0',\n\t\t\t  `email` varchar(255) NOT NULL DEFAULT '0',\n\t\t\t  `description` varchar(1024) NOT NULL DEFAULT '0',\n\t\t\t  `perm_templ` tinyint(4) NOT NULL DEFAULT '0',\n\t\t\t  `active` tinyint(4) NOT NULL DEFAULT '0',\n\t\t\t  PRIMARY KEY (`id`))";
        $q->QUERY_SQL($sql, "powerdns");
        if (!$q->ok) {
            echo "Starting......: PowerDNS creating 'users' table FAILED\n";
        }
    }
    if (!$q->TABLE_EXISTS("perm_items", "powerdns")) {
        echo "Starting......: PowerDNS creating 'perm_items' table\n";
        $sql = "CREATE TABLE IF NOT EXISTS `perm_items` (\n\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t  `name` varchar(64) NOT NULL DEFAULT '0',\n\t\t  `descr` varchar(1024) NOT NULL DEFAULT '0',\n\t\t  PRIMARY KEY (`id`)\n\t\t) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=62 ;";
        $q->QUERY_SQL($sql, "powerdns");
        if (!$q->ok) {
            echo "Starting......: PowerDNS creating 'perm_items' table FAILED\n";
        } else {
            $sql = "INSERT INTO `perm_items` (`id`, `name`, `descr`) VALUES\n\t\t\t(41, 'zone_master_add', 'User is allowed to add new master zones.'),\n\t\t\t(42, 'zone_slave_add', 'User is allowed to add new slave zones.'),\n\t\t\t(43, 'zone_content_view_own', 'User is allowed to see the content and meta data of zones he owns.'),\n\t\t\t(44, 'zone_content_edit_own', 'User is allowed to edit the content of zones he owns.'),\n\t\t\t(45, 'zone_meta_edit_own', 'User is allowed to edit the meta data of zones he owns.'),\n\t\t\t(46, 'zone_content_view_others', 'User is allowed to see the content and meta data of zones he does not own.'),\n\t\t\t(47, 'zone_content_edit_others', 'User is allowed to edit the content of zones he does not own.'),\n\t\t\t(48, 'zone_meta_edit_others', 'User is allowed to edit the meta data of zones he does not own.'),\n\t\t\t(49, 'search', 'User is allowed to perform searches.'),\n\t\t\t(50, 'supermaster_view', 'User is allowed to view supermasters.'),\n\t\t\t(51, 'supermaster_add', 'User is allowed to add new supermasters.'),\n\t\t\t(52, 'supermaster_edit', 'User is allowed to edit supermasters.'),\n\t\t\t(53, 'user_is_ueberuser', 'User has full access. God-like. Redeemer.'),\n\t\t\t(54, 'user_view_others', 'User is allowed to see other users and their details.'),\n\t\t\t(55, 'user_add_new', 'User is allowed to add new users.'),\n\t\t\t(56, 'user_edit_own', 'User is allowed to edit their own details.'),\n\t\t\t(57, 'user_edit_others', 'User is allowed to edit other users.'),\n\t\t\t(58, 'user_passwd_edit_others', 'User is allowed to edit the password of other users.'),\n\t\t\t(59, 'user_edit_templ_perm', 'User is allowed to change the permission template that is assigned to a user.'),\n\t\t\t(60, 'templ_perm_add', 'User is allowed to add new permission templates.'),\n\t\t\t(61, 'templ_perm_edit', 'User is allowed to edit existing permission templates.');";
            $q->QUERY_SQL($sql, "powerdns");
        }
    }
    if (!$q->TABLE_EXISTS("perm_templ", "powerdns")) {
        echo "Starting......: PowerDNS creating 'perm_templ' table\n";
        $sql = "CREATE TABLE IF NOT EXISTS `perm_templ` (\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t  `name` varchar(128) NOT NULL DEFAULT '0',\n\t\t\t  `descr` varchar(1024) NOT NULL DEFAULT '0',\n\t\t\t  PRIMARY KEY (`id`)\n\t\t\t) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;";
        $q->QUERY_SQL($sql, "powerdns");
        if (!$q->ok) {
            echo "Starting......: PowerDNS creating 'perm_templ' table FAILED\n";
        } else {
            $sql = "INSERT INTO `perm_templ` (`id`, `name`, `descr`) VALUES (1, 'Administrator', 'Administrator template with full rights.');";
            $q->QUERY_SQL($sql, "powerdns");
        }
    }
    if (!$q->TABLE_EXISTS("perm_templ_items", "powerdns")) {
        echo "Starting......: PowerDNS creating 'perm_templ_items' table\n";
        $sql = "CREATE TABLE IF NOT EXISTS `perm_templ_items` (\n\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t  `templ_id` int(11) NOT NULL DEFAULT '0',\n\t\t  `perm_id` int(11) NOT NULL DEFAULT '0',\n\t\t  PRIMARY KEY (`id`)\n\t\t) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=250 ;";
        $q->QUERY_SQL($sql, "powerdns");
        if (!$q->ok) {
            echo "Starting......: PowerDNS creating 'perm_templ_items' table FAILED\n";
        } else {
            $sql = "INSERT INTO `perm_templ_items` (`id`, `templ_id`, `perm_id`) VALUES (249, 1, 53);";
            $q->QUERY_SQL($sql, "powerdns");
        }
    }
    if (!$q->TABLE_EXISTS("zones", "powerdns")) {
        echo "Starting......: PowerDNS creating 'zones' table\n";
        $sql = "CREATE TABLE IF NOT EXISTS `zones` (\n\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t  `domain_id` int(11) NOT NULL DEFAULT '0',\n\t\t  `owner` int(11) NOT NULL DEFAULT '0',\n\t\t  `comment` varchar(1024) DEFAULT '0',\n\t\t  `zone_templ_id` int(11) NOT NULL,\n\t\t  PRIMARY KEY (`id`)\n\t\t) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;";
        $q->QUERY_SQL($sql, "powerdns");
        if (!$q->ok) {
            echo "Starting......: PowerDNS creating 'zones' table FAILED\n";
        }
    }
    if (!$q->TABLE_EXISTS("zone_templ", "powerdns")) {
        echo "Starting......: PowerDNS creating 'zone_templ' table\n";
        $sql = "CREATE TABLE IF NOT EXISTS `zone_templ` (\n\t\t\t  `id` bigint(20) NOT NULL AUTO_INCREMENT,\n\t\t\t  `name` varchar(128) NOT NULL DEFAULT '0',\n\t\t\t  `descr` varchar(1024) NOT NULL DEFAULT '0',\n\t\t\t  `owner` bigint(20) NOT NULL DEFAULT '0',\n\t\t\t  PRIMARY KEY (`id`)\n\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;";
        $q->QUERY_SQL($sql, "powerdns");
        if (!$q->ok) {
            echo "Starting......: PowerDNS creating 'zone_templ' table FAILED\n";
        }
    }
    if (!$q->TABLE_EXISTS("zone_templ_records", "powerdns")) {
        echo "Starting......: PowerDNS creating 'zone_templ_records' table\n";
        $sql = "CREATE TABLE IF NOT EXISTS `zone_templ_records` (\n\t\t  `id` bigint(20) NOT NULL AUTO_INCREMENT,\n\t\t  `zone_templ_id` bigint(20) NOT NULL DEFAULT '0',\n\t\t  `name` varchar(255) NOT NULL DEFAULT '0',\n\t\t  `type` varchar(6) NOT NULL DEFAULT '0',\n\t\t  `content` varchar(255) NOT NULL DEFAULT '0',\n\t\t  `ttl` bigint(20) NOT NULL DEFAULT '0',\n\t\t  `prio` bigint(20) NOT NULL DEFAULT '0',\n\t\t  PRIMARY KEY (`id`)\n\t\t) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;";
        $q->QUERY_SQL($sql, "powerdns");
        if (!$q->ok) {
            echo "Starting......: PowerDNS creating 'zone_templ_records' table FAILED\n";
        }
    }
    echo "Starting......: PowerDNS Mysql done...\n";
    poweradmin();
}
コード例 #30
0
ファイル: freeweb.edit.php プロジェクト: rsd/artica-1.5
function Save(){
	
	$servername=trim(strtolower($_GET["servername"]));
	if(substr($servername, 0,1)=='.'){echo $servername. " FAILED\n";return;}
	$users=new usersMenus();
	$sock=new sockets();
	$FreewebsStorageDirectory=$sock->GET_INFO("FreewebsStorageDirectory");
	
	if(!$users->AsWebMaster){return "FALSE";}
	$uid=$_GET["uid"];
	$mysql_database=format_mysql_table($_GET["mysql_database"]);
	$mysql_password=$_GET["mysql_password"];
	$mysql_username=$_GET["mysql_username"];
	$lvm_vg=$_GET["lvm_vg"];
	$vg_size=$_GET["vg_size"];
	$ServerPort=$_GET["ServerPort"];
	if(!is_numeric($ServerPort)){$ServerPort=0;}
	if($_GET["UseDefaultPort"]==1){$ServerPort=0;}

	if(!is_numeric($vg_size)){$vg_size=5000;}
	$ftpuser=$_GET["ftpuser"];
	$ftppassword=$_GET["ftppassword"];
	$useSSL=$_GET["useSSL"];
	
	if(!$users->PUREFTP_INSTALLED){
		$_GET["useFTP"]=0;
		$ftpuser=null;
		$ftppassword=null;
	}	
	
	
	
	$sql="SELECT servername FROM freeweb WHERE servername='{$_GET["servername"]}'";
	$q=new mysql();

	$ligne=@mysql_fetch_array($q->QUERY_SQL($sql,'artica_backup'));	
	if($ligne["servername"]<>null){
		if($uid<>null){$u=new user($uid);$ou=$u->ou;}
		if(!$users->AsSystemAdministrator){$ou=$_SESSION["ou"];}
		
		$sql="UPDATE freeweb SET 
			mysql_password='******',
			mysql_username='******',
			ftpuser='******',
			ftppassword='******',
			uid='$uid',
			useMysql='{$_GET["useMysql"]}',
			useFTP='{$_GET["useFTP"]}',
			lvm_vg='{$_GET["lvm_vg"]}',
			lvm_size='{$_GET["vg_size"]}',
			UseLoopDisk='{$_GET["UseLoopDisk"]}',
			LoopMounts='{$_GET["LoopMounts"]}',
			UseReverseProxy='{$_GET["UseReverseProxy"]}',
			ProxyPass='******',
			useSSL='$useSSL',
			ServerPort='$ServerPort',
			ou='$ou',
			Forwarder='{$_GET["Forwarder"]}',
			ForwardTo='{$_GET["ForwardTo"]}'
			
			WHERE servername='$servername'
		";
	}else{
		if($uid<>null){$u=new user($uid);$ou=$u->ou;}
		if($ou<>null){if($FreewebsStorageDirectory<>null){$www_dir="$FreewebsStorageDirectory/$servername";}}
		$sock=new sockets();
		$sock->getFrameWork("freeweb.php?force-resolv=yes");
		$sql="INSERT INTO freeweb (mysql_password,mysql_username,ftpuser,ftppassword,useSSL,servername,mysql_database,
		uid,useMysql,useFTP,lvm_vg,lvm_size,UseLoopDisk,LoopMounts,ou,domainname,www_dir,ServerPort,UseReverseProxy,ProxyPass,Forwarder,ForwardTo)
		VALUES('$mysql_password','$mysql_username','$ftpuser','$ftppassword','$useSSL','$servername','$mysql_database',
		'$uid','{$_GET["useMysql"]}',
		'{$_GET["useFTP"]}','{$_GET["lvm_vg"]}','{$_GET["vg_size"]}','{$_GET["UseLoopDisk"]}','{$_GET["LoopMounts"]}','$ou',
		'{$_GET["domainname"]}','$FreewebsStorageDirectory','$ServerPort','{$_GET["UseReverseProxy"]}','{$_GET["ProxyPass"]}',
		'{$_GET["Forwarder"]}','{$_GET["ForwardTo"]}'
		)";
	}
	$q=new mysql();
	$q->BuildTables();
	$q->QUERY_SQL($sql,"artica_backup");
	if(!$q->ok){echo $q->mysql_error;return;}
	$sock=new sockets();
	
	if($_GET["useFTP"]==1){
		if($users->PUREFTP_INSTALLED){
			$pure=new pureftpd_user();
			if(!$pure->CreateUser($ftpuser,$ftppassword,$servername)){
				echo "FTP: Failed\n";
				return;
			}
		}
	}
	
	if($_GET["useMysql"]==1){
		if(!$q->DATABASE_EXISTS($mysql_database)){$q->CREATE_DATABASE("$mysql_database");}
		if(!$q->PRIVILEGES($mysql_username,$mysql_password,$mysql_database)){
			echo "GRANT $mysql_database FAILED FOR $mysql_username\n$q->mysql_error";
		}
	}
	

	$sock->getFrameWork("cmd.php?freeweb-restart=yes");
	
}