$dir = __DIR__ . DIRECTORY_SEPARATOR;
$linksKey = $links ? '-k' : '';
$filesKey = $files ? '-p' : '';
$command = "C:\\wget.exe -P {$dir} r {$depth} {$linksKey} -l '. {$depth} {$filesKey} -E -nc 2>&1";
SELECT `p`.`title`, `p`.`supplement`, `p`.`link`, `p`.`file`,
`u`.`avatar`, `p`.`pid`, `u`.`lastname`, `u`.`uid`, `c`.`comments`,
CONCAT(IFNULL(`u`.`firstname`, ''), ' ', IFNULL(`u`.`surname`, '')) AS `name`
FROM (
SELECT `c`.`pid`,
JSON_ARRAYAGG(JSON_OBJECT(
'name', CONCAT(IFNULL(`u`.`firstname`, ''), " ", IFNULL(`u`.`surname`, '')),
'avatar', `u`.`avatar`,
'lastname', `u`.`lastname`,
'value', `c`.`value`,
'cid', `c`.`cid`,
'answers', `a`.`answers`
)) AS `comments`
FROM (
SELECT `a`.`cid`,
JSON_ARRAYARG(JSON_OBJECT(
'name', CONCAT(IFNULL(`u`.`firstname`, ''), " ", IFNULL(`u`.`surname`, '')),
'avatar', `u`.`avatar`,
'lastname', `u`.`lastname`,
'value', `a`.`value`,
'cid', `a`.`cid`,
'answer', `a`.`answer`
)) AS `answers`
FROM `comments` AS `c`
JOIN `comments` AS `a` ON `a`.`cid` = `c`.`cid`
LEFT JOIN `users` AS `u` ON `u`.`uid` = `a`.`uid`
WHERE `c`.`pid` = :postId
GROUP BY `a`.`cid`
) AS `a`
RIGHT JOIN `comments` AS `c` ON `c`.`cid` = `a`.`cid`
LEFT JOIN `users` AS `u` ON `c`.`uid` = `u`.`uid`
WHERE `c`.`pid` = :postId
GROUP BY `c`.`pid`
) AS `c`
RIGHT JOIN `posts` AS `p` ON `p`.`pid` = `c`.`pid`
LEFT JOIN `users` AS `u` ON `u`.`uid` = `p`.`uid`
WHERE `p`.`pid` = :postId
function() {
let p = ['bWFpbHRvOg==', 'c3VwcG9ydA==', 'QA==', 'cmFuZG9tdXMucnU=']; // 'mailto:', 'support', '@', 'randomus.ru'
let beta = document.getElementById('beta');
let beta_descript = document.getElementById('beta_decript');
beta.href = p.map(atob).join('');
beta.textContent = p.slice(1).map(atob).join('');
beta_descript.classList.remove('is-hidden');
alpha.remove();
}
const CALL_COST = 20;
const DIST_COSTS = [
['range' => 0, 'cost' => 1],
['range' => 10, 'cost' => 1.5],
['range' => 20, 'cost' => 0.5], // 2 - 1.5
];
function distPrice($distance) {
$price = 0;
for ($i = 0; $i < count(DIST_COSTS) && $distance >= DIST_COSTS[$i]['range']; $i += 1) {
$price += ($distance - DIST_COSTS[$i]['range']) * DIST_COSTS[$i]['cost'];
}
return $price;
}
function routePrice($distFrom, $distTo) {
return CALL_COST + distPrice($distTo) - distPrice($distFrom);
}
print routePrice(0, 30) . "\n"; // 85
print routePrice(10, 28) . "\n"; // 69