#!/usr/bin/php <?php if ($argv[1] == "--delete") { DeleteRules(); return; } CreateRules(); function CreateRules() { $iptables = find_program("iptables"); $iptables_save = "/sbin/iptables-save"; $iptables_restore = "/sbin/iptables-restore"; $MIKROTIK_FIREWALL = unserialize(@file_get_contents("/etc/squid3/MIKROTIK_FIREWALL.array")); DeleteRules(); if (count($MIKROTIK_FIREWALL) == 0) { return; } $suffixTables = "-m comment --comment \"ArticaMikroTik\""; $SquidMikrotikMaskerade = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/SquidMikrotikMaskerade")); while (list($INDEX, $ARRAY) = each($MIKROTIK_FIREWALL)) { $PORT = $ARRAY["PORT"]; $SRC_PORT = $ARRAY["SRC_PORT"]; $IPADDR = $ARRAY["IPADDR"]; $cmd = "{$iptables} -t mangle -I PREROUTING -p tcp --dport {$SRC_PORT} -j TPROXY --tproxy-mark 0x1/0x1 --on-port {$PORT} {$suffixTables}"; echo "{$cmd}\n"; exec("{$cmd} >/dev/null 2>&1"); $cmd = "{$iptables} -t nat -I PREROUTING -s {$IPADDR} -p tcp --dport {$SRC_PORT} -j ACCEPT {$suffixTables}"; //$cmd="$iptables -t nat -I PREROUTING -p tcp --dport $SRC_PORT -j ACCEPT $suffixTables"; echo "{$cmd}\n"; exec("{$cmd} >/dev/null 2>&1"); }
<?php # Create/delete recurring parking rules. require "./auth.php"; require_once "./_logic.php"; switch ($_POST["action"]) { case "create": $startDate = $_POST["create_start_date"]; $endDate = $_POST["create_end_date"]; $startTime = $_POST["create_start_hour"] . ":" . $_POST["create_start_minute"] . ":00"; $endTime = $_POST["create_end_hour"] . ":" . $_POST["create_end_minute"] . ":00"; $newRuleIDs = @CreateRules($_POST["create_lots"], $_POST["create_passes"], (string) $startDate, (string) $endDate, (string) $startTime, (string) $endTime, implode($_POST["create_days"], ",")); if ($newRuleIDs != null) { ui_info("Rules Created: <strong>" . count($newRuleIDs) . "</strong>"); } else { ui_alert("Rules Created: <strong>" . count($newRuleIDs) . "</strong>"); } break; case "delete": $results = @DeleteRules($_POST["delete_rules"]); if ($results > 0) { ui_info("Rules Deleted: <strong>" . $results . "</strong>"); } else { ui_alert("No Rules Deleted."); } break; default: break; } $passes = GetPassTypes("name"); $all_lots = GetLots();