function build() { $sock = new sockets(); $DenyHaproxyConf = intval($sock->GET_INFO("DenyHaproxyConf")); if ($DenyHaproxyConf == 1) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, Configuration is blocked..\n"; } return; } $hap = new haproxy(); $conf = $hap->buildconf(); @unlink("/etc/haproxy/haproxy.cfg"); if (trim($conf) == null) { return; } @mkdir("/etc/haproxy", 0755, true); @file_put_contents("/etc/haproxy/haproxy.cfg", $conf); Transparents_modes(); rsyslog_conf(); }
function EXPLAIN_THIS_RULE($ruleid) { $q = new mysql(); $tpl = new templates(); $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM haproxy_acls_rules WHERE ID='{$ruleid}'", "artica_backup")); if (!$q->ok) { return $q->mysql_error; } $haproxy = new haproxy(); $rule_action = $ligne["rule_action"]; $rule_action_data = $ligne["rule_action_data"]; if ($rule_action == 0) { return $tpl->_ENGINE_parse_body("{do_nothing}"); } if ($rule_action == 1) { $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT groupname FROM haproxy_backends_groups WHERE ID='{$rule_action_data}'", "artica_backup")); $to = $ligne["groupname"]; $rule_action_text = $tpl->_ENGINE_parse_body($haproxy->acls_actions[$rule_action] . "{to} {$to}"); } if ($rule_action == 2) { $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT backendname FROM haproxy_backends WHERE ID='{$rule_action_data}'", "artica_backup")); $to = $ligne["backendname"]; $rule_action_text = $tpl->_ENGINE_parse_body($haproxy->acls_actions[$rule_action]) . " {to} {$to}"; } if ($rule_action == 3) { $rule_action_text = $tpl->_ENGINE_parse_body("{deny_access}"); } $table = "SELECT haproxy_acls_link.groupid,\n\thaproxy_acls_link.ID as tid,\n\thaproxy_acls_link.revert,\n\thaproxy_acls_link.operator,\n\thaproxy_acls_link.zorder as torder,\n\thaproxy_acls_groups.* FROM haproxy_acls_link,haproxy_acls_groups\n\tWHERE haproxy_acls_link.groupid=haproxy_acls_groups.ID AND \n\thaproxy_acls_link.ruleid={$ruleid} AND\n\thaproxy_acls_groups.enabled=1\n\tORDER BY haproxy_acls_link.zorder"; $results = $q->QUERY_SQL($table, "artica_backup"); $acl = new haproxy(); $c = 0; while ($ligne = mysql_fetch_assoc($results)) { $revert = $ligne["revert"]; $revert_text = null; if ($revert == 1) { $revert_text = "{not} "; } $operator = $ligne["operator"]; $operator = $acl->acl_operator[$operator]; $operator = $tpl->_ENGINE_parse_body($operator) . " "; if ($c == 0) { $operator = null; } $arrayF = $acl->FlexArray($ligne['ID']); $items = $arrayF["ITEMS"]; if ($items == 0) { continue; } $f[] = "{$operator}{$revert_text}{$arrayF["ROW"]} <span style='font-size:14px'>({$items} {items})</span>"; $c++; } if (count($f) == 0) { return $tpl->_ENGINE_parse_body("{do_nothing}"); } return $tpl->_ENGINE_parse_body("<span style='font-size:14px'> {for_objects} " . @implode("<br>", $f) . "<br>{then} {$rule_action_text}</span>"); }
function items_list() { //ini_set('html_errors',0);ini_set('display_errors', 1);ini_set('error_reporting', E_ALL);ini_set('error_prepend_string','');ini_set('error_append_string',''); $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql(); $ID = $_GET["aclid"]; $t0 = $_GET["t"]; $rp = 50; $search = '%'; $table = "(SELECT haproxy_acls_link.groupid,\n\thaproxy_acls_link.ID as tid,\n\thaproxy_acls_link.revert,\n\thaproxy_acls_link.operator,\n\thaproxy_acls_link.zorder as torder,\n\thaproxy_acls_groups.* FROM haproxy_acls_link,haproxy_acls_groups \n\tWHERE haproxy_acls_link.groupid=haproxy_acls_groups.ID AND haproxy_acls_link.ruleid={$ID}\n\tORDER BY haproxy_acls_link.zorder\n\t) as t"; $page = 1; if ($q->COUNT_ROWS("haproxy_acls_link", "artica_backup") == 0) { json_error_show("No datas haproxy_acls_link Empty"); } 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) { $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 . "\n{$sql}"); } $total = $ligne["TCOUNT"]; } else { $sql = "SELECT COUNT(*) as TCOUNT FROM {$table}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup")); if (!$q->ok) { json_error_show($q->mysql_error . "\n{$sql}"); } $total = $ligne["TCOUNT"]; } if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $pageStart = ($page - 1) * $rp; $limitSql = "LIMIT {$pageStart}, {$rp}"; $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} {$ORDER} {$limitSql}"; $results = $q->QUERY_SQL($sql, "artica_backup"); if ($GLOBALS["VERBOSE"]) { echo "{$sql}<br>\n"; } if (!$q->ok) { json_error_show($q->mysql_error . "\n{$sql}"); } $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); $CountofRows = mysql_num_rows($results); if ($GLOBALS["VERBOSE"]) { echo "CountofRows = {$CountofRows}<br>\n"; } if ($CountofRows == 0) { json_error_show("No data"); } $rules = $tpl->_ENGINE_parse_body("{rules}"); $acl = new haproxy(); while ($ligne = mysql_fetch_assoc($results)) { $val = 0; $mkey = $ligne["tid"]; $arrayF = $acl->FlexArray($ligne['ID']); $delete = imgsimple("delete-24.png", null, "DeleteObjectLinks('{$mkey}')"); $negation = Field_checkbox("negation-{$mkey}", 1, $ligne["revert"], "ChangeNegation('{$mkey}')"); $operator = $ligne["operator"]; $operator = $acl->acl_operator[$operator]; $operator = $tpl->_ENGINE_parse_body($operator); $up = imgsimple("arrow-up-16.png", "", "AclGroupUpDown('{$mkey}',0)"); $down = imgsimple("arrow-down-18.png", "", "AclGroupUpDown('{$mkey}',1)"); if ($ligne["torder"] == 1) { $up = null; } if ($ligne["torder"] == 0) { $up = null; } $operator = "\n\t\t\t\t<a href=\"javascript:blur()\" OnClick=\"javascript:AclGroupOperator('{$mkey}')\"\n\t\t\t\tstyle='text-decoration:underline;font-weight:bolder'>{$operator}</a>"; $data['rows'][] = array('id' => "{$mkey}", 'cell' => array($ligne["torder"], $arrayF["ROW"], "<center>{$negation}</center>", "<center style='font-size:14px;font-weight:bold'>{$operator}</center>", "<span style='font-size:14px;font-weight:bold'>{$arrayF["ITEMS"]}</span>", $up, $down, $delete)); } echo json_encode($data); }