当前位置: 首页>>代码示例>>PHP>>正文


PHP mysql::TestingConnection方法代码示例

本文整理汇总了PHP中mysql::TestingConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP mysql::TestingConnection方法的具体用法?PHP mysql::TestingConnection怎么用?PHP mysql::TestingConnection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mysql的用法示例。


在下文中一共展示了mysql::TestingConnection方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ParseResolvMX

function ParseResolvMX()
{
    $sock = new sockets();
    $WhiteListResolvMX = $sock->GET_INFO("WhiteListResolvMX");
    if (!is_numeric($WhiteListResolvMX)) {
        return null;
    }
    if ($WhiteListResolvMX == 0) {
        return null;
    }
    if (!function_exists("getmxrr")) {
        echo "getmxrr() no such function\n";
        return;
    }
    $sql = "SELECT sender FROM postfix_global_whitelist WHERE enabled=1 ORDER BY sender";
    if ($GLOBALS["VERBOSE"]) {
        echo $sql . "\n";
    }
    $q = new mysql();
    if (!$q->TestingConnection()) {
        echo "ParseResolvMX()/" . basename(__FILE__) . " Connection to MySQL server failed...\n";
        return;
    }
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    $q = new mysql();
    $sql = "SELECT * FROM postfix_whitelist_con";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo "{$q->mysql_error}\n";
    }
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        $WHITELISTED[$ligne["ipaddr"]] = true;
        $WHITELISTED[$ligne["hostname"]] = true;
    }
    $count_whitelisted_before = count($WHITELISTED);
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $domain = trim($ligne["sender"]);
        if ($domain == null) {
            continue;
        }
        if (preg_match("#@(.+)#", $domain, $re)) {
            $domain = $re[1];
        }
        if (strpos($domain, "*") > 0) {
            continue;
        }
        $array_mx = resolvMX($domain);
        if (count($array_mx) == 0) {
            continue;
        }
        echo "{$domain} = " . count($array_mx) . " mx\n";
        while (list($ipaddr, $hostname) = each($array_mx)) {
            $notif[] = "{$domain}: {$hostname} [{$ipaddr}]";
            $WHITELISTED[$ipaddr] = $hostname;
        }
    }
    $count_whitelisted_after = count($WHITELISTED);
    $somme = $count_whitelisted_after - $count_whitelisted_before;
    if ($somme == 0) {
        echo "Nothing to do...\n";
        return;
    }
    if ($somme > 0) {
        if ($GLOBALS["VERBOSE"]) {
            echo "{$somme} items added in array\n" . @implode("\n", $notif);
        }
        $unix = new unix();
        $unix->send_email_events("{$somme} items MX has been whitelisted", @implode("\n", $notif), "postfix");
    }
    reset($WHITELISTED);
    while (list($value, $hostname) = each($WHITELISTED)) {
        if (trim($value) == null) {
            continue;
        }
        $sql = "DELETE FROM iptables WHERE serverip='{$value}' AND local_port=25";
        $q->QUERY_SQL($sql, "artica_backup");
        $sql = "INSERT IGNORE INTO postfix_whitelist_con (ipaddr,hostname) VALUES('{$value}','{$hostname}')";
        $q->QUERY_SQL($sql, "artica_backup");
    }
    $cmd = LOCATE_PHP5_BIN2() . " /usr/share/artica-postfix/exec.postfix.maincf.php --postscreen";
    shell_exec($cmd);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:86,代码来源:exec.postfix.iptables.php

示例2: ParseMimeDefangFilter

function ParseMimeDefangFilter()
{
    $q = new mysql();
    $sock = new sockets();
    if (!$q->TestingConnection()) {
        echo "Starting mimedefang: testing connection to MySQL failed, aborting configuration task...\n";
        return;
    }
    $ldap = new clladp();
    $tr = array();
    $localdomains = $ldap->hash_get_all_domains();
    $disclaimers_rules = disclaimers_rules();
    $autocompress_rules = autocompress_rules();
    $filehosting_rules = filehosting_rules();
    if ($autocompress_rules != null) {
        $EnableAutocompress = 1;
    } else {
        $EnableAutocompress = 0;
    }
    if ($filehosting_rules != null) {
        $EnableFileHosting = 1;
    } else {
        $EnableFileHosting = 0;
    }
    $Param = unserialize(base64_decode($sock->GET_INFO("MimeDefangServiceOptions")));
    if (!is_numeric($Param["DEBUG"])) {
        $Param["DEBUG"] = 0;
    }
    $MySQL_server = $q->mysql_server;
    $MySQL_user = $q->mysql_admin;
    $MySQL_password = $q->mysql_password;
    $MySQL_port = intval($q->mysql_port);
    $main = new main_cf();
    @file_put_contents("/etc/artica-postfix/settings/Daemons/MimeDefangPostFixNetwork", @implode("\n", $main->array_mynetworks));
    if ($MySQL_server == null) {
        $MySQL_server = "127.0.0.1";
    }
    if ($MySQL_server == "localhost") {
        $MySQL_server = "127.0.0.1";
    }
    if ($MySQL_server == "127.0.0.1") {
        $MySQL_server = null;
    }
    if ($MySQL_server == null) {
        $DSN = "DBI:mysql:database=artica_backup;mysql_socket=/var/run/mysqld/mysqld.sock";
    } else {
        $DSN = "DBI:mysql:database=artica_backup;host={$MySQL_server};port={$MySQL_port}";
    }
    $sock->SET_INFO("MySQLPerlDSN", $DSN);
    $sock->SET_INFO("MySQLPerlUsername", $MySQL_user);
    $sock->SET_INFO("MySQLPerlPassword", $MySQL_password);
    $TMPDIR = "/var/spool/MIMEDefang";
    if (!is_dir($TMPDIR)) {
        @mkdir($TMPDIR, 0755, true);
    }
    if (!is_dir("{$TMPDIR}/BACKUP")) {
        @mkdir("{$TMPDIR}/BACKUP", 0755, true);
    }
    @chown($TMPDIR, "postfix");
    @chgrp($TMPDIR, "postfix");
    @chown("{$TMPDIR}/BACKUP", "postfix");
    @chgrp("{$TMPDIR}/BACKUP", "postfix");
    $QuarantineDir = "/var/spool/MD-Quarantine";
    if (!is_dir($QuarantineDir)) {
        @mkdir($QuarantineDir, 0755, true);
    }
    @chown($QuarantineDir, "postfix");
    @chgrp($QuarantineDir, "postfix");
    $TMPDIR_CAPTURED = "/var/spool/MIMEDefang_replaced";
    if (!is_dir($TMPDIR_CAPTURED)) {
        @mkdir($TMPDIR_CAPTURED, 0755, true);
    }
    @chown($TMPDIR_CAPTURED, "postfix");
    @chgrp($TMPDIR_CAPTURED, "postfix");
    @copy("/usr/share/artica-postfix/bin/install/mimedefang/mimedefang-filter.pl", "/etc/mail/mimedefang-filter");
    while (list($dim, $line) = each($localdomains)) {
        $tr[] = "'{$dim}'=>1";
    }
    if (count($tr) > 0) {
        $hashlocaldomains = @implode(",", $tr);
    }
    $MimeDefangFileHostingSubjectPrepend = $sock->GET_INFO("MimeDefangFileHostingSubjectPrepend");
    $MimeDefangFileHostingSubjectPrepend = str_replace('"', '\\"', $MimeDefangFileHostingSubjectPrepend);
    $MimeDefangFileHostingLink = $sock->GET_INFO("MimeDefangFileHostingLink");
    $MimeDefangFileHostingText = $sock->GET_INFO("MimeDefangFileHostingText");
    $MimeDefangFileHostingExternMySQL = $sock->GET_INFO("MimeDefangFileHostingExternMySQL");
    $MimeDefangFileHostingMySQLsrv = $sock->GET_INFO("MimeDefangFileHostingMySQLsrv");
    $MimeDefangFileHostingMySQLusr = $sock->GET_INFO("MimeDefangFileHostingMySQLusr");
    $MimeDefangFileHostingMySQLPass = $sock->GET_INFO("MimeDefangFileHostingMySQLPass");
    $MimeDefangFileMaxDaysStore = $sock->GET_INFO("MimeDefangFileMaxDaysStore");
    if (!is_numeric($MimeDefangFileMaxDaysStore)) {
        $MimeDefangFileMaxDaysStore = 5;
    }
    $MimeDefangFileHostingText = stripslashes($MimeDefangFileHostingText);
    if ($MimeDefangFileHostingText == null) {
        $MimeDefangFileHostingText = "The %s file exceed the company's messaging rules.\nIt has been moved to our Web server.\nYou can download it by clicking on the link bellow.";
    }
    $MimeDefangFileHostingText = str_replace('"', '\\"', $MimeDefangFileHostingText);
    $MimeDefangFileHostingText = str_replace("\n", "\\n", $MimeDefangFileHostingText);
    $tb = explode("\n", @file_get_contents("/etc/mail/mimedefang-filter"));
//.........这里部分代码省略.........
开发者ID:articatech,项目名称:artica,代码行数:101,代码来源:exec.mimedefang.php

示例3: wizards

function wizards()
{
    return;
    $sock = new sockets();
    $DisableNetworksManagement = $sock->GET_INFO("DisableNetworksManagement");
    $WizardNetLeaveUnconfigured = $sock->GET_INFO("WizardNetLeaveUnconfigured");
    if (!is_numeric($DisableNetworksManagement)) {
        $DisableNetworksManagement = 0;
    }
    if (!is_numeric($WizardNetLeaveUnconfigured)) {
        $WizardNetLeaveUnconfigured = 0;
    }
    $hostname = base64_decode($sock->getFrameWork("network.php?fqdn=yes"));
    writelogs("network.php?fqdn=yes -> hostname=\"{$hostname}\"", __FUNCTION__, __FILE__, __LINE__);
    $mustchangeHostname = false;
    if (preg_match("#Name or service not known#", $hostname)) {
        $hostname = trim($sock->GET_INFO("myhostname"));
    }
    if (preg_match("#locahost\\.localdomain#", $hostname)) {
        $mustchangeHostname = true;
    }
    if (preg_match("#localhost\\.localdomain#", $hostname)) {
        $mustchangeHostname = true;
    }
    if (preg_match("#[A-Za-z]+\\s+[A-Za-z]+#", $hostname)) {
        $mustchangeHostname = true;
    }
    if (!$mustchangeHostname) {
        if (preg_match("#locahost\\.localdomain#", $users->hostname)) {
            $mustchangeHostname = true;
        }
    }
    if (!$mustchangeHostname) {
        if (strpos($hostname, ".") == 0) {
            $mustchangeHostname = true;
        }
    }
    if ($mustchangeHostname) {
        writelogs("hostname=\"{$hostname}\" mustchangeHostname=True", __FUNCTION__, __FILE__, __LINE__);
    } else {
        writelogs("hostname=\"{$hostname}\" mustchangeHostname=False", __FUNCTION__, __FILE__, __LINE__);
    }
    if ($mustchangeHostname) {
        echo "<script>Loadjs('admin.chHostname.php');</script>";
    }
    if ($WizardNetLeaveUnconfigured == 0) {
        $user = new usersMenus();
        if ($user->VPS_OPENVZ) {
            $sock->SET_INFO("WizardNetLeaveUnconfigured", 1);
        }
        $WizardNetLeaveUnconfigured = 1;
    }
    if ($DisableNetworksManagement == 0) {
        if ($WizardNetLeaveUnconfigured == 0) {
            if (!$mustchangeHostname) {
                $q = new mysql();
                if ($q->TestingConnection()) {
                    $countDeNIC = $q->COUNT_ROWS("nics", "artica_backup");
                    if ($q->ok) {
                        if ($countDeNIC == 0) {
                            echo "<script>Loadjs('admin.chNICs.php');</script>";
                        }
                    }
                }
            }
        }
    }
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:68,代码来源:admin.index.status-infos.php

示例4: whitelist_global_disable

function whitelist_global_disable()
{
    if (!is_numeric($_GET["ID"])) {
        return null;
    }
    $sql = "UPDATE postfix_global_whitelist SET enabled='{$_GET["GlobalWhiteDisable"]}' WHERE ID='{$_GET["ID"]}'";
    $q = new mysql();
    if (!$q->TestingConnection()) {
        echo "Connection to MySQL server failed\n";
        return;
    }
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo $q->mysql_error . "\n" . $sql . "\n";
        return;
    }
    $sock = new sockets();
    $sock->getFrameWork("cmd.php?postfix-whitelisted-global=yes");
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:19,代码来源:whitelists.admin.php

示例5: test_mysql

function test_mysql()
{
    $q = new mysql();
    if (!$q->UseMysql) {
        return;
    }
    $tpl = new templates();
    if (!$q->TestingConnection()) {
        $title = $tpl->_ENGINE_parse_body("{ERROR_MYSQL_CONNECTION}");
        $html[] = "\$.jGrowl(\"";
        $html[] = "<table>";
        $html[] = "<tr>";
        $html[] = "<td width=1% valign='top'>";
        $html[] = "<img src=img/database-error-48.png>";
        $html[] = "</td>";
        $html[] = "<td valign=top>";
        $html[] = "<span style=color:#C3393E;font-size:16px>{$title}";
        $html[] = "</span><hr>";
        $html[] = $tpl->_ENGINE_parse_body("<a href='#' OnClick=javascript:Loadjs('mysql.password.php'); style='text-decoration:underline'><strong>{$q->mysql_error}</strong>");
        $html[] = "\",";
        $html[] = "{header: '{$title}',life:15000});";
        echo implode("", $html) . "\n";
    }
}
开发者ID:,项目名称:,代码行数:24,代码来源:

示例6: messages_search

function messages_search()
{
    $tpl = new templates();
    $users = new usersMenus();
    $q = new mysql();
    $search = '%';
    $table = "amavisd_tests";
    $page = 1;
    $total = 0;
    $MyPage = CurrentPageName();
    if (!$q->TestingConnection()) {
        json_error_show("Connection to MySQL server failed");
    }
    if ($q->COUNT_ROWS("amavisd_tests", "artica_backup") == 0) {
        json_error_show("no data");
    }
    if (isset($_POST["sortname"])) {
        if ($_POST["sortname"] != null) {
            $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
        }
    }
    if (isset($_POST['page'])) {
        $page = $_POST['page'];
    }
    $searchstring = string_to_flexquery();
    $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$searchstring}";
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
    if (!$q->ok) {
        json_error_show($q->mysql_error . " LINE:" . __LINE__);
    }
    $total = $ligne["TCOUNT"];
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    $limitSql = "LIMIT {$pageStart}, {$rp}";
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    $sql = "SELECT *  FROM {$table} WHERE 1 {$searchstring} {$ORDER} {$limitSql}";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        json_error_show($q->mysql_error . " LINE:" . __LINE__);
    }
    if (mysql_num_rows($results) == 0) {
        json_error_show("no row {$sql}", 1);
    }
    $score = 0;
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        if ($ligne["subject"] == null) {
            $ligne["subject"] = "{subject}:{unknown}";
        }
        $recp = explode(",", $ligne["recipients"]);
        $rcpt_text = @implode($recp, "<br>");
        if ($ligne["finish"] == 0) {
            $status = "{scheduled}";
        }
        if ($ligne["finish"] == 1) {
            $status = "{analyzed}";
            $ahrf = "<a href=\"javascript:blur();\" \n\t\t\t\tOnClick=\"javascript:SpamassShowMsgStatus({$ligne["ID"]})\"\n\t\t\t\tstyle='font-size:16px;font-weight:normal;text-decoration:underline'>";
        }
        $delete = imgtootltip("delete-32.png", "{delete}", "DeleteSpamTest({$ligne["ID"]})");
        $analyze = imgtootltip("refresh-32.png", "{analyze}", "spamass_ana_msg({$ligne["ID"]})");
        $status = $tpl->_ENGINE_parse_body($status);
        $data['rows'][] = array('id' => $ligne['prefid'], 'cell' => array("<span style='font-size:16px'>{$ahrf}{$ligne["saved_date"]}</a></span>", "<span style='font-size:16px'>{$ahrf}{$ligne["sender"]}</a></span>", "<span style='font-size:16px'>{$ahrf}{$rcpt_text}</a></span>", "<span style='font-size:16px'>{$ligne["subject"]}</a></span>", "<span style='font-size:16px'>{$ahrf}{$status}</a></span>", "<center>{$analyze}</center>", "<center>{$delete}</center>"));
    }
    echo json_encode($data);
}
开发者ID:articatech,项目名称:artica,代码行数:69,代码来源:spamassassin.analyze.php

示例7: CheckLibraries

function CheckLibraries()
{
    $prefixOutput = "Starting......: " . date("H:i:s") . " [INIT]: Apache \"Engine\"";
    if (!isset($GLOBALS["CLASS_UNIX"])) {
        $GLOBALS["CLASS_UNIX"] = new unix();
    }
    if (!isset($GLOBALS["CLASS_USERS_MENUS"])) {
        $GLOBALS["CLASS_USERS_MENUS"] = new usersMenus();
    }
    if (!isset($GLOBALS["CLASS_SOCKETS"])) {
        $GLOBALS["CLASS_SOCKETS"] = new sockets();
    }
    if (!isset($GLOBALS["CLASS_LDAP"])) {
        $GLOBALS["CLASS_LDAP"] = new clladp();
    }
    if (!isset($GLOBALS["ECHO_BIN"])) {
        $GLOBALS["ECHO_BIN"] = $GLOBALS["CLASS_UNIX"]->find_program("echo");
    }
    if (!isset($GLOBALS["MD5SUM_BIN"])) {
        $GLOBALS["MD5SUM_BIN"] = $GLOBALS["CLASS_UNIX"]->find_program("md5sum");
    }
    if (!isset($GLOBALS["CUT_BIN"])) {
        $GLOBALS["CUT_BIN"] = $GLOBALS["CLASS_UNIX"]->find_program("cut");
    }
    $EnableOpenLDAP = 1;
    if (is_file("/etc/artica-postfix/settings/Daemons/EnableOpenLDAP")) {
        $EnableOpenLDAP = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableOpenLDAP"));
    }
    if ($EnableOpenLDAP == 1) {
        if ($GLOBALS["CLASS_LDAP"]->ldapFailed) {
            echo "{$prefixOutput} [" . __LINE__ . "] OpenLDAP system not ready...\n";
            build_progress("OpenLDAP system not ready", 110);
            die;
        }
    }
    $q = new mysql();
    if (!$q->TestingConnection()) {
        echo "{$prefixOutput} [" . __LINE__ . "] MySQL system not ready...\n";
        build_progress("MySQL system not ready", 110);
        die;
    }
}
开发者ID:articatech,项目名称:artica,代码行数:42,代码来源:exec.freeweb.php

示例8: clladp

$GLOBALS["postmap"] = $unix->find_program("postmap");
$GLOBALS["postalias"] = $unix->find_program("postalias");
$GLOBALS["postfix"] = $unix->find_program("postfix");
if (class_exists("clladp")) {
    $ldap = new clladp();
    if ($ldap->ldapFailed) {
        WriteToSyslogMail("Fatal: connecting to ldap server {$ldap->ldap_host}", basename(__FILE__), true);
        echo "Starting......: " . date("H:i:s") . " failed connecting to ldap server {$ldap->ldap_host}\n";
        $unix->send_email_events("Postfix user databases aborted (ldap failed)", "The process has been scheduled to start in few seconds.", "postfix");
        $unix->THREAD_COMMAND_SET(trim($unix->LOCATE_PHP5_BIN() . " " . __FILE__ . " {$argv[1]}"));
        die;
    }
}
if (class_exists("mysql")) {
    $mysql = new mysql();
    if (!$mysql->TestingConnection()) {
        WriteToSyslogMail("Fatal: connecting to MySQL server {$mysql->mysql_error}", basename(__FILE__), true);
        echo "Starting......: " . date("H:i:s") . " failed connecting to ldap server {$mysql->mysql_error}\n";
        $unix->send_email_events("Postfix user databases aborted (MySQL failed)", "The process has been scheduled to start in few seconds.", "postfix");
        $unix->THREAD_COMMAND_SET(trim($unix->LOCATE_PHP5_BIN() . " " . __FILE__ . " {$argv[1]}"));
        die;
    }
}
if ($argv[1] == '--reconfigure-all') {
    reconfigure();
    die;
}
if ($argv[1] == '--restart-all') {
    restart_all_instances();
    die;
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:31,代码来源:exec.postfix-multi.php

示例9: CheckLibraries

function CheckLibraries()
{
    $prefixOutput = "Starting......: " . date("H:i:s") . " [INIT]: Apache \"Engine\"";
    if (!isset($GLOBALS["CLASS_UNIX"])) {
        $GLOBALS["CLASS_UNIX"] = new unix();
    }
    if (!isset($GLOBALS["CLASS_USERS_MENUS"])) {
        $GLOBALS["CLASS_USERS_MENUS"] = new usersMenus();
    }
    if (!isset($GLOBALS["CLASS_SOCKETS"])) {
        $GLOBALS["CLASS_SOCKETS"] = new sockets();
    }
    if (!isset($GLOBALS["CLASS_LDAP"])) {
        $GLOBALS["CLASS_LDAP"] = new clladp();
    }
    if (!isset($GLOBALS["ECHO_BIN"])) {
        $GLOBALS["ECHO_BIN"] = $GLOBALS["CLASS_UNIX"]->find_program("echo");
    }
    if (!isset($GLOBALS["MD5SUM_BIN"])) {
        $GLOBALS["MD5SUM_BIN"] = $GLOBALS["CLASS_UNIX"]->find_program("md5sum");
    }
    if (!isset($GLOBALS["CUT_BIN"])) {
        $GLOBALS["CUT_BIN"] = $GLOBALS["CLASS_UNIX"]->find_program("cut");
    }
    if ($GLOBALS["CLASS_LDAP"]->ldapFailed) {
        echo "{$prefixOutput} [" . __LINE__ . "] OpenLDAP system not ready...\n";
        die;
    }
    $q = new mysql();
    if (!$q->TestingConnection()) {
        echo "{$prefixOutput} [" . __LINE__ . "] MySQL system not ready...\n";
        die;
    }
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:34,代码来源:exec.freeweb.php

示例10: checkMysql

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");
//.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:101,代码来源:exec.pdns.php

示例11: mysql

include_once(dirname(__FILE__).'/ressources/class.mysql.inc');
$file=$argv[1];
$_GET["DEBUG"]=false;
if(trim(strtolower($argv[2]))=="--debug"){$_GET["DEBUG"]=true;}


if($argv[1]=='--rebuild-sites'){
	rebuildsites();
	die('finish');
}

die("depreciated");
if(!file_exists($file)){write_syslog(" Unable to stat $file",__FILE__);}
$q=new mysql();
$q->BuildTables();
if(!$q->TestingConnection()){write_syslog("Unable to logon to mysql",__FILE__);}
$datas_file=file_get_contents($file);
$datas=explode("\n",$datas_file);
write_syslog("$file: ".Count($datas) . " line(s) with " . strlen($datas_file). " bytes length",__FILE__);

while (list ($num, $val) = each ($datas) ){
		
		if(trim($val==null)){continue;}
		if($_GET["DEBUG"]){echo "Parsing line number $num/".Count($datas)."\n";}
		parseDansLine($val);
		}
		
@unlink($file);
System("/etc/init.d/artica-postfix restart squid &");

开发者ID:rsd,项目名称:artica-1.5,代码行数:29,代码来源:cron.dansguardian.php

示例12: search

function search()
{
    $tpl = new templates();
    $users = new usersMenus();
    $q = new mysql();
    $xglobal = "%{$_GET["domain"]}";
    $search = '%';
    $table = "userpref";
    $page = 1;
    $total = 0;
    $MyPage = CurrentPageName();
    if (!$q->TestingConnection()) {
        json_error_show("Connection to MySQL server failed");
    }
    if ($q->COUNT_ROWS("userpref", "artica_backup") == 0) {
        json_error_show("no data");
    }
    if (isset($_POST["sortname"])) {
        if ($_POST["sortname"] != null) {
            $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
        }
    }
    if (isset($_POST['page'])) {
        $page = $_POST['page'];
    }
    $table = "(SELECT * FROM userpref WHERE (preference ='whitelist_from' AND `username`='{$xglobal}') \n\tOR (preference='blacklist_from' AND `username`='{$xglobal}') ) as t";
    $searchstring = string_to_flexquery();
    $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$searchstring}";
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
    if (!$q->ok) {
        json_error_show($q->mysql_error . " LINE:" . __LINE__);
    }
    $total = $ligne["TCOUNT"];
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    $limitSql = "LIMIT {$pageStart}, {$rp}";
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    $sql = "SELECT *  FROM {$table} WHERE 1 {$searchstring} {$ORDER} {$limitSql}";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        json_error_show($q->mysql_error . " LINE:" . __LINE__);
    }
    if (mysql_num_rows($results) == 0) {
        json_error_show("no row {$sql}", 1);
    }
    $score = 0;
    $ARRAY["whitelist_from"] = $tpl->javascript_parse_text("{whitelist}");
    $ARRAY["blacklist_from"] = $tpl->javascript_parse_text("{blacklist}");
    $ARRAY2["whitelist_from"] = "ok32.png";
    $ARRAY2["blacklist_from"] = "okdanger32.png";
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $delete = imgsimple("delete-32.png", "{delete}", "Loadjs('{$MyPage}?delete-id-js={$ligne["prefid"]}')");
        $prefid = $ligne["prefid"];
        $type = $ligne["preference"];
        $icon = $ARRAY2[$type];
        $text = $ARRAY[$type];
        $data['rows'][] = array('id' => $ligne['prefid'], 'cell' => array("<center><img src='img/{$icon}'></center>", "<span style='font-size:22px'>{$text} <code>{$ligne["value"]}</code></span>", "<center>{$delete}</center>"));
    }
    echo json_encode($data);
}
开发者ID:articatech,项目名称:artica,代码行数:65,代码来源:spamassassin.domains.bwl.php

示例13: rebuildsites

$file = $argv[1];
$_GET["DEBUG"] = false;
if (trim(strtolower($argv[2])) == "--debug") {
    $_GET["DEBUG"] = true;
}
if ($argv[1] == '--rebuild-sites') {
    rebuildsites();
    die('finish');
}
die("depreciated");
if (!file_exists($file)) {
    write_syslog(" Unable to stat {$file}", __FILE__);
}
$q = new mysql();
$q->BuildTables();
if (!$q->TestingConnection()) {
    write_syslog("Unable to logon to mysql", __FILE__);
}
$datas_file = file_get_contents($file);
$datas = explode("\n", $datas_file);
write_syslog("{$file}: " . Count($datas) . " line(s) with " . strlen($datas_file) . " bytes length", __FILE__);
while (list($num, $val) = each($datas)) {
    if (trim($val == null)) {
        continue;
    }
    if ($_GET["DEBUG"]) {
        echo "Parsing line number {$num}/" . Count($datas) . "\n";
    }
    parseDansLine($val);
}
@unlink($file);
开发者ID:brucewu16899,项目名称:artica,代码行数:31,代码来源:cron.dansguardian.php


注:本文中的mysql::TestingConnection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。