Short Tag – Web Development Blog

Entries for March, 2012

Make cPanel Api2 Requests with Jquery and Javascript

First, include jQuery in your page:

<script src=""></script>

Here is the API 2 of cPanel:
Find the modules and function names you need, and use them when calling the function below.
Copy the following function to your webpage:

function cpanel_call(module, fct, domain, user, password, secure, port, json, callback, return_as, async)
var protocol = secure ? "https" : "http";
var data_type = json [...]

Xul and XPCOM: Delete files

Here is a little handy function for removing files with Javascript on Mozzila platform:

function delete_file_by_path(path)
var file = Components.classes[';1']
if (file.exists())

Create a new instance of nsILocalFile, and the use the initWithPath function to initialize the file, and the delete the file is exists.

Php .Htaccess Set default timezone

When getting an error like this:
© Warning: date(): It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled [...]

Loop through a Combobox, Listbox in XUL/XPCOM

So, we have a XUL component, that looks like this:

<listbox id="listboxId">
<listitem label="1" />
<listitem label="2" />
<listitem label="3" />

We can loop through the elements of this componenet using XPCOM:

var lbox = document.getElementById(‘listboxId’);

for (var i =0; i<lbox.children.length; i++)
var child = lbox.children[i];
//do someting with child, like