IE11 and expression evaluation regarding Boolean

It seems that a lot of stuff changes with IE11. Some legacy code stopped working out the blue.
After some debugging it seems that some expressions that have been evaluating to true, now are being evaluated to false.


if(document.ActiveXObject) //document.ActiveXObject is a valid function in IE 11
    alert("YES!!!");  //this never gets called in IE 11

Boolean(document.ActiveXObject) gets evaluated to true in IE 10 but in IE 11 is evaluated to false, while it is still a valid function.

Whatever, just thought this might help someone.


Google Analytics for WordPress – multisite not sufficient permissions solution

It is one of those times that you relive all that has passed.

I came across my own solution i had shared with the community back then, more than 2 years ago.

Time flies and time mosquitoes.

The solution is you need to edit the file wp-content/plugins/google-analytics-for-wordpress/admin/yst_plugin_tools.php at line 16

and replace the line

var $accesslvl = 'edit_users';


var $accesslvl = 'activate_plugins';


jQuery UI selectable, how to programmatically select option

If you need to programmatically select an option, using events, so that your callbacks are called then you can do the following:
Suppose we have a ul element with id mySelectUlID, and i want to add an extra element to the end of it and also select it.

This is done like this:

    $('#mySelectUlID').append('<li class="ui-widget-content ui-selectee ui-selecting">another</li>');



The code is valid for the latest jQuery 1.10 and is self explaining i believe.


Jquery Tools library problem with modal overlay not appearing … a solution

So i was using the library of jquery tools recently and wanted to use the modal box with the nice overlay in the background.

I did all that was suggested yet the overlay didn’t appear. The solution was simple. I had downloaded a custom version of the jquery tools library and in an effort to save some bytes didn’t include a crucial part of the library named Expose.

The overlay is based on the ‘Expose’ part of the library. If you take a carefull look a the modal box documentation it is mentioned: ‘This feature can be achieved with the Expose tool which is tightly integrated with this overlay tool.

If you want a custom version of jquery tools, don’t forget to click on Expose.

That’s all for now.


Problem with Varnish(2.1). Drupal’s pages aren’t cached by varnish.

I had a problem with varnish, trying to boost a drupal site by caching it. I noticed that while js, css and image files were getting cached, no other page could be cached by varnish and on each request the apache was asked to fetch the page.

That was not acceptable since the site isn’t updated really often. I found out that the reason why varnish didn’t cache is drupal’s (v7) file:
/var/www/drupal/includes/ , line 1283

  'Expires' => 'Sun, 19 Nov 1978 05:00:00 GMT',

I didn’t want to just comment it out in the file, since a lot more problems could be faced regarding drupal and varnish and caching and updating drupal core later on etc.

A solution was to add the following lines in the varnish config file vcl_fetch :

if(beresp.http.Content-Type ~ "text/html") {
        set beresp.ttl = 1d;

So now all pages are cached for 1 day and then the cache gets updated again when someone requests a page.


PS 1: I followed the instructions at and the documentation of varnish.
PS 2: A nice command to check if any page is requested from apache and is not in varnish cache is this:

varnishtop -b -i txurl

IE9 DOMParser is missing method selectSingleNode, selectNodes (and possibly others too …), a solution … (XMLSerializer missing methods also)

When you have browsers which have the DOMParser (like chrome, firefox etc.)
you can do the following in javascript:

var dom = (new DOMParser).parseFromString(str, "text/xml");

In IE9 although DOMParser is available it seems that it lacks some methods, so you get errors like:
Object doesn’t support property or method ‘selectSingleNode’

The solution you can use in javascript level is something like that:

var dom = new ActiveXObject("Microsoft.XMLDOM");

To all of you who are using sarissa.js and you face the same problems then you need a little code tweaking for it to work. I will share what i did and worked for me. I don’t know if some other parts of the library require also fixing…

in sarissa.js at line 474 (file version replace the line:



if(!window.DOMParser || navigator.userAgent.indexOf("MSIE 9")>-1){

PS. In addition the case with XMLSerializer is the same like DOMParser. So in sarissa.js change the line 596 from:

if(!window.XMLSerializer && Sarissa.getDomDocument && Sarissa.getDomDocument("","foo", null).xml){


if((!window.XMLSerializer && Sarissa.getDomDocument && Sarissa.getDomDocument("","foo", null).xml) || navigator.userAgent.indexOf("MSIE 9")>-1){

That’s all for now.

curl : How to set PHPSESSID in the request headers of a call, how to solve waiting and getting no response

I have been trying to use curl in PHP to post some data in some page of mine that requires login and thus a session to be present.
So i had to send the session along with the curl request. The problem was that the script seemed to be waiting for a response.

What happened actually was that my target script was waiting for the session to become available.
As is stated in session_write_close():

“session data is locked to prevent concurrent writes only one script may operate on a session at any time”

So my target script was waiting for the session to become writable while the current script (that made the post ) couldn’t complete because it was waiting the response of the target (cruel things the deadlocks). The solution is to call session_write_close() and free the session before you make the call curl_exec()

That’s it. Take a look at the following code. Take care.



    $ch = curl_init();
        die('Failed to init curl ...');

    curl_setopt($ch, CURLOPT_URL,            "" );
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
    curl_setopt($ch, CURLOPT_POST,           1 );
    curl_setopt($ch, CURLOPT_POSTFIELDS,     $raw_data );
    curl_setopt($ch, CURLOPT_HTTPHEADER,     array('Content-Type: text/xml')); //remove this line if you want submit text/html
    $strCookie = 'PHPSESSID=' . session_id() . '; path=/';
    curl_setopt( $ch, CURLOPT_COOKIE, $strCookie ); //We set our session in the headers of the request!

    session_write_close(); //kmak - this is what makes the session transmission possible ... otherwise we will wait and wait ...
    $result=curl_exec ($ch);
        die("Failed in curl_exec with error:".curl_error($ch));