M van de K

Mijn blog over van alles

Backup emailaccounts with Zimbra zmmailbox — 11/02/2017

Backup emailaccounts with Zimbra zmmailbox

The following code makes it possible to loop through email addresses saved in the file /home/maarten/emailaccounts.txt.

#!/bin/bash

for i in $(cat /home/maarten/emailaccounts.txt);

do zmmailbox -z -m $i getRestURL "//?fmt=tgz" > /backup/$i.$(date +%d-%m-%Y).tgz

done

For now the addresses have to be added manually to the file emailaccounts.txt, but with the zmprov command it’s possible to generate a list of accounts, which can also be used as a source for accounts that have to be exported.

Make sure you have a folder backup in the root of your server (mkdir /backup), and it is writable for the Zimbra user (chown zimbra:zimbra /backup).

Keep WordPress comment_agent and comment_user_IP empty with hooks — 17/12/2016

Keep WordPress comment_agent and comment_user_IP empty with hooks

WordPress saves all kinds of information when someone leaves a comment on your blog/website. Two pieces of information I don’t need from someone who comments on an article are the IP-address of the author and the User Agent of the browser they used to place the comment.

pre_comment_* hooks

WordPress has pre_comment_* hooks which can be used to alter data before it’s put into the database.

I used the following two hooks:

pre_comment_user_ip

This hook filters the comment author’s IP before it is set, so this can be used to alter the IP-address before it’s saved in the database.

// Don't log IP addresses of comment authors.
add_filter( 'pre_comment_user_ip', '__return_zero' );

The filter uses the function __return_zero, which does exactly as it says: the comment_user_ip is set to 0.

Clean up already saved IP-addresses

To clean up the already saved IP-addresses, you execute the following SQL-query (after you made sure you have made a full backup of the database) via phpMyAdmin to your WordPress database:

update wp_comments set comment_author_IP ='' ;

pre_comment_user_agent

This hook filters the comment author’s browser user agent before it is set, so this can be used to alter the User Agent before it’s saved in the database.

// Don't log User Agents of comment authors.
add_filter( 'pre_comment_user_agent', '__return_empty_string' );

The filter uses the function __return_empty_string, which returns an empty string before the data is saved into the database, thus keeping the database clean from unneeded information.

Clean up already saved User Agents

To clean up the already saved User Agents, you execute the following SQL-query (after you made sure you have made a full backup of the database) via phpMyAdmin to your WordPress database:

update wp_comments set comment_agent ='' ;
How to make OCSP stapling on nginx work — 27/04/2016
Using multiple IPv6 addresses on a single interface — 23/04/2016
Disable WordPress Twemoji and Emoji scripts — 13/03/2015

Disable WordPress Twemoji and Emoji scripts

Add the following two lines in your functions.php file.

function remove_emoji_scripts() {
// Dequeue the Emoji script
wp_dequeue_script( 'emoji' );
// Dequeue the Twemoji script
wp_dequeue_script( 'twemoji' );
}
add_action( 'wp_enqueue_scripts', 'remove_emoji_scripts' );