本文整理汇总了PHP中mysql::BD_CONNECT方法的典型用法代码示例。如果您正苦于以下问题:PHP mysql::BD_CONNECT方法的具体用法?PHP mysql::BD_CONNECT怎么用?PHP mysql::BD_CONNECT使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mysql
的用法示例。
在下文中一共展示了mysql::BD_CONNECT方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build
//.........这里部分代码省略.........
}
events("{$Interface} Must be {$ipaddr} -> {$array[$Interface]["IPADDR"]}", __FUNCTION__, __LINE__);
if ($ipaddr != $array[$Interface]["IPADDR"]) {
events("Must rebuilded....", __FUNCTION__, __LINE__);
$EXECUTE_CMDS = true;
break;
}
}
}
if ($q->mysql_server == "127.0.0.1") {
if (!$unix->is_socket("/var/run/mysqld/mysqld.sock")) {
event("/var/run/mysqld/mysqld.sock no such socket", __FUNCTION__, __LINE__);
echo "Starting......: " . date("H:i:s") . " Building networks MySQL database not available starting MySQL service...\n";
shell_exec("{$nohup} {$php5} /usr/share/artica-postfix/exec.initd-mysql.php >/dev/null 2>&1 &");
shell_exec("{$nohup} /etc/init.d/mysql start >/dev/null 2>&1 &");
sleep(1);
for ($i = 0; $i < 5; $i++) {
$q = new mysql();
if (!is_file("/var/run/mysqld/mysqld.sock")) {
echo "Starting......: " . date("H:i:s") . " Building networks waiting MySQL database to start...{$i}/4\n";
sleep(1);
} else {
break;
}
}
if (!$unix->is_socket("/var/run/mysqld/mysqld.sock")) {
event("/var/run/mysqld/mysqld.sock no such socket", __FUNCTION__, __LINE__);
echo "Starting......: " . date("H:i:s") . " Building networks MySQL database not available...\n";
die;
}
}
}
shell_exec("{$nohup} {$php5} /usr/share/artica-postfix/exec.initd-mysql.php >/dev/null 2>&1 &");
if (!$q->BD_CONNECT()) {
sleep(1);
event("Building networks MySQL database not available starting MySQL service", __FUNCTION__, __LINE__);
echo "Starting......: " . date("H:i:s") . " Building networks MySQL database not available starting MySQL service...\n";
shell_exec("{$nohup} /etc/init.d/mysql start >/dev/null 2>&1 &");
for ($i = 0; $i < 5; $i++) {
$q = new mysql();
if (!$q->BD_CONNECT()) {
echo "Starting......: " . date("H:i:s") . " Building networks waiting MySQL database to start...{$i}/4\n";
sleep(1);
} else {
break;
}
}
$q = new mysql();
if (!$q->BD_CONNECT()) {
event("Building networks MySQL database not available...", __FUNCTION__, __LINE__);
echo "Starting......: " . date("H:i:s") . " Building networks MySQL database not available...\n";
die;
}
}
if (!$q->TABLE_EXISTS("nics", "artica_backup", true)) {
echo "Starting......: " . date("H:i:s") . " Building networks MySQL table is not yet builded..\n";
die;
}
$GLOBALS["SAVED_INTERFACES"] = array();
Checkipv6();
@file_put_contents($pidfile, getmypid());
echo "Starting......: " . date("H:i:s") . " Building networks checking bridge\n";
bridges_build();
echo "Starting......: " . date("H:i:s") . " Building networks checking IPV6\n";
Checkipv6();
$nic = new system_nic();
示例2: ACTION_NETWORK
function ACTION_NETWORK()
{
$unix = new unix();
$clear = $unix->find_program("clear");
if (is_file($clear)) {
system("{$clear}");
}
$users = new usersMenus();
$q = new mysql();
if (!$q->BD_CONNECT(true)) {
echo "There is an issue while connecting to MySQL\n{$q->mysql_error}\nPress Key to exit.\n";
$line = fgets(STDIN);
return;
}
$DEFAULT = null;
$net = new networking();
$interfaces = $net->Local_interfaces();
unset($interfaces["lo"]);
if (isset($interfaces["eth0"])) {
$DEFAULT = "eth0";
}
while (list($num, $letter) = each($interfaces)) {
$int[] = "\"{$num}\"";
}
if ($DEFAULT == null) {
$DEFAULT = $int[0];
}
$q->BuildTables();
echo "This wizard will help to configure network.\n";
echo "Press q letter to exit or any key to continue:";
$answer = trim(strtolower(fgets(STDIN)));
if ($answer == "q") {
return;
}
if (is_file($clear)) {
system("{$clear}");
}
echo "Give here the interface name of the network interface\n";
echo "you need to setup.\n\n";
echo "Should be one of :" . @implode(", ", $int) . "\n";
echo "Default: [{$DEFAULT}]\n";
$NIC = trim(strtolower(fgets(STDIN)));
if ($NIC == null) {
$NIC = $DEFAULT;
}
if (!preg_match("#([a-z])([0-9+)\$#", $NIC)) {
$NIC = $DEFAULT;
}
$ETH_IP = trim(ASK_ETH_IP($NIC));
$GATEWAY = trim(ASK_GATEWAY($NIC));
$NETMASK = trim(ASK_NETMASK($NIC));
$DNS = trim(ASK_DNS1($NIC));
if (is_file($clear)) {
system("{$clear}");
}
echo "Your Settings:\n";
echo "Interface.........: \"{$NIC}\"\n";
echo "IP address........: \"{$ETH_IP}\"\n";
echo "Gateway...........: \"{$GATEWAY}\"\n";
echo "Netmask...........: \"{$NETMASK}\"\n";
echo "DNS server 1......: \"{$DNS}\"\n";
echo "\n";
//ini_set('display_errors', 1);ini_set('error_reporting', E_ALL);ini_set('error_prepend_string',null);ini_set('error_append_string',null);
echo "If your are agree with these settings\n";
echo "Press any key to apply settings or press \"q\" to return to menu.\n";
$answer = trim(strtolower(fgets(STDIN)));
if ($answer == "q") {
return;
}
echo "5%] Please Wait, saving configuration...\n";
$nics = new system_nic($NIC);
$nics->eth = $NIC;
$nics->IPADDR = $ETH_IP;
$nics->NETMASK = $NETMASK;
$nics->GATEWAY = $GATEWAY;
$nics->DNS1 = $DNS;
$nics->dhcp = 0;
$nics->metric = 1;
$nics->defaultroute = 1;
$nics->enabled = 1;
echo "7%] Please Wait, saving Networks parameters to MySQL DB...\n";
if (!$nics->SaveNic()) {
echo "There is an issue while saving your settings\n";
echo "Press any key to exit.\n";
$answer = trim(strtolower(fgets(STDIN)));
return;
}
echo "10%] Please Wait, building configuration....\n";
$php = $unix->LOCATE_PHP5_BIN();
$nohup = $unix->find_program("nohup");
$php5 = $php;
shell_exec2("{$php5} " . dirname(__FILE__) . " /exec.virtuals-ip.php --build --force >/dev/null 2>&1");
echo "20%] Please Wait, apply network configuration....\n";
shell_exec2("{$php5} /usr/share/artica-postfix/exec.initslapd.php");
shell_exec2("/etc/init.d/artica-ifup start");
echo "30%] Please Wait, restarting services....\n";
$unix->THREAD_COMMAND_SET("{$php5} /usr/share/artica-postfix/exec.postfix.maincf.php --reconfigure");
$unix->THREAD_COMMAND_SET("/usr/share/artica-postfix/bin/artica-install --reconfigure-cyrus");
shell_exec2("{$nohup} /etc/init.d/artica-status reload >/dev/null 2>&1 &");
shell_exec2("{$nohup} /etc/init.d/nginx restart >/dev/null 2>&1 &");
//.........这里部分代码省略.........
示例3: start
function start($nopid = false)
{
$users = new usersMenus();
$unix = new unix();
$ettercap_bin = $unix->find_program("ettercap");
if (!$users->ETTERCAP_INSTALLED) {
echo "ArpSpoofing.........: [START]: Ettercap, not installed...\n";
return;
}
if (!is_file($ettercap_bin)) {
echo "ArpSpoofing.........: [START]: Ettercap, not such binary...\n";
return;
}
$sock = new sockets();
$ArpSpoofEnabled = $sock->GET_INFO("ArpSpoofEnabled");
if (!is_numeric($ArpSpoofEnabled)) {
$ArpSpoofEnabled = 0;
}
if (!$nopid) {
$me = basename(__FILE__);
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, $me)) {
$time = $unix->PROCCESS_TIME_MIN($pid);
echo "ArpSpoofing.........: [START]: Ettercap, Already start instance executed PID {$pid} since {$time}Mn...\n";
return;
}
@file_put_contents($pidfile, getmypid());
}
if ($ArpSpoofEnabled == 0) {
echo "ArpSpoofing.........: [START]: Ettercap, not enabled\n";
stop(true);
}
$nohup = $unix->find_program("nohup");
$q = new mysql();
if (!$q->BD_CONNECT()) {
echo "ArpSpoofing.........: [START]: unable to connect to MySQL database...\n";
return;
}
if (!$unix->SystemUserExists("nobody")) {
echo "ArpSpoofing.........: [START]: Creating nobody user...\n";
$unix->CreateUnixUser("nobody", "nogroup");
}
if (!$unix->SystemGroupExists("nogroup")) {
$unix->SystemCreateGroup("nogroup");
$unix->CreateUnixUser("nobody", "nogroup");
}
$uid = $unix->SystemUserGetuid("nobody");
$guid = $unix->SystemGroupUid("nogroup");
init_debian();
$sql = "SELECT * FROM arpspoof_rules WHERE enabled=1";
$results = $q->QUERY_SQL($sql, "artica_backup");
while ($ligne = mysql_fetch_assoc($results)) {
$rulename = $ligne["rulename"];
$pid = get_rule_pid($ligne["ID"]);
if ($unix->process_exists($pid)) {
echo "ArpSpoofing.........: [START]: `{$rulename}` already running pid {$pid}\n";
continue;
}
$sources = getobjects($ligne["ID"]);
$gateway = $ligne["gateway"];
if ($sources == null) {
echo "ArpSpoofing.........: [START]: `{$rulename}` no item set...\n";
continue;
}
if ($sources == "all") {
$sources = null;
}
$f = array();
$f[] = "[privs]";
$f[] = "ec_uid = {$uid} # nobody is the default";
$f[] = "ec_gid = {$guid} # nobody is the default";
$f[] = "[mitm]";
$f[] = "arp_storm_delay = 10";
$f[] = "arp_poison_warm_up = 1";
$f[] = "arp_poison_delay = 10";
$f[] = "arp_poison_equal_mac= 1";
$f[] = "arp_poison_reply=1";
$f[] = "arp_poison_icmp = 1";
$f[] = "dhcp_lease_time = 600";
$f[] = "port_steal_delay = 10 # milliseconds";
$f[] = "port_steal_send_delay = 2000 # microseconds";
$f[] = "[connections]";
$f[] = "connection_timeout = 300 # seconds";
$f[] = "connection_idle = 5 # seconds";
$f[] = "connection_buffer = 10000 # bytes";
$f[] = "connect_timeout = 5 # seconds";
$f[] = "";
$f[] = "[stats]";
$f[] = "sampling_rate = 50 # number of packets";
$f[] = "";
$f[] = "[misc]";
$f[] = "close_on_eof = 1 # boolean value";
$f[] = "store_profiles = 1 # 0 = disabled; 1 = all; 2 = local; 3 = remote";
$f[] = "aggressive_dissectors = 1 # boolean value";
$f[] = "skip_forwarded_pcks = 1 # boolean value";
$f[] = "checksum_check = 0 # boolean value";
$f[] = "checksum_warning = 0 # boolean value (valid only if checksum_check is 1)";
$f[] = "";
@mkdir("/etc/ettercap", 0755, true);
//.........这里部分代码省略.........
示例4: system_admin_events_checks
function system_admin_events_checks($nopid = false)
{
$f = array();
$unix = new unix();
$TRW = array();
if ($nopid) {
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = @file_get_contents($pidfile);
if ($unix->process_exists($pid)) {
writelogs("Already running pid {$pid}", __FUNCTION__, __FILE__, __LINE__);
return;
}
$t = 0;
@file_put_contents($pidfile, getmypid());
}
// removed : foreach (glob("{$GLOBALS["ARTICALOGDIR"]}/system_admin_events/*") as $filename) {
$BaseWorkDir = "{$GLOBALS["ARTICALOGDIR"]}/system_admin_events";
$FILES = $unix->COUNT_FILES($BaseWorkDir);
if ($FILES > 5000) {
if (!($handle = opendir($BaseWorkDir))) {
echo "Failed open {$BaseWorkDir}\n";
return;
}
while (false !== ($filename = readdir($handle))) {
if ($filename == ".") {
continue;
}
if ($filename == "..") {
continue;
}
$targetFile = "{$BaseWorkDir}/{$filename}";
if (is_dir($targetFile)) {
continue;
}
@unlink($targetFile);
}
return;
}
if (!($handle = opendir($BaseWorkDir))) {
echo "Failed open {$BaseWorkDir}\n";
return;
}
$q = new mysql();
if (!$q->BD_CONNECT(true, "called by " . basename(__FILE__) . " (" . __FUNCTION__ . ") line: " . __LINE__)) {
return;
}
$sql = "CREATE TABLE IF NOT EXISTS `artica_events`.`system_admin_events` (\n\t`zDate` TIMESTAMP NOT NULL ,\n\t`description` MEDIUMTEXT NOT NULL ,\n\t`function` VARCHAR( 60 ) NOT NULL ,\n\t`filename` VARCHAR( 50 ) NOT NULL ,\n\t`line` INT( 10 ) NOT NULL ,\n\t`category` VARCHAR( 50 ) NOT NULL ,\n\t`TASKID` INT(10) NOT NULL,\n\tKEY `zDate` ( `zDate`),\n\tKEY `function` (`function`),\n\tKEY `filename` (`filename`),\n\tKEY `line` (`line`),\n\tKEY `TASKID` (`TASKID`),\n\tKEY `category` (`category`)\n\t) ENGINE=MYISAM;";
$q->QUERY_SQL($sql, "artica_events");
if (!$q->ok) {
return;
}
$prefix = "INSERT IGNORE INTO system_admin_events (`zDate`,`function`,`filename`,`line`,`description`,`category`,`TASKID`) VALUES ";
while (false !== ($filename = readdir($handle))) {
if ($filename == ".") {
continue;
}
if ($filename == "..") {
continue;
}
$targetFile = "{$BaseWorkDir}/{$filename}";
$array = unserialize(@file_get_contents($targetFile));
@unlink($targetFile);
if (!is_array($array)) {
$array["text"] = basename($filename) . " is not an array, skip event \n" . @file_get_contents($targetFile);
$array["zdate"] = date('Y-m-d H:i:s');
$array["pid"] = getmypid();
$array["function"] = __FUNCTION__;
$array["category"] = "parser";
$array["file"] = basename(__FILE__);
$array["line"] = __LINE__;
}
if (!is_numeric($array["TASKID"])) {
$array["TASKID"] = 0;
}
$tableName = "Taskev{$array["TASKID"]}";
$chkTables[$tableName] = true;
WriteMyLogs(substr($array["text"], 0, 128), __FUNCTION__, __FILE__, __LINE__);
while (list($key, $val) = each($array)) {
$val = mysql_escape_string2($val);
$array[$key] = str_replace("'", "`", $val);
}
$rom2 = "('{$array["zdate"]}','{$array["function"]}','{$array["file"]}','{$array["line"]}','{$array["text"]}','{$array["category"]}','{$array["TASKID"]}')";
$rom = "('{$array["zdate"]}','{$array["function"]}','{$array["file"]}','{$array["line"]}','{$array["text"]}','{$array["category"]}')";
$TRW[] = $rom2;
$f[$tableName][] = $rom;
if (count($f[$tableName]) > 1500) {
system_admin_events_inject($f, true);
$f = array();
}
if (count($f) > 10) {
system_admin_events_inject($f, true);
$f = array();
}
@unlink($targetFile);
}
$q = new mysql();
if (count($TRW) > 0) {
$q->QUERY_SQL("{$prefix}" . @implode(",", $TRW), "artica_events");
}
//.........这里部分代码省略.........
示例5: sys_mem
function sys_mem()
{
$f = array();
$q = new mysql();
if (!$q->TABLE_EXISTS('sys_mem', 'artica_events')) {
$sql = "CREATE TABLE IF NOT EXISTS `sys_mem` (\n\t\t\t \t`zDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n\t\t\t\tmemory_used BIGINT UNSIGNED,\n\t\t\t\tPRIMARY KEY (`zDate`),\n\t\t\t\tKEY `memory_used` (`memory_used`)\n\t\t\t) ENGINE=MYISAM;\n\t\t\t";
$q->QUERY_SQL($sql, 'artica_events');
if (!$q->ok) {
return;
}
}
if (!$q->BD_CONNECT()) {
return;
}
$prefix = "INSERT IGNORE INTO sys_mem (zDate,memory_used) VALUES ";
if (system_is_overloaded()) {
return;
}
$DirPath = "{$GLOBALS["ARTICALOGDIR"]}/sys_mem";
if (!is_dir($DirPath)) {
@mkdir($DirPath, 0755, true);
}
if (!($handle = opendir($DirPath))) {
return;
}
while (false !== ($file = readdir($handle))) {
if ($file == ".") {
continue;
}
if ($file == "..") {
continue;
}
$filename = "{$DirPath}/{$file}";
if (is_dir($filename)) {
continue;
}
$time = basename($filename);
$zdate = date("Y-m-d H:i:s", $time);
$load = trim(@file_get_contents($filename));
$f[] = "('{$zdate}','{$load}')";
@unlink($filename);
}
if (count($f) > 0) {
$sql = $prefix . @implode(",", $f);
$q->QUERY_SQL($sql, "artica_events");
}
}