sigmoid

..oo..oo..oo..oo..oo..oo..

I use Akismet on my blog and it catches 99% of all spam comments. However lately I noticed I get more than 2000 spam messages and I decided I’d rather ban those IPs. Chances are they are virus infected or zombie machines that potentially not only leave spam messages, but may also engage into other activities.

Before cleaning my spam comments, I first obtain a list of all those IPs from the wordpress table stored in my SQL server:

SELECT DISTINCT `comment_author_IP` FROM `wp_comments` WHERE `comment_approved` = "spam" ORDER BY `comment_author_IP` DESC

I then add those on to my firewall rules to block those IPs completely. Of course there can be proxies of large networks on the list, I know, which may in turn prevent legitimate users from accessing this blog, but lets see if my spam goes down.

Another way people may find useful is to ban them only on their blog using a plugin. One that works pretty well for this purpose is WP Ban

0

As my build scripts keep getting more complicated, I am now in need of a configuration file for each. Furthermore, I have several machines and I need to sometimes change paths around. In other words, I need a local configuration file for each script and for each host I build on.

I will use myScript.bat as the main executable batch, which contains:

@echo off
SETLOCAL EnableExtensions EnableDelayedExpansion
rem ####################################################################################
rem ## Default Configuration
rem ####################################################################################

SET EXTERNAL_VARIABLE_A=This is the default variable A
SET EXTERNAL_VARIABLE_B=This is the default variable B

rem ####################################################################################
rem ## PLEASE DO NOT EDIT BELOW THIS LINE
rem ####################################################################################

rem We load the config file first
call :loadconfig "%~dpn0"

rem we then carry on execution
call :execScript

@exit /B 0

rem ####################################################################################
rem ## Pseudo-function to load config
rem ####################################################################################
:loadconfig
rem set the variable HOSTNAME by executing the command (that's the computer's name)
FOR /F "delims=" %%a IN ('hostname') DO @set HOSTNAME=%%a

rem strip double quotes
set scriptFile=%1
set scriptFile=%scriptFile:"=%

rem We use two files: myScript.conf and myScript.
rem myScript. overrides myScript.conf
rem %~dpn0 is the full file minus the extension.
FOR %%c IN (
	"!scriptFile!.conf"
	"!scriptFile!.!HOSTNAME!"
) DO (
	IF EXIST "%%c" (
		echo Loading local configuration from: %%c
		FOR /F "usebackq delims=" %%v IN (%%c) DO (set %%v)
	)
)

GOTO :eof

rem ####################################################################################

rem Use this pseudo-function to write the code of your main script
:execScript

echo !EXTERNAL_VARIABLE_A!
echo !EXTERNAL_VARIABLE_B!

ENDLOCAL

Then for the configuration file, I will use on my host baux, I will create a file called myScript.baux, which will contain the variables I want to configure externally. Note there is no SET command infront of the variables in the configuration file! The file may look like this:

EXTERNAL_VARIABLE_A=Mary had a little lamb
EXTERNAL_VARIABLE_B=Johny had a little pump

Acknowledgements

Joey, over at StackOverflow, provided the central idea to solving this.

0

Getting CodeIgniter URLs properly rewritten is a bit tricky when using FastCGI, including the mod_fastcgi_handler. Typically, we want to remove the index.php from all urls. To do this, create an .htaccess file in the same directory with index.php and paste into it:

Options -Indexes +FollowSymLinks

RewriteEngine On
RewriteBase /

# exclude any paths that are not codeigniter-app related
RewriteCond %{REQUEST_URI} !^/server-status
RewriteCond %{REQUEST_URI} !^/server-info
RewriteCond %{REQUEST_URI} !^/docs

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

<IfModule mod_php5.c> 
    RewriteRule ^(.*)$ index.php/$1 [L]    
</IfModule>    

# the following is for rewritting under FastCGI
<IfModule !mod_php5.c>    
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

Acknowledgements

Full credit for the right mod_rewrite rule goes to Phil Sturgeon who has posted it here.

1+

Currently, there isn’t a straight forward way to stylize the output of the Apache-generated server status. The server’s status is generated by the mod_status module. I assume that this module is already loaded and its properly configured on your setup. The default location on most installations is /server-status on your web server. You should see a rather minimalistic web page with statistics about the resources consumed by the server when you visit it.

If you would like to add your own touch to the Apache-generated server status output then one way to do it would be to manipulate the generated output to inject some CSS code. The simplest approach to do this is to use another Apache module mod_substitute. This module is specifically designed for both simple and advanced substitution of generated html by the server before that is sent to the client.

First, make sure that mod_substitute is loaded by your server:

    apache2 -M | grep substitute
or
    httpd -M | grep substitute

If you see a line with substitute_module, then you’re good to go. If not see the documentation of your OS vendor on how to install it. Next configure your web server to do the substitution:

<Location /server-status>

   SetHandler server-status 

   # Add a line on the html head to include a CSS file, 
   # instead of writing your CSS code as a substitution string
   AddOutputFilterByType SUBSTITUTE text/html 
   Substitute 's|</head>|<style type="text/css">@import "/status.css"</style></head>|'

</Location>

Remember to reload or restart your server after you make the relevant configuration changes, or you won’t see anything happening.

You can now go to your server’s DocumentRoot and add a file named status.css in which you may write whatever CSS code you want to style your server status with. To see the relevant tags used in the original output of the handler inspect the generated html and work in the CSS file only. Feel free to use my status.css file to get started.

Of course you can do more specific substitutions to add classes to various tags and use them to do more advanced styling.

The result of applying the custom CSS to Apache's default server-status

The result of applying the custom CSS to Apache’s default server-status

1+
UPDATE [05 May 2014]: therealone, a user over at WDC Forums has posted a registry fix that Fresco Logic sent him. I have mirrored it here, in case the original file disappears. I have installed it along with the latest Fresco Logic USB3 drivers v3.5.106.0, which seems to work quite well. Note that my drive still disconnected a couple of times, however only when the computer it was attached to was left for hours unattended and certainly not while in use.

I must also note that I have emailed Fresco Logic support twice at the beginning of 2014, asking them for information, a fix or comment, but they have not replied, or chose to ignore my email. Therefore I find their poor support disproportional to the problems their bugs have caused to unsuspecting users. Make what you want of it.

Registry fix for Windows – Quick Steps:

(a) Upgrade the firmware of your WD Passport via the Firmware Updater.

(b) Download and install the latest FL USB3 drivers. I obtained mine from the FL support web page.

(c) Download, decompress the Fresco Logic registry fix. Insert the fix into your registry, by double clicking it on windows. This registry fix only inserts a key used by the FL driver to disable the U1/U2 power states I think, but you are using this at your own risk.

(d) Please take a moment and thank therealone for obtaining and posting this fix!!

Attention: If the registry fix does not fix it for you, read and follow the rollback instructions to an older driver.

UPDATE [26 Aug 2013]: WD is providing firmware updates for various drives exhibiting the connect/disconnect problem (thanks Boostland for pointing this out). Firmware updates for My Passport drives can be found under the WD Support pages, for Windows and Mac, respectively. Read the release notes and perform the relevant update. Please, leave a comment if the firmware works for you with some information of your configuration, a lot of people come here in search for a solution! What is the USB 3.0 controller drivers you are using? Did you downgrade to those I suggest in my post here?

I recently bought a WD My Passport 1TB USB 3.0 Portable hard drive, which had an awesome price tag attached for the space it provides. However, within minutes of use under Windows 7 (64-bit), the drive started to disconnect and reconnect randomly making it almost impossible to use. For the record I have an AsRock G41MH/USB3 motherboard that has a Fresco Logic FL1000 USB 3.0 controller, which provides a single USB 3.0 port. The drive worked just fine on a USB 2.0 port, albeit at the expense of speed of course.

Round 1. Contact Western Digital Support

My first reaction was to contact WD. I thought that if there is a problem with the drive, they most likely know it already. They suggested to install WD SmartWare and manage the sleeping cycles. Unfortunately, installing WD SmartWare didn’t do the trick. I am actually uncertain why one has to install a backup utility to regulate sleeping cycles. I left SmartWare on my system for now. Support also suggested that I disable any Legacy USB 3.0 support in my BIOS, which I did. No improvement, my passport is disconnecting continuously. I see various posts on the WDC community forums (1) suggesting that there is a problem with power and potentially the cable shipped with the drive. It even appears that WD sends out a power cable to users affected.

Round 2. Try it on another computer

I didn’t have a second cable and although my power supply is a Corsair HX850 I thought I should try it on another computer before going any further. I took the drive at work, where my workstation has an Asus P6X58D Premium, with a NEC USB 3.0 controller. The drive works flawlessly! That rules out a problem with the drive or the cable and points the finger at my machine at home.

Round 3. Contact AsRock Support

Back home, my power supply is 850W which should provide enough power, so I thought my motherboard may be faulty or it needs a BIOS update, or something similar. If it’s my motherboard, then AsRock support must know something about it, right? I contact them and they suggest to me to check the jumpers on my motherboard and set the voltage of the USB port to +5V. I switched all jumpers to +5V, but the drive still disconnects.

Round 4. Software tweaking hell

I read on the web that there are software tweaks about this, particularly power options under Windows 7. I disable USB sleeping on Windows ( Control Panel > Power Options > Balanced > Change plan settings > Change advanced power setting > USB setting > USB selective suspend setting > Disabled ), but this does not fix my problem either, as user Ayssl3 claims.

Round 5. Contact AsRock Support (again)

I respond to AsRock support and they tell me to search and update to the latest Fresco FL1000 USB3.0 driver on Windows. I do that. I apparently managed to find v3.5.93.0 of the driver at http://www.station-drivers.com/page/fresco_logic.htm which was the latest and very new (dated 2/11/2012). So I install the driver, but the problem isn’t going away!!

Round 6. Looking for a solution

I go back to searching the web and I stumble upon a great post by kyroguy at the WDC forums. This is it. I most likely have to downgrade my Fresco Logic drivers!

Round 7. Driver Trial Galore

I started trying out various Fresco Logic drivers I could get my hands on. I have tried, without success, versions: 3.5.93.0, 3.5.88.0, 3.5.73.0, 3.5.46.0, 3.5.30.0, 3.5.24, 3.5.2.0. Version 3.5.24 seemed to be working, but when I pushed the drive by transferring lots of data simultaneously, the device disconnected.

I must note that I have tried unsuccessfully to locate driver 3.5.20.0 that kyroguy reported as working.

Round 8. Solved!

I have contacted AsRock Support (yet again) and these guys have been great in sending me driver v3.0.100.58 which actually works!! To save the day for anyone with the same problem I have made a backup of this working driver!

I shall note here for the record that another user Mikael P. posts here that he has also had success with the v3.0.100.58.

1+