Так что это более общий вопрос о наилучшей практике предотвращения DoS-атак, Я просто пытаюсь понять, как большинство людей обрабатывают вредоносные запросы с того же IP-адреса, что является проблемой, с которой мы сталкиваемся в настоящее время.
Я понял это table: 15, people: 34, places_details: 85, story_1: 21, story_2: 6, story_3: 11, } This array: var categories = ['table', 'people', 'places_details', 'story_1', '...
I have this object:
var count = {
table: 15,
people: 34,
places_details: 85,
story_1: 21,
story_2: 6,
story_3: 11,
}
This array:
var categories = ['table', 'people', 'places_details', 'story_1', 'story_2', 'story_3']
And this function:
function preloadThumbs()
{
var j=0;
for (j=0; j<categories.length; j++)
{
var k=1;
for (k=1; k<=count[categories[j]]; k++)
{
$('#preload').append('<img src="graphics/thumbs/'+categories[j]+'/'+k+'.jpg" />');
}
}
}
...which goes through each folder by the name of categories[j]
and loads all the images into a hidden
What's a way to write the data as a single object and change the corresponding function to interpret it correctly?
var count = {
table: 15,
people: 34,
places_details: 85,
story_1: 21,
story_2: 6,
story_3: 11,
}
function preloadThumbs() {
var preload = $("#preload");
for (var kind in count) {
for (var i = 1; i <= count[kind]; i++) {
preload.append('<img src="graphics/thumbs/' + kind + '/' + i + '.jpg" />');
}
}
}
Это способ хранения всех ваших данных в одном объекте. Я не знаю, для чего вам нужен 2D-массив.
Вы можете напрямую сделать следующее:
for (var i in count) {
var a = i; // a would be "table"
var b = count[i]; //b would be 15.
}