How to mirror (statically) a website?

If you want to copy a website really really fast use HTTrack with following switches:

httrack http://website.com/ -K --sockets=50 --disable-security-limits --max-rate=0

It works on Linux (there’s a native Debian package) and Windows.

Check documentation for other options. K is very important because it affects link generation. If you want original links without html extensions use it like above.

K option cheatsheet:

−K0foo.cgi?q=45 −> foo4B54.html?q=45 (relative URI, default)
−K−> http://www.foobar.com/folder/foo.cgi?q=45 (absolute URL) (−−keep−links[=N])
−K3−> /folder/foo.cgi?q=45 (absolute URI)
−K4−> foo.cgi?q=45 (original URL)
−K5−> http://www.foobar.com/folder/foo4B54.html?q=45 (transparent proxy URL)

And last but not least…

If you want to rewrite original links to html static links use this:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.html
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.html
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/$ /$1/$2/$3.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

How to do something between exact two dates in PHP?

Sometimes you need to show something on your website in timeframe. This snippet will show you how to do it precisely:

Flamingo plugin with proper polish csv export

In case anyone searching I’ve created a modified version of Flamingo plugin for WordPress. Now it exports proper polish csv files out of box (encoded in Windows-1250 and delimited with semicolons).

Download here: http://realhe.ro/pub/flamingo-polish-export.zip

Install using zip upload ability in WordPress or by FTP.

How to access language var from PHP in Grav CMS?

Gravs documentation is a little bit harsh on PHP developers that want to write plugins. What can you do in this situation? Look trough source code, check other plugins or var_dump $this object 🙂

I’ve spent some time searching for an answer how to access language var in plugins class. And this is it:

// Will output two letter ISO 3166-1 alpha-2 code of country
$language =  $this->grav['language']; 
$language->getLanguage();

Have fun with coding and don’t get crazy during that 🙂