function findRoute(routeMap, from, to, secureLevel) {
let route;
while (!Array.isArray(route = tryFindRoute(routeMap, from, to, secureLevel))) {
let invalidRoute, invalidRouteIndex;
invalidRoute = routeMap[route][6]
.sort((a, b) => a - b)
.reverse()
.find(e => e > from && e > route);
invalidRouteIndex = routeMap[route][6].indexOf(invalidRoute);
routeMap[route][6].splice(invalidRouteIndex, 1);
}
return route
}
function tryFindRoute(routeMap, from, to, secureLevel) {
let route = [from], routePoint;
for (let i = 0, len = routeMap.length; i < len; i++) {
let el = routeMap[i];
if (route[route.length - 1] > el[0]){
continue
}
routePoint = el[6]
.sort((a, b) => a - b)
.reverse()
.find(e => e > from && e > i);
if (el[0] !== to) {
if (!routePoint || el[5] < secureLevel) {
route = route[Math.max(0, route.length - 2)];
break
}
route.push(routePoint)
}
}
return route;
}
let x, y, z;
let routeMap = [
[0, "name", x, y, z, 10, [1, 2]],
[1, "name", x, y, z, 10, [0, 3]],
[2, "name", x, y, z, 5, [0, 3, 4]],
[3, "name", x, y, z, 10, [2, 1, 4]],
[4, "name", x, y, z, 10, [3, 2, 5]],
[5, "name", x, y, z, 10, [4]]
];
let shortRoute = findRoute(routeMap, 0, 5, 0);
let inSecureshortRoute = findRoute(routeMap, 0, 5, 10);
console.log('самый короткий из безопасных путей', inSecureshortRoute);
console.log('самый короткий путь', shortRoute);
Нашел такой вариант но не могу понять как его применять
# Разрешит локалный траффик
iptables -A INPUT -i lo -j ACCEPT
# Разрешит пинг
iptables -A INPUT -p icmp -j ACCEPT
# разрешит порты 21,22,25,80,81,443
iptables -A INPUT -p tcp -m multiport --port 21,22,25,80,81,443 -j ACCEPT
# Разрешит сессии
iptables -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
# ну и запретит все остальное
iptables -A INPUT -j DROP
$data = array(
$key->naimenovanie,
$key->proizvoditel,
$key->nds,
'<span id="cena_data">' . $key->cena . '</span>',
$key->srok,
$key->zhvl,
$key->ostatok,
'<input type"text" id="kol_data">',
'<input type="text" id="summa_data">'
);
$jsonData = json_encode($data);
var check = function () {
var hours = new Date().getHours();
if (hours < 8) {
document.body.classList.add('.noch');
document.body.classList.remove('.vecher');
}
elseif(hours < 12 && hours >= 8) {
document.body.classList.add('.utro');
document.body.classList.remove('.noch');
}
elseif(hours >= 12 && hours < 17) {
document.body.classList.add('.den');
document.body.classList.remove('.utro');
}
elseif(hours >= 17 && hours <= 20) {
document.body.classList.add('.vecher');
document.body.classList.remove('.den');
}
}
var name = $(this).find("input[name='name" + i + "']");
<form name="mySuperForm" id="mySuperForm" method="GET" action="http://www.testsite/search">
<input type="text" name="variable1"/>
<input type="text" name="variable2"/>
<button type="submit">submit</button>
</form>