# Перенаправление с www
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
# Добавляем слэш
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\..+$
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1/ [R=301,L]
# Перенаправление с http на https
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{REQUEST_URI} !^/1c_exchange.php
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# Склейка файлов index
RewriteRule ^(.*)index(\.(php|html?))?$ https://%{HTTP_HOST}/$1 [R=301,L]
/system script add name=script_block policy=ftp,reboot,read,write,policy,test,password,sensitive source="
:foreach addr in=[/ip dns cache all find where (name~"vk.com" || name~"userapi.com" || name~"twitch.tv") && (type="A")] do={
:local tmpAddress [/ip dns cache get $addr data];
:delay 300ms;
:if ([/ip firewall address-list find where address=$tmpAddress] = "") do={
:local cacheName [/ip dns cache get $addr name];
:log info "added entry: $cacheName $tmpAddress";
/ip firewall address-list add address=$tmpAddress list=block timeout=24h comment=$cacheName;
}
};"
/system scheduler add interval=10m name=schedule_block-sites on-event=script_block policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive
/ip firewall filter add action=reject chain=forward dst-address-list=block protocol=tcp reject-with=tcp-reset
RewriteRule ^(/?images/[^\.]+)\.(png|jpg|jpeg|gif)$ /watermark.php?img=import/$1.$2 [QSA,L]
$stamp = imagecreatefrompng('watermark.png');
$im = imagecreatefromstring(file_get_contents($_GET['img']));
$pc = imagesx($im) / 300;
$s_w = imagesx($stamp) * $pc;
$s_h = imagesy($stamp) * $pc;
$stamp_p = imagecreatetruecolor($s_w, $s_h);
imagealphablending($stamp_p, false);
imagesavealpha($stamp_p, true);
imagecopyresampled($stamp_p, $stamp, 0, 0, 0, 0, $s_w, $s_h, imagesx($stamp), imagesy($stamp));
$marge_right = 10;
$marge_bottom = 10;
$sx = imagesx($stamp_p);
$sy = imagesy($stamp_p);
imagecopy($im, $stamp_p, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, $sx, $sy);
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
SELECT MIN(`datetime`), MAX(`datetime`)
FROM `table`
WHERE TIMESTAMP BETWEEN "2014-10-01" AND "2017-10-31"
INTO @min_d, @max_d;
SET @n:=date(@max_d + INTERVAL 1 DAY);
SELECT * FROM
/* Все пользователи */
(SELECT DISTINCT `user`
FROM `table`
WHERE
NOT ISNULL(`user`)
) AS `users`
RIGHT OUTER JOIN
/* Все даты запрошенных дней */
(SELECT (SELECT @n:= @n - INTERVAL 1 DAY) AS `date`
FROM `table`
WHERE @n >= DATE_SUB(@max_d, INTERVAL DATEDIFF(@max_d,@min_d) DAY) AND
NOT ISNULL(`user`)
) AS `datetime`
ON TRUE
$res = $DBH->query("SELECT groups as id, (SELECT pid FROM cat_groups WHERE id = groups) as pid, count(groups) AS col FROM cat_prod WHERE visible = 1
AND id IN(SELECT DISTINCT prod_id FROM cat_prod_prop)
GROUP BY groups");
$res = $res->fetchAll(PDO::FETCH_ASSOC);
$res = array_reverse($res);
foreach ($res as $k => $v) {
$keys = array_keys(array_column($res, 'pid'), $v['id']);
foreach ($keys as $w) {
$res[$k]['col'] += $res[$w]['col'];
}
}
foreach ($res as $row) {
$STH = $DBH->prepare("UPDATE cat_groups SET count = :count WHERE id = :id");
$STH->bindParam(':count', $row['col']);
$STH->bindParam(':id', $row['id']);
$STH->execute();
}
id;pid;count
1;0;34
2;1;11
3;1;25
4;3;12
5;3;20
6;0;97
7;6;36
8;6;25
9;0;15
$('#button-c-p-save-file').attr({'data-button-id-file':id_file, 'data-button-id-app':id_app,и тд.});