Centos IPTables Error – Setting chains to policy ACCEPT: security raw nat mangle filter [FAILED]

Getting a definitive fix for this problem proved elusive. A patch provided at http://epoxie.net/14857.txt, did not work for me but by manually applying the patch it resolved the issue

Below is the patch script


--- 5350.orig.sh 2011-05-27 19:58:32.000000000 +0100
+++ 5350.sh 2011-05-27 19:57:32.000000000 +0100
@@ -120,6 +120,12 @@
for i in $tables; do
echo -n "$i "
case "$i" in
+ security)
+ $IPTABLES -t security -P INPUT $policy \
+ && $IPTABLES -t security -P OUTPUT $policy \
+ && $IPTABLES -t security -P FORWARD $policy \
+ || let ret+=1
+ ;;
raw)
$IPTABLES -t raw -P PREROUTING $policy \
&& $IPTABLES -t raw -P OUTPUT $policy \

The patch should be applied to iptables init script in /etc/init.d.

Drupal 7 DB Getting A Single Value From The Database

Here is how to get a single value out of the database using drupal 7. In the example below the select uses a single count column but you can use any query that is sure to return a single result. Use fetchField() to return it.


$value = db_query("select count(*) from node where type='mynode' and created > :time",array(':time' => strtotime($time)))->fetchField();  

Varnishhist – What Does it Tell Us

Varnishhist is a really cool console utility app that comes with Varnish Cache. It is a utility that reads varnishd shared memory logs and presents a continuously updated histogram showing the distribution of the last N requests by their processing. The value of N and the vertical scale are displayed in the top left corner. The horizontal scale is logarithmic. Hits are marked with a pipe character (“|”), and misses are marked with a hash character (“#”). Varnishhist was developed by Poul-Henning Kamp in cooperation with Verdens Gang AS and Linpro AS. Continue reading

JSON Encode Problems with TinyMCE

TinyMCE is a brilliant javascript WYSIWYG editor that I commonly use on forms. JSON ( Javascript Object Notation ) is a way of encoding objects as strings and is commonly used for storing and transmitting objects and other complex data types.

JSON requires a UTF8 encoding for strings. JSON was unable to encode the output from TinyMCE and this turned out to be a problem with the way tinyMCE handled its output.

The fix was to initialise tinyMCE with the property entity_encoding : “raw”, this prevented tinyMCE messing with the natural UTF8 output. JSON was then able to encode the output correctly!

$(document).ready(function () {

           tinyMCE.init({
                mode : "textareas" ,
                theme : "simple",
                entity_encoding : "raw",
                editor_selector : "mcesimple",
            });

}

This can also be a problem when encoding JSON in php. It is important to ensure any strings or HTML are encoded to UTF8 before trying to JSON.stingify. Use utf8_encode( $str );

HTML5 Local Storage And JSON

Most Browsers now support HTML5 and all the major ones support local storage. Local Storage is the HTML5 way of storing your web app data locally instead of cookies or on the server.

JSON or Javascript Object Notation, is a way of encoding javascript objects and Arrays as a string. This is a very convenient method of storing complex data or for passing data AJAX requests between server and the client.

Currently most implementatins of local storage use key/value pairs and do not directly support complex data, however by ‘stringifying’ (JSON encode) objects into a string it is possible to overcome this shortcoming.
Continue reading

Posting Free Ads Successes & Failures

I have recently tried selling some of my things that I no longer needed on a few of the free ads sites but was surprised to find that most were not actually free! They always caught you or your potential customers one way or another.

One site I tried and was happy with was inyourareanow.co.uk . This UK based site did offer free ads that were really free. I got a great response to my ads and am very happy with the service! They also offer a “Free Ads Getting Started” guide.

Giving My WordPress Site Some Love

I have been trying to make a decision on whether to go for Drupal 7 or WordPress for this blog. Finally have come down on the side of WordPress.

Reason is simply that as a blogging tool – its much quicker to come up with a site that works and looks good pretty much “out of the box’. Drupal may be more powerful, but it requires a substantial learning curve and dispite the improvements in themes – the Drupal themes are simply not as good as the wordpress ones!

So expect changes!

Securing a ProFTPD server

If you are looking for ways to lock-down your ProFTPD server without using iptables this may help. I recently had to find a way of securing a VPS without iptables. The ftp server only needed to be accessed by a few known users so I ended up with two reasonable possibilities.

  • Switch ftp on and off manually as and when it was needed (most secure)
  • Configure ProFTPd to only allow connections from specific IP’s

Continue reading