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


PHP mysql::FIELD_EXISTS方法代码示例

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


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

示例1: time_save

function time_save()
{
    $ID = $_POST["time-save"];
    $array_days = array(1 => "monday", 2 => "tuesday", 3 => "wednesday", 4 => "thursday", 5 => "friday", 6 => "saturday", 7 => "sunday");
    while (list($num, $maks) = each($array_days)) {
        if ($_POST["D{$num}"] == 1) {
            $TTIME["D{$num}"] = 1;
        }
    }
    $TTIME["ttime"] = $_POST["ttime"];
    $TTIME["ftime"] = $_POST["ftime"];
    $rule1 = strtotime(date("Y-m-d") . " {$TTIME["ftime"]}");
    $rule2 = strtotime(date("Y-m-d") . " {$TTIME["ttime"]}");
    if ($rule1 > $rule2) {
        $tpl = new templates();
        echo $tpl->javascript_parse_text("{fwtime_explain}");
        return;
    }
    $TTIMEZ = mysql_escape_string2(serialize($TTIME));
    $q = new mysql();
    if (!$q->FIELD_EXISTS("iptables_main", "time_restriction", "artica_backup")) {
        $sql = "ALTER TABLE `iptables_main` ADD `time_restriction` TEXT";
        $q->QUERY_SQL($sql, "artica_backup");
    }
    if (!$q->FIELD_EXISTS("iptables_main", "enablet", "artica_backup")) {
        $sql = "ALTER TABLE `iptables_main` ADD `enablet` smallint( 1 ) NOT NULL DEFAULT '0',ADD INDEX ( enablet ) ";
        $q->QUERY_SQL($sql, "artica_backup");
    }
    $sql = "UPDATE iptables_main SET `enablet`='{$_POST["enablet"]}',`time_restriction`='{$TTIMEZ}' WHERE ID='{$ID}'";
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo $q->mysql_error . "\n{$sql}";
    }
}
开发者ID:articatech,项目名称:artica,代码行数:34,代码来源:firehol.nic.rules.time.php

示例2: save

function save()
{
    $_POST["relay_password"] = url_decode_special_tool($_POST["relay_password"]);
    $q = new mysql();
    if (!$q->FIELD_EXISTS("relay_host", "enabledauth", "artica_backup")) {
        $sql = "ALTER TABLE `relay_host` ADD `enabledauth` smallint( 1 ) NOT NULL ";
        $q->QUERY_SQL($sql, "artica_backup");
    }
    if (!$q->FIELD_EXISTS("relay_host", "username", "artica_backup")) {
        $sql = "ALTER TABLE `relay_host` ADD `username` VARCHAR( 128 ) NOT NULL ";
        $q->QUERY_SQL($sql, "artica_backup");
    }
    if (!$q->FIELD_EXISTS("relay_host", "password", "artica_backup")) {
        $sql = "ALTER TABLE `relay_host` ADD `password` VARCHAR( 128 ) NOT NULL ";
        $q->QUERY_SQL($sql, "artica_backup");
    }
    if (!$q->FIELD_EXISTS("relay_host", "lookups", "artica_backup")) {
        $sql = "ALTER TABLE `relay_host` ADD `lookups` smallint(1) NOT NULL ";
        $q->QUERY_SQL($sql, "artica_backup");
    }
    if ($_POST["relay_address"] == null) {
        echo "relay address: not set...\n";
        return;
    }
    if ($_POST["relay_port"] == 0) {
        $_POST["relay_port"] = 25;
    }
    $q->QUERY_SQL("DELETE FROM `relay_host` WHERE hostname='{$_POST["hostname"]}'", "artica_backup");
    $sql = "INSERT IGNORE INTO relay_host\n\t(`hostname`,`enabled`,`enabledauth`,`relay`,`relay_port`,`username`,`password`,`lookups`)\n\tVALUES('{$_POST["hostname"]}','{$_POST["enabled"]}','{$_POST["enabledauth"]}','{$_POST["relay_address"]}',\n\t'{$_POST["relay_port"]}','{$_POST["relay_username"]}','{$_POST["relay_password"]}','{$_POST["lookups"]}')";
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo $q->mysql_error;
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:34,代码来源:postfix.routing.relayhost.php

示例3: Save

function Save()
{
    $q = new mysql();
    if (!$q->FIELD_EXISTS("squid_parents", "WanProxyMemory", "artica_backup")) {
        $q->QUERY_SQL("ALTER TABLE `squid_parents` ADD `WanProxyMemory` SMALLINT(10) NOT NULL DEFAULT '256'", "artica_backup");
        if (!$q->ok) {
            echo $q->mysql_error . "\n";
        }
    }
    if (!$q->FIELD_EXISTS("squid_parents", "WanProxyCache", "artica_backup")) {
        $q->QUERY_SQL("ALTER TABLE `squid_parents` ADD `WanProxyCache` SMALLINT(10) NOT NULL DEFAULT '1'", "artica_backup");
        if (!$q->ok) {
            echo $q->mysql_error . "\n";
        }
    }
    $q->QUERY_SQL("UPDATE squid_parents SET\n\tWanProxyMemory={$_POST["WanProxyMemory"]},\n\tWanProxyCache={$_POST["WanProxyCache"]}\n\tWHERE ID='{$_POST["ID"]}'", "artica_backup");
    if (!$q->ok) {
        echo $q->mysql_error;
    }
    $sock = new sockets();
    $sock->getFrameWork("wanproxy.php?reconfigure-silent=yes");
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:22,代码来源:squid.parent.proxy.wancompress.php

示例4: popup

function popup()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $sock = new sockets();
    $CPU_NUMBER = $sock->getFrameWork("services.php?CPU-NUMBER=yes");
    $q = new mysql();
    $t = time();
    $ARRAY_CPU[0] = "{all}";
    for ($i = 1; $i < $CPU_NUMBER + 1; $i++) {
        $ARRAY_CPU[$i] = "CPU #{$i}";
    }
    if (!$q->FIELD_EXISTS("squid_caches_center", "CPUAF", "artica_backup")) {
        $sql = "ALTER TABLE `squid_caches_center` ADD `CPUAF` smallint(2) NOT NULL DEFAULT 0";
        $q->QUERY_SQL($sql, "artica_backup");
    }
    $sql = "SELECT cpu,CPUAF FROM squid_caches_center GROUP BY cpu,CPUAF ORDER BY cpu";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    $html[] = "<div style='width:98%' class=form>";
    $html[] = "<table style='width:100%'>";
    while ($ligne = mysql_fetch_assoc($results)) {
        $html[] = "<tr>";
        $html[] = "<td class=legend style='font-size:26px'>{process} {$ligne["cpu"]}:<td>";
        $html[] = "<td style='font-size:26px'>" . Field_array_Hash($ARRAY_CPU, "CPUFOR-{$ligne["cpu"]}", $ligne["CPUAF"], "style:font-size:26px") . "</td>";
        $html[] = "<td>" . button("{apply}", "SaveCPU{$ligne["cpu"]}()", 26) . "</td>";
        $html[] = "</tR>";
        $js[] = "function SaveCPU{$ligne["cpu"]}(){";
        $js[] = "\tvar XHR = new XHRConnection();";
        $js[] = "\tXHR.appendData('affectprocess','{$ligne["cpu"]}');";
        $js[] = "\tXHR.appendData('affectcpu',document.getElementById('CPUFOR-{$ligne["cpu"]}').value);";
        $js[] = "\tXHR.sendAndLoad('{$page}', 'POST',xSave{$t});";
        $js[] = "}";
    }
    $html[] = "</table>\n\t\t<center style='margin:20px;margin-top:50px'>" . button("{restart}", "Loadjs('squid.restart.php');", 28) . "\n\t\t</center>";
    $html[] = "</div>";
    $html[] = "<script>";
    $html[] = "var xSave{$t}= function (obj) {";
    $html[] = "\tvar results=obj.responseText;";
    $html[] = "\tif(results.length>0){alert(results);}";
    $html[] = "\tif(document.getElementById('CACHE_CENTER_TABLEAU')){";
    $html[] = "\t\tvar CACHE_CENTER_TABLEAU=document.getElementById('CACHE_CENTER_TABLEAU').value;";
    $html[] = "\t\t\$('#'+CACHE_CENTER_TABLEAU).flexReload();";
    $html[] = "\t}";
    $html[] = "}";
    $html[] = @implode("\n", $js);
    $html[] = "</script>";
    $html_final = @implode("\n", $html);
    echo $tpl->_ENGINE_parse_body($html_final);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:49,代码来源:squid.caches.center.cpuaff.php

示例5: search

function search()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql();
    $database = "artica_backup";
    $t = $_GET["t"];
    $search = '%';
    $table = "routing_rules_dest";
    $page = 1;
    $fontsize = 16;
    $FORCE_FILTER = "AND ruleid='{$_GET["ruleid"]}'";
    $total = 0;
    if (!$q->FIELD_EXISTS("routing_rules_dest", "zOrder", "artica_backup")) {
        $q->QUERY_SQL("ALTER TABLE `routing_rules_dest` ADD `zOrder` INT(10) NOT NULL, ADD INDEX (`zOrder`)", "artica_backup");
        if (!$q->ok) {
            json_error_show($q->mysql_error, 1);
        }
    }
    if (!$q->FIELD_EXISTS("routing_rules_dest", "metric", "artica_backup")) {
        $q->QUERY_SQL("ALTER TABLE `routing_rules_dest` ADD `metric` INT(10) NOT NULL, ADD INDEX (`metric`)", "artica_backup");
    }
    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();
    if ($searchstring != null) {
        $search = $_POST["query"];
        $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE 1 {$FORCE_FILTER} {$searchstring}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql, $database));
        $total = $ligne["TCOUNT"];
    } else {
        $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE 1 {$FORCE_FILTER}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql, $database));
        $total = $ligne["TCOUNT"];
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    if (!is_numeric($rp)) {
        $rp = 50;
    }
    $limitSql = "LIMIT {$pageStart}, {$rp}";
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    $types[1] = $tpl->_ENGINE_parse_body("{network_nic}");
    $types[2] = $tpl->_ENGINE_parse_body("{host}");
    $types[3] = $tpl->_ENGINE_parse_body("{default_gateway}");
    $style = "style='font-size:{$fontsize}px;color:black;'";
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM routing_rules WHERE ID='{$_GET["ruleid"]}'", "artica_backup"));
    $nic = new system_nic($ligne["nic"]);
    if ($nic->GATEWAY != null) {
        if ($nic->GATEWAY != "0.0.0.0") {
            $data['total'] = $total + 1;
            $data['rows'][] = array('id' => $ligne['ID'], 'cell' => array("<span {$style}>0</a></span>", "<span {$style}>0.0.0.0/0</a></span>", "<span {$style}>" . $types[3] . "</a></span>", "<span {$style}>{$nic->GATEWAY}</span>", "<center {$style}>-</center>", "<center {$style}>-</center>", "<center {$style}>-</center>"));
        }
    }
    $sql = "SELECT *  FROM `{$table}` WHERE 1 {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}";
    $results = $q->QUERY_SQL($sql, $database);
    if (!$q->ok) {
        json_error_show($q->mysql_error, 1);
    }
    while ($ligne = mysql_fetch_assoc($results)) {
        $color = "black";
        //if($ligne["enabled"]==0){$color="#8a8a8a";}
        $style = "style='font-size:{$fontsize}px;color:{$color};'";
        $delete = imgsimple("delete-24.png", null, "Loadjs('{$MyPage}?route-delete-js=yes&ID={$ligne["ID"]}&ruleid={$_GET["ruleid"]}&t={$t}');");
        $js = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('{$MyPage}?route-js=yes&ID={$ligne["ID5"]}&t={$t}');\"\n\t\tstyle='font-size:{$fontsize}px;color:{$color};text-decoration:underline'>";
        $down = imgsimple("arrow-down-18.png", null, "Loadjs('{$MyPage}?route-move-js=yes&ID={$ligne["ID"]}&ruleid={$_GET["ruleid"]}&t={$t}&dir=down');");
        $up = imgsimple("arrow-up-18.png", null, "Loadjs('{$MyPage}?route-move-js=yes&ID={$ligne["ID"]}&ruleid={$_GET["ruleid"]}&t={$t}&dir=up');");
        if ($ligne["gateway"] == null) {
            $ligne["gateway"] = "-";
        }
        if ($ligne["type"] == 3) {
            $ligne["pattern"] = "0.0.0.0/0";
        }
        $data['rows'][] = array('id' => $ligne['ID'], 'cell' => array("<span {$style}>{$js}{$ligne["zOrder"]}</a></span>", "<span {$style}>{$js}{$ligne["pattern"]}</a></span>", "<span {$style}>{$js}" . $types[$ligne["type"]] . "</a></span>", "<span {$style}>{$ligne["gateway"]}</span>", "<center {$style}>{$up}</center>", "<center {$style}>{$down}</center>", "<center {$style}>{$delete}</center>"));
    }
    echo json_encode($data);
}
开发者ID:articatech,项目名称:artica,代码行数:88,代码来源:system.routing.rules.destinations.php

示例6: add_website

function add_website()
{
    if ($_GET["ID"] == 0) {
        $sqlSource = "INSERT INTO squid_accel (website_name,website_ip,website_port,`UseSSL`,`certificate`,`UseVirtualHosts`,`enabled`) \n\t\tVALUES('{$_GET["website"]}','{$_GET["website_ip"]}','{$_GET["website_port"]}','{$_GET["UseSSL"]}','{$_GET["certificate"]}','{$_GET["UseVirtualHosts"]}','{$_GET["enabled"]}')";
    } else {
        $sqlSource = "UPDATE squid_accel SET website_name='{$_GET["website"]}',\n\t\twebsite_ip='{$_GET["website_ip"]}',\n\t\twebsite_port='{$_GET["website_port"]}',\n\t\tUseSSL='{$_GET["UseSSL"]}',\n\t\tcertificate='{$_GET["certificate"]}',\n\t\tUseVirtualHosts='{$_GET["UseVirtualHosts"]}',\n\t\tenabled='{$_GET["enabled"]}'\n\t\tWHERE ID={$_GET["ID"]}";
    }
    $q = new mysql();
    if (!$q->FIELD_EXISTS("squid_accel", "UseSSL", "artica_backup")) {
        $q->QUERY_SQL("ALTER TABLE `squid_accel` ADD `UseSSL` smallint( 1 ) NOT NULL DEFAULT '0',ADD INDEX ( `UseSSL` )", "artica_backup");
        if (!$q->ok) {
            echo "{$q->mysql_error}\n";
        }
    }
    if (!$q->FIELD_EXISTS("squid_accel", "enabled", "artica_backup")) {
        $q->QUERY_SQL("ALTER TABLE `squid_accel` ADD `enabled` smallint( 1 ) NOT NULL DEFAULT '1',ADD INDEX ( `enabled` )", "artica_backup");
        if (!$q->ok) {
            echo "{$q->mysql_error}\n";
        }
    }
    if (!$q->FIELD_EXISTS("squid_accel", "certificate", "artica_backup")) {
        $q->QUERY_SQL("ALTER TABLE `squid_accel` ADD `certificate`VARCHAR(255) NOT NULL", "artica_backup");
        if (!$q->ok) {
            echo "{$q->mysql_error}\n";
        }
    }
    if (!$q->FIELD_EXISTS("squid_accel", "UseVirtualHosts", "artica_backup")) {
        $sql = "ALTER TABLE `squid_accel` ADD `UseVirtualHosts` smallint(1) NOT NULL,ADD INDEX ( `UseVirtualHosts` )";
        $q->QUERY_SQL($sql, "artica_backup");
        if (!$q->ok) {
            echo "{$q->mysql_error}\n";
        }
    }
    if (!$q->FIELD_EXISTS("squid_accel", "virtualhosts", "artica_backup")) {
        $sql = "ALTER TABLE `squid_accel` ADD `virtualhosts` TEXT NOT NULL";
        $q->QUERY_SQL($sql, "artica_backup");
        if (!$q->ok) {
            echo "{$q->mysql_error}\n";
        }
    }
    $q->QUERY_SQL($sqlSource, "artica_backup");
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:46,代码来源:squid.reverse.websites.php

示例7: build

function build()
{
    $unix = new unix();
    $q = new mysql();
    $sock = new sockets();
    $FireHolEnable = intval($sock->GET_INFO("FireHolEnable"));
    if ($FireHolEnable == 1) {
        @unlink("/bin/artica-firewall.sh");
        iptables_delete_all();
        return;
    }
    iptables_delete_all();
    $FINAL_LOG_DROP = array();
    if (!$q->FIELD_EXISTS("nics", "isFWAcceptNet", "artica_backup")) {
        $sql = "ALTER TABLE `nics` ADD `isFWAcceptNet` smallint( 1 ) NOT NULL DEFAULT '0'";
        $q->QUERY_SQL($sql, 'artica_backup');
        if (!$q->ok) {
            echo "[" . __LINE__ . "]: {$q->mysql_error}\n";
        }
    }
    if (!$q->FIELD_EXISTS("nics", "isFWAcceptArtica", "artica_backup")) {
        $sql = "ALTER TABLE `nics` ADD `isFWAcceptArtica` smallint( 1 ) NOT NULL DEFAULT '0'";
        $q->QUERY_SQL($sql, 'artica_backup');
        if (!$q->ok) {
            echo "[" . __LINE__ . "]: {$q->mysql_error}\n";
        }
    }
    $sql = "SELECT `Interface`,`Bridged`,`BridgedTo`,`isFWAcceptNet`,`isFWAcceptArtica`,`isFWLogBlocked` FROM `nics` WHERE `isFW`=1 AND `Bridged`=0";
    if ($GLOBALS["VERBOSE"]) {
        echo "[" . __LINE__ . "] {$sql}\n";
    }
    $echo = $unix->find_program("echo");
    $php = $unix->LOCATE_PHP5_BIN();
    $SCRIPT[] = "#! /bin/sh";
    $SCRIPT[] = "{$php} /usr/share/artica-postfix/exec.syslog-engine.php --buildconf";
    $SCRIPT[] = "if [ ! -f /var/log/iptables.log ]; then";
    $SCRIPT[] = "\t{$echo} \"/var/log/iptables.log doesn't exists...\"";
    $SCRIPT[] = "\t" . $unix->LOCATE_SYSLOG_INITD() . " restart";
    $SCRIPT[] = "fi";
    $SCRIPT[] = "{$echo} \"Removing Firewall rules...\"";
    $SCRIPT[] = $php . " " . __FILE__ . " --remove || true";
    $SCRIPT[] = "# -------------- Q . O . S --------------";
    $SCRIPT[] = build_qos();
    $results = $q->QUERY_SQL($sql, "artica_backup");
    $CountDeInterface = mysql_num_rows($results);
    $SCRIPT[] = "{$echo} \"Firewall enabled on {$CountDeInterface} Interface(s)\"";
    $iptables = $unix->find_program("iptables");
    $MARKLOG = "-m comment --comment \"ArticaFireWall\"";
    $net = new networkscanner();
    while (list($num, $maks) = each($net->networklist)) {
        if (trim($maks) == null) {
            continue;
        }
        $SCRIPT[] = "# Accept potential Network {$maks}";
        $hash[$maks] = $maks;
    }
    $ALL_RULES = 0;
    if ($CountDeInterface > 0) {
        while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
            $ALL_RULES++;
            $isFWAcceptNet = intval($ligne["isFWAcceptNet"]);
            $J_LOGPRX = "--j LOG --log-level debug --log-prefix \"AID=0/INPUT/REJECT \"";
            $InInterface = " -i {$ligne["Interface"]} ";
            $SCRIPT_FINAL[] = "{$iptables} -A INPUT {$InInterface} {$MARKLOG} -j REJECT || true";
            if ($ligne["isFWLogBlocked"] == 1) {
                $FINAL_LOG_DROP["{$iptables} -A INPUT {$InInterface} {$MARKLOG} {$J_LOGPRX} || true"] = true;
            }
            $SCRIPT[] = "{$iptables} -I INPUT {$InInterface} -s 127.0.0.1 {$MARKLOG} -j ACCEPT || true";
            $SCRIPT[] = "{$iptables} -I INPUT {$InInterface} -d 127.0.0.1 {$MARKLOG} -j ACCEPT || true";
            $SCRIPT[] = "# {$InInterface} Accept local network ? = {$isFWAcceptNet}";
            if ($isFWAcceptNet == 1) {
                reset($hash);
                while (list($num, $maks) = each($hash)) {
                    $SCRIPT[] = "{$iptables} -I INPUT {$InInterface} -d {$maks} {$MARKLOG} -j ACCEPT || true";
                    $SCRIPT[] = "{$iptables} -I INPUT {$InInterface} -s {$maks} {$MARKLOG} -j ACCEPT || true";
                }
            }
            $SCRIPT[] = BuilFWdRules($ligne["Interface"], "INPUT", $ligne["isFWLogBlocked"]);
            $SCRIPT[] = BuilFWdRules($ligne["Interface"], "OUTPUT", $ligne["isFWLogBlocked"]);
            $SCRIPT[] = BuilFWdRules_FORWARD($ligne["Interface"], $ligne["isFWLogBlocked"]);
        }
    }
    $sql = "SELECT * FROM `nics_bridge` WHERE `isFW`=1";
    if ($GLOBALS["VERBOSE"]) {
        echo "[" . __LINE__ . "] {$sql}\n";
    }
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        $SCRIPT[] = "#" . str_replace("\n", " ", $q->mysql_error);
    }
    $CountDeInterface = mysql_num_rows($results);
    $SCRIPT[] = "{$echo} \"Firewall enabled on {$CountDeInterface} Bridge(s)\"";
    if ($CountDeInterface > 0) {
        while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
            $ALL_RULES++;
            $J_LOGPRX = "--j LOG --log-level debug --log-prefix \"AID={$ligne["ID"]}/INPUT/REJECT \"";
            $SCRIPT[] = "{$echo} \"Apply rules on bridge br{$ligne["ID"]} log block={$ligne["isFWLogBlocked"]}\"";
            $interface = "br{$ligne["ID"]}";
            $InInterface = " -i {$interface} ";
            $SCRIPT[] = "{$iptables} -I INPUT {$InInterface} -s 127.0.0.1 {$MARKLOG} -j ACCEPT || true";
//.........这里部分代码省略.........
开发者ID:articatech,项目名称:artica,代码行数:101,代码来源:exec.firewall.php

示例8: caches_center

function caches_center($aspid = false)
{
    $unix = new unix();
    $umount = $unix->find_program("umount");
    if (!$aspid) {
        $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
        $pid = $unix->get_pid_from_file($pidfile);
        if ($unix->process_exists($pid, basename(__FILE__))) {
            $time = $unix->PROCCESS_TIME_MIN($pid);
            if ($GLOBALS["OUTPUT"]) {
                echo "Stopping......: " . date("H:i:s") . "Already `task` running PID {$pid} since {$time}mn\n";
            }
            system_admin_events("stop_squid::Already task running PID {$pid} since {$time}mn", __FUNCTION__, __FILE__, __LINE__, "proxy");
            return;
        }
        @file_put_contents($pidfile, getmypid());
    }
    if (system_is_overloaded(__FILE__)) {
        return;
    }
    $rm = $unix->find_program("rm");
    $q = new mysql();
    if (!$q->FIELD_EXISTS("squid_caches_center", "percenttext", "artica_backup")) {
        $sql = "ALTER TABLE `squid_caches_center` ADD `percenttext` VARCHAR(10)";
        $q->QUERY_SQL($sql, "artica_backup");
        if (!$q->ok) {
            writelogs("{$this->mysql_error}\n{$sql}", __CLASS__ . '/' . __FUNCTION__, __FILE__, __LINE__);
        }
    }
    $sql = "SELECT * FROM squid_caches_center WHERE `remove`=1";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        squid_admin_mysql(1, "MySQL error {$q->mysql_error}", "{$q->mysql_error}");
        return;
    }
    while ($ligne = mysql_fetch_assoc($results)) {
        $ID = $ligne["ID"];
        $cache_dir = $ligne["cache_dir"];
        $cache_type = $ligne["cache_type"];
        if ($cache_type == "Cachenull") {
            $q->QUERY_SQL("DELETE FROM squid_caches_center WHERE ID={$ID}", "artica_backup");
            continue;
        }
        if ($cache_type == "tmpfs") {
            $cache_dir = "/home/squid/cache/MemBooster{$ID}";
        }
        if (is_link($cache_dir)) {
            $cache_dir = readlink($cache_dir);
        }
        shell_exec("{$rm} -rf {$cache_dir}");
        squid_admin_mysql(1, "Cache {$cache_dir} was deleted from DISK", "ID={$ID}\ndirectory={$cache_dir}");
        $q->QUERY_SQL("DELETE FROM squid_caches_center WHERE ID={$ID}", "artica_backup");
        if ($cache_type == "tmpfs") {
            shell_exec("{$umount} -l {$cache_dir}");
        }
        if (!$q->ok) {
            squid_admin_mysql(1, "MySQL error {$q->mysql_error}", "ID={$ID}\ndirectory={$cache_dir}");
        }
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "Cache Center done\n";
    }
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:63,代码来源:exec.squid.watchdog.php

示例9: smtp_generic_map_add

function smtp_generic_map_add()
{
    $ou = base64_decode($_POST["ou"]);
    $ID = intval($_POST["ID"]);
    $md5 = md5($_POST["source_pattern"] . "{$ou}{$_POST["smtp_generic_maps"]}{$_POST["recipient_canonical_maps"]}{$_POST["sender_canonical_maps"]}");
    $q = new mysql();
    if (!$q->FIELD_EXISTS("smtp_generic_maps", "smtp_generic_maps", "artica_backup")) {
        $sql = "ALTER TABLE `smtp_generic_maps` ADD `smtp_generic_maps` smallint(1)  NOT NULL DEFAULT '1',\n\t\t\t\tADD INDEX ( `smtp_generic_maps` )";
        $q->QUERY_SQL($sql, 'artica_backup');
    }
    if (!$q->FIELD_EXISTS("smtp_generic_maps", "recipient_canonical_maps", "artica_backup")) {
        $sql = "ALTER TABLE `smtp_generic_maps` ADD `recipient_canonical_maps` smallint(1)  NOT NULL DEFAULT '0',\n\t\t\t\tADD INDEX ( `recipient_canonical_maps` )";
        $q->QUERY_SQL($sql, 'artica_backup');
    }
    if (!$q->FIELD_EXISTS("smtp_generic_maps", "sender_canonical_maps", "artica_backup")) {
        $sql = "ALTER TABLE `smtp_generic_maps` ADD `sender_canonical_maps` smallint(1)  NOT NULL DEFAULT '0',\n\t\t\t\tADD INDEX ( `sender_canonical_maps` )";
        $q->QUERY_SQL($sql, 'artica_backup');
    }
    if ($ID == 0) {
        $sql = "INSERT INTO smtp_generic_maps (generic_from,generic_to,ou,zmd5,smtp_generic_maps,recipient_canonical_maps,sender_canonical_maps)\n\t\tVALUES('{$_POST["source_pattern"]}','{$_POST["destination_pattern"]}','{$ou}','{$md5}',\n\t\t'{$_POST["smtp_generic_maps"]}','{$_POST["recipient_canonical_maps"]}','{$_POST["sender_canonical_maps"]}'\n\t\t\n\t\t);";
    } else {
        $sql = "UPDATE smtp_generic_maps SET generic_from='{$_POST["source_pattern"]}',\n\t\tgeneric_to='{$_POST["destination_pattern"]}',\n\t\tzmd5='{$md5}',\n\t\tsender_canonical_maps='{$_POST["sender_canonical_maps"]}',\n\t\trecipient_canonical_maps='{$_POST["recipient_canonical_maps"]}',\n\t\tsmtp_generic_maps='{$_POST["smtp_generic_maps"]}'\n\t\tWHERE ID={$ID}";
    }
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    //$sock=new sockets();
    //$sock->getFrameWork("cmd.php?postfix-hash-smtp-generic=yes");
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:31,代码来源:postfix.smtp.generic.maps.php

示例10: save

function save()
{
    $sock = new sockets();
    $FireHolConf = unserialize(base64_decode($sock->GET_INFO("FireHolConf")));
    while (list($index, $ligne) = each($_POST)) {
        $FireHolConf[$index] = $ligne;
    }
    $sock->SaveConfigFile(base64_encode(serialize($FireHolConf)), "FireHolConf");
    //$FireHolConf=unserialize(base64_decode(@file_get_contents("/etc/artica-postfix/settings/Daemons/FireHolConf")));
    $IF_WAN = $FireHolConf["IF_WAN"];
    $IF_LAN = $FireHolConf["IF_LAN"];
    if ($IF_WAN == null) {
        return;
    }
    $zMD5 = md5($IF_LAN . $IF_WAN);
    if ($IF_LAN == null) {
        echo "No LAN interface defined !";
        return;
    }
    if ($IF_WAN == null) {
        echo "No WAN interface defined !";
        return;
    }
    $q = new mysql();
    $sql = "CREATE TABLE IF NOT EXISTS `pnic_bridges` (\n\t\t`ID` INT(10) NOT NULL AUTO_INCREMENT,\n\t\t`zMD5` varchar(90) NOT NULL,\n\t\t`nic_from` varchar(50) NOT NULL,\n\t\t`nic_to` varchar(50) NOT NULL,\n\t\t`enabled` smallint(1) NOT NULL DEFAULT 1,\n\t\t`DenyDHCP` smallint(1) NOT NULL DEFAULT 1,\n\t\tPRIMARY KEY (`ID`),\n\t\tUNIQUE KEY (`zMD5`),\n\t\tKEY `nic_from` (`nic_from`),\n\t\tKEY `nic_to` (`nic_to`),\n\t\tKEY `DenyDHCP` (`DenyDHCP`),\n\t\tKEY `enabled` (`enabled`)\n\t\t) ENGINE=MYISAM;";
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->FIELD_EXISTS("pnic_bridges", "zMD5", "artica_backup")) {
        $q->QUERY_SQL("ALTER TABLE pnic_bridges ADD zMD5 varchar(90), ADD UNIQUE KEY (`zMD5`)", "artica_backup");
        if (!$q->ok) {
            echo "ALTER TABLE pnic_bridges failed\n{$q->mysql_error}\n";
            return;
        }
    }
    if (!$q->FIELD_EXISTS("pnic_bridges", "STP", "artica_backup")) {
        $q->QUERY_SQL("ALTER TABLE pnic_bridges ADD STP smallint(1) DEFAULT 1", "artica_backup");
        if (!$q->ok) {
            echo "ALTER TABLE STP failed\n{$q->mysql_error}\n";
            return;
        }
    }
    if (!$q->FIELD_EXISTS("pnic_bridges", "DenyDHCP", "artica_backup")) {
        $q->QUERY_SQL("ALTER TABLE pnic_bridges ADD DenyDHCP smallint(1) DEFAULT 1", "artica_backup");
        if (!$q->ok) {
            echo "ALTER TABLE DenyDHCP failed\n{$q->mysql_error}\n";
            return;
        }
    }
    if (!$q->FIELD_EXISTS("pnic_bridges", "DenyCountries", "artica_backup")) {
        $q->QUERY_SQL("ALTER TABLE pnic_bridges ADD DenyCountries smallint(1) DEFAULT 0", "artica_backup");
        if (!$q->ok) {
            echo "ALTER TABLE DenyCountries failed\n{$q->mysql_error}\n";
            return;
        }
    }
    if (!$q->FIELD_EXISTS("pnic_bridges", "masquerading", "artica_backup")) {
        $q->QUERY_SQL("ALTER TABLE pnic_bridges ADD masquerading smallint(1) DEFAULT 0", "artica_backup");
        if (!$q->ok) {
            echo "ALTER TABLE masquerading failed\n{$q->mysql_error}\n";
            return;
        }
    }
    if (!$q->FIELD_EXISTS("pnic_bridges", "masquerading_invert", "artica_backup")) {
        $q->QUERY_SQL("ALTER TABLE pnic_bridges ADD masquerading_invert smallint(1) DEFAULT 0", "artica_backup");
        if (!$q->ok) {
            echo "ALTER TABLE masquerading_invert failed\n{$q->mysql_error}\n";
            return;
        }
    }
    $sql = "INSERT INTO pnic_bridges (zMD5,nic_from,nic_to,enabled,STP,DenyDHCP,masquerading,masquerading_invert)\n\tVALUES ('{$zMD5}','{$IF_LAN}','{$IF_WAN}','1','1','1','1','0')";
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    $nic = new system_nic($IF_WAN);
    $nic->firewall_policy = "reject";
    $nic->firewall_behavior = 2;
    $nic->firewall_masquerade = 1;
    $nic->firewall_artica = 1;
    $nic->SaveNic();
    $nic = new system_nic($IF_LAN);
    $nic->firewall_policy = "accept";
    $nic->firewall_behavior = 1;
    $nic->SaveNic();
    $sock->GET_INFO("FireHolConfigured", 1);
    $sock->SET_INFO("FireHolEnable", 1);
    $sock->SET_INFO("FireHolRouter", 1);
    $sock->SET_INFO("FireHolConfigured", 1);
    $sock->SaveConfigFile(base64_encode(serialize(array())), "FireHolConf");
}
开发者ID:articatech,项目名称:artica,代码行数:90,代码来源:firehol.wizard.router.php

示例11: sender_canonical_maps_build

function sender_canonical_maps_build()
{
    $ldap = new clladp();
    $filter = "(&(objectClass=userAccount)(mail=*))";
    $attrs = array("mail", "SenderCanonical");
    $dn = "{$ldap->suffix}";
    $hash = $ldap->Ldap_search($dn, $filter, $attrs);
    for ($i = 0; $i < $hash["count"]; $i++) {
        $mail = $hash[$i]["mail"][0];
        if (!isset($hash[$i][strtolower("SenderCanonical")])) {
            continue;
        }
        $canonical = $hash[$i][strtolower("SenderCanonical")][0];
        if ($canonical == null) {
            continue;
        }
        $GLOBALS["sender_canonical_maps"][] = "{$mail}\t{$canonical}";
        $GLOBALS["smtp_generic_maps"][] = "{$mail}\t{$canonical}";
    }
    $q = new mysql();
    if (!$q->FIELD_EXISTS("smtp_generic_maps", "sender_canonical_maps", "artica_backup")) {
        $sql = "ALTER TABLE `smtp_generic_maps` ADD `sender_canonical_maps` smallint(1)  NOT NULL DEFAULT '0',ADD INDEX ( `sender_canonical_maps` )";
        $q->QUERY_SQL($sql, 'artica_backup');
    }
    $sql = "SELECT * FROM smtp_generic_maps WHERE ou='POSTFIX_MAIN' AND sender_canonical_maps=1 ORDER BY generic_from";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        if (trim($ligne["generic_from"]) == null) {
            continue;
        }
        if (trim($ligne["generic_to"]) == null) {
            continue;
        }
        $GLOBALS["sender_canonical_maps"][] = "{$ligne["generic_from"]}\t{$ligne["generic_to"]}";
    }
}
开发者ID:articatech,项目名称:artica,代码行数:36,代码来源:exec.postfix.hashtables.php

示例12: status_squid_left


//.........这里部分代码省略.........
			
			
			
			if($SquidEnableRockStore==1){
				$SquidRockStoreSize=FormatBytes($SquidRockStoreSize*1024);
				$SquidEnableRockStoreCK="20-check.png";
			}else{
				$SquidRockStoreSize="{disabled}";
			}
			
			$smptr="		
			<tr>
				<td width=1%><img src='img/$DisableSquidSNMPModeCK'></td>
				<td class=legend nowrap style='font-size:12px'>SMP:</td>
				<td style='font-size:14px'>
				<a href=\"javascript:blur();\"
				OnClick=\"javascript:Loadjs('squid.caches32.php?smp-js=yes&uuid={$_GET["uuid"]}');\"
				style='$styleText;text-decoration:underline'>$DisableSquidSNMPModeText</a></span></td>
			</tr>
			<tr>
				<td width=1%><img src='img/$SquidEnableRockStoreCK'></td>
				<td class=legend nowrap style='font-size:12px'>Rock store:</td>
				<td style='font-size:14px'>
				<a href=\"javascript:blur();\"
				OnClick=\"javascript:Loadjs('squid.rockstore.php');\"
				style='$styleText;text-decoration:underline'>$SquidRockStoreSize</a></td>
			</tr>";			
			
		}
	}
	
	
	$qs=new mysql();
	if(!$qs->FIELD_EXISTS("nics","ucarp-enable","artica_backup")){$qs->QUERY_SQL("ALTER TABLE `nics` ADD `ucarp-enable` smallint( 1 ) NULL DEFAULT '0'",'artica_backup'); }
	$sql="SELECT COUNT(*) as tcount FROM nics WHERE `ucarp-enable`=1";
	$ligne2=mysql_fetch_array($qs->QUERY_SQL($sql,"artica_backup"));
	$failover_icon="20-check-grey.png";
	if($ligne2["tcount"]==0){
		$failover_text="{disabled}";
	}else{
		$failover_text="{enabled}";
		$failover_icon="20-check.png";
	}
	if(!$users->UCARP_INSTALLED){
		$failover_text="-";
		$failover_icon="20-check-grey.png";
	}
	
	if($CacheManagement2==1){$smptr=null;}
	$DisableAnyCache=$sock->GET_INFO("DisableAnyCache");
	if(!is_numeric($DisableAnyCache)){$DisableAnyCache=0;}
	$SquidCacheLevel=$sock->GET_INFO("SquidCacheLevel");
	if(!is_numeric($SquidCacheLevel)){$SquidCacheLevel=4;}
	if($SquidCacheLevel==0){$DisableAnyCache=1;}
	
	
	$hasProxyTransparent=$sock->GET_INFO("hasProxyTransparent");
	if(!is_numeric($hasProxyTransparent)){$hasProxyTransparent=0;}
	
	$hasProxyTransparentText="{disabled}";
	$hasProxyTransparentCheck="20-check-grey.png";
	
	$DisableAnyCacheText="{enabled}";
	$DisableAnyCacheCheck="20-check.png";
	
	if($hasProxyTransparent==1){
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:67,代码来源:squid.main.quicklinks.php

示例13: rule_new_save

function rule_new_save()
{
    $rulename = mysql_escape_string2(url_decode_special_tool($_POST["rule-new"]));
    $eth = $_POST["eth"];
    $sql = "INSERT IGNORE INTO iptables_main (`rulename`,`eth`,`accepttype`,`enabled`) \n\tVALUES ('{$rulename}','{$eth}','ACCEPT','1')";
    $q = new mysql();
    if (!$q->FIELD_EXISTS("iptables_main", "service", "artica_backup")) {
        $q->QUERY_SQL("ALTER TABLE `iptables_main` ADD `service` varchar(50) NULL ,ADD INDEX ( service );", "artica_backup");
    }
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo $q->mysql_error;
    }
}
开发者ID:articatech,项目名称:artica,代码行数:14,代码来源:firehol.nic.rules.php

示例14: rule_save

function rule_save(){
	$ID=$_POST["rule-save"];
	$_POST["rulename"]=mysql_escape_string2(url_decode_special_tool($_POST["rulename"]));
	
	
	$FADD_FIELDS[]="`rulename`";
	$FADD_FIELDS[]="`proto`";
	$FADD_FIELDS[]="`accepttype`";
	$FADD_FIELDS[]="`enabled`";
	$FADD_FIELDS[]="`OverideNet`";
	$FADD_FIELDS[]="`MOD`";
	$FADD_FIELDS[]="`eth`";
	$FADD_FIELDS[]="`source_group`";
	$FADD_FIELDS[]="`dest_group`";
	$FADD_FIELDS[]="`destport_group`";
	$FADD_FIELDS[]="`zOrder`";
	$FADD_FIELDS[]="`ForwardTo`";
	$FADD_FIELDS[]="`ForwardNIC`";
	$FADD_FIELDS[]="`L7Mark`";
	$FADD_FIELDS[]="`jlog`";
	
	
	
	$FADD_VALS[]=$_POST["rulename"];
	$FADD_VALS[]=$_POST["proto"];
	$FADD_VALS[]=$_POST["accepttype"];
	$FADD_VALS[]=$_POST["enabled"];
	$FADD_VALS[]=$_POST["OverideNet"];
	$FADD_VALS[]=$_POST["table"];
	$FADD_VALS[]=$_POST["interface"];
	$FADD_VALS[]=$_POST["source_group"];
	$FADD_VALS[]=$_POST["dest_group"];
	$FADD_VALS[]=$_POST["destport_group"];
	$FADD_VALS[]=$_POST["zOrder"];
	$FADD_VALS[]=$_POST["ForwardTo"];
	$FADD_VALS[]=$_POST["ForwardNIC"];
	$FADD_VALS[]=$_POST["L7Mark"];
	$FADD_VALS[]=$_POST["jlog"];
	
	
	
	if(isset($_POST["MARK"])){
		$FADD_FIELDS[]="`MARK`";
		$FADD_VALS[]=$_POST["MARK"];
	
	}
	
	if(isset($_POST["QOS"])){
		$FADD_FIELDS[]="`QOS`";
		$FADD_VALS[]=$_POST["QOS"];
	
	}

	while (list ($num, $field) = each ($FADD_FIELDS)){
		$EDIT_VALS[]="$field ='".$FADD_VALS[$num]."'";
	}
	
	reset($FADD_VALS);
	while (list ($num, $field) = each ($FADD_VALS)){
		$ITEMSADD[]="'$field'";
	}
	
	$q=new mysql();
	if(!$q->FIELD_EXISTS("iptables_main","MARK","artica_backup")){
		$sql="ALTER TABLE `iptables_main` ADD `MARK` INT( 10 ) NOT NULL DEFAULT 0";
		$q->QUERY_SQL($sql,"artica_backup");
	}
	
	if(!$q->FIELD_EXISTS("iptables_main","QOS","artica_backup")){
		$sql="ALTER TABLE `iptables_main` ADD `QOS` INT( 10 ) NOT NULL DEFAULT 0";
		$q->QUERY_SQL($sql,"artica_backup");
	}
	
	if(!$q->FIELD_EXISTS("iptables_main","L7Mark","artica_backup")){
		$sql="ALTER TABLE `iptables_main` ADD `L7Mark` INT( 10 ) NULL DEFAULT 0,ADD INDEX ( L7Mark ) ";
		$q->QUERY_SQL($sql,"artica_backup");
	}
	if(!$q->FIELD_EXISTS("iptables_main","jlog","artica_backup")){
		$sql="ALTER TABLE `iptables_main` ADD `jlog` smallint( 1 ) NOT NULL DEFAULT 0,ADD INDEX ( jlog )";
		$q->QUERY_SQL($sql,"artica_backup");
	}

	
	if($ID==0){
		$sql="INSERT IGNORE INTO iptables_main ( ". @implode(",", $FADD_FIELDS).") VALUES (".@implode(",", $ITEMSADD).")";
		
	}else{
		$sql="UPDATE iptables_main SET  ". @implode(",", $EDIT_VALS)." WHERE ID='$ID'";
		
	}
	
	
	

	
	
	$q->QUERY_SQL($sql,"artica_backup");
	if(!$q->ok){echo $q->mysql_error."\n$sql";}
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:99,代码来源:system.firewall.php

示例15: Save

function Save()
{
    $q = new mysql();
    $sql = "CREATE TABLE IF NOT EXISTS `artica_backup`.`artica_webdav` (\n\t\t\t\t`ID` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,\n\t\t\t\t`directory` VARCHAR(128) NOT NULL,\n\t\t\t\t`write` smallint(1),\n\t\t\t\tUNIQUE KEY `directory` (`directory`)\n\t\t\n\t\t\t\t) ENGINE=MYISAM;";
    $q->QUERY_SQL($sql, 'artica_backup');
    if (!$q->FIELD_EXISTS("artica_webdav", "write", "artica_backup")) {
        $sql = "ALTER TABLE `artica_webdav` ADD `write` smallint( 1 ) NOT NULL DEFAULT 0";
        $q->QUERY_SQL($sql, "artica_backup");
    }
    $q->QUERY_SQL("INSERT IGNORE INTO artica_webdav (`directory`,`write`) VALUES ('{$_POST["directory"]}','{$_POST["write"]}')", "artica_backup");
    if (!$q->ok) {
        echo $q->mysql_error;
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:14,代码来源:artica.webdav.php


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