Jan 15 2015
Redirecting varnish to new backend on the fly
1) Change VCL backend config
Go to your vcl file (in my case /etc/varnish/default.vcl). Edit the backend param to point to another server. Also increase the timeouts since it will take longer than accessing localhost.
backend default {
.host = "backupserver.org";
.port = "80";
.connect_timeout = 120s;
.first_byte_timeout = 600s;
.between_bytes_timeout = 60s;
}
2) Validate VCL script on the fly
sudo varnishd -C -f /etc/varnish/default.vcl
This will notify if any syntax issues exist.
3) Reload the VCL Script without restarting varnish
I utilized:
$varnishadm -T localhost:6082
vcl.load reload01 /etc/varnish/default.vcl vcl.use reload01

Jul 6 2021
PHP – detecting new uploaded images and sending an e-mail with attachments
Quick example today if a php script that I wanted to detect new uploaded images, and then send an e-mail.
I think it’s pretty self-explanatory so won’t go into details. However, keep in mind that it’s mostly simple PHP (not too object-oriented) and also that I make use of the wp_mail function.
$menPath = "path-to-uploaded-files/*.jpg"; $menLast = file_get_contents('timestampFile.txt'); if($menLast === false){ echo 'it is zero'; $menLast = 0; } $menFiles = glob($menPath); $menFiles = array_filter($menFiles, function ($file) use ($menLast) { $mentest = $menLast - filemtime($file); return filemtime($file) > $menLast; }); file_put_contents('timestampFile.txt', time()); if (count($menFiles) > 0 ) { $menText = "images uploaded\r\nFound images count:".count($menFiles) ."Current last timestamp recorded:".date('d-m-Y h:i:s', $menLast )."\r\n" ."Images found:\r\n"; <code>foreach ($menFiles as &$file) { $menText = $menText.date('d-m-Y h:i:s', filemtime($file))."-".basename($file)."\r\n"; }</code> wp_mail( "[email protected]", "files-uploaded", $menText ,'',$menFiles); } ?>By Menelaos Bakopoulos • PHP, Scripts, Uncategorized 0