Maze Blog
Server Maintenance
May 18th, 2010Dear Customers,
On May 22 2010 (0800-1100 GMT) Maze Solutions will be doing a routine maintenance on its servers.
This might affect your website(s) and/or emails.
The affected server is:
- audi.mazesolutions.me [204.42.155.13]
Sorry for any inconvenience this may cause you,
Maze Solutions,
support@mazesolutions.me
Let Me Start By Saying Thank You to You
February 2nd, 2010Maze Solutions website `yes this one
` recently won the second prize in Lebanon Web Award’s yearly competition (web design and development category).
We know you have many choices when choosing a web development company, and appreciate your business.
We THANK YOU, and promise that we’ll do our best so you can feel confident that you made the right choice.
It was a pleasure to provide you with the high-quality website you needed and we look forward to serving you again soon.
Sincerely,
Maze Solutions team

Full list of winners here
Happy holidays from Maze Solutions
December 23rd, 2009This is our wish for you: peace of mind, prosperity through the year, happiness that multiplies, health for you and yours, fun around every corner, energy to chase your dreams and joy to fill your holidays.
Happy Holidays from all of Maze Solutions team.

Nice hint and tips for using wget
February 20th, 2009I think most of us have used the wget command once or twice.
What i will do now is explain a few tips and tricks on using this useful command.
1. Download many files at the same time
2. Download and resume
3. Limit your download to a specific speed
4. Split your download for faster results
5. Log your download
6. Download in the background and keep using the terminal
Common use of wget:
1. Download many files at the same time
There is more then one way to do this, my favourite one is to create a .txt file using the vi command and write in it the URLs of the files you want to download
write in it
http://example.com/bleh.tar
http://example.com/tfeh.tar
http://example.com/blah.tar
http://example.com/stuff.tar
Then run wget using the -i argument
2. Download and resume
You can force wget to resume any broken download like this
3. Limit your download to a specific speed
You can use this when downloading a big file and you don’t want the connection to choke
4. Split your download for faster results
Just like free download manager or download accelerator on windows ![]()
To do this we will have to use awget instead of wget
Note that i could not find aget in the repos. However you can download a .deb package from http://www.enderunix.org/aget/
5. Log your download
Log all your downloads into a file
6. Download in the background and keep using the terminal
Note that doing the above will automatically create a log file for the download process
To specify your own log file location do the following
Hope this helps ![]()
// Jo
Javascript images pre-loader
January 19th, 2009Here you are, doing a photo gallery and in that photo gallery you have many thumbnails that on click will display the larger picture.
If you are using the simple “document.getElementById(‘someid’).innerHTML=’‘” or many other javascript method to load your images then you have a problem.
When the user click he will have to wait for the image to load and sometimes will see parts of the images opening bit by bit.
This javascript preloader will load all your desired images in the background and so when you call them they are ready to be displayed ![]()
This will come handy also a lot when doing a javascript slide show… but this will be my next post here ![]()
Demo: http://joeabiraad.com/demos/preloader/
Files: http://joeabiraad.com/demos/preloader/preloader.rar
Hope it helps
//Jo
How to do a fixed footer using only CSS
January 19th, 2009The last CSS tutorial i wrote was about making a two level menu using CSS/JS, well this one is about fixed footers…

You know how it is ! you just wanna keep this footer still while navigating through the page.
Peace of cake ![]()
The main thing is to fix that position to bottom: 0px and the rest will follow !
min-width:770px;
width: 100%;
position: fixed;
z-index: 5;
bottom: 0px;
}
Check the demo http://mazesolutions.me/demos/footer/
Download the files http://mazesolutions.me/demos/footer/footer.rar
To get the full working menu http://mazesolutions.me/website-production/how-to-do-a-menu-with-sub-items-using-css/130
Hope i helped in a way ![]()
// Jo
How to make a Sudoku (Only javascript used)
January 9th, 200910 days ago, a good friend of mine asked me to write a sudoku online game for him.
He is always bored at work and wanted to lose some time, so… here it is ![]()
PLAY
Rules of sudoku
- Each row should contains all numbers from 1 to 9 (no repetition)
- Each column should contains all numbers from 1 to 9 (no repetition)
- Each 3×3 table should contains all numbers from 1 to 9 (no repetition)
Logic used
- Start by generating each number in a cell at a time by choosing randomly from 1 to 9
- If the number is ok and do not conflict with the other cells —> Continue to next one
- Else —> go back one cell and choose another number
New server, new header
December 21st, 2008Well welcome to the new header styled, hosted joeabiraad.com ![]()
After my pagerank droped to 2 and discovering that my website is hosted with like a trillion other websites on the same server containing adult materials… I moved my blog to another server, its more expensive of course but i already like it more ![]()
Here is a list of the website that were being hosted with joeabiraad.com
http://www.reverseip.us/index.do?url=74.54.18.242
Thats more then 468 websites…… thats insane !
Changing the welcome message in SSH
December 18th, 2008If your a linux user or maybe a simple linux server administrator with some servers at hand, the chances are that you use SSH to login there and manage them.
When a user logs in to SSH usually he sees a welcome message.
If you have an ubuntu machine like me then you will see the following message
The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
To access official Ubuntu documentation, please visit:
http://help.ubuntu.com/
In order to change this message just type in the terminal

Update:
Note: On restart your changes to /etc/motd will be reverted, the reason is that /etc/motd is a symbolic link to /var/run/motd which is rebuilt by /etc/init.d/bootmisc.sh from a template, /etc/motd.tail, at each reboot. (thank you Adam Trickett).
lrwxrwxrwx 1 root root 13 2008-11-27 14:18 motd -> /var/run/motd
jo@jo-desktop:/etc$
This means that to make your changes permanent you can either:
1. change
then reboot
2. point the /etc/motd symlink to a different file such as /etc/motd.static and make your changes there. (Also thank you Adam Trickett).
Joe
Preventing hotlinking to your website using .htaccess
November 25th, 2008What is hotlinking?
Also known as “bandwidth stealing” by the angry site owner, it refers to linking directly to non-html objects not on one own’s server, such as images, .js files etc. The victim’s server in this case is robbed of bandwidth (and in turn money) as the violator enjoys showing content without having to pay for its deliverance. The most common practice of hot linking pertains to another site’s images.
So how to prevent someone from hotlinking to your website?
How to give them maybe a “nasty” surprise when their hotlinks become so pervasive as to have a significant effect on your bandwidth usage ?
An easy solution is to write this piece of code into your .htaccess file.
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ http://www.mydomain.com/somelink.ext [R,L]
Of course dont forget to replace
1. “mydomain.com” by your domain name
2. gif|jpg by your desired of file extension you wish to block from referrers (ex: gif|jpg|css|js)
3. http://www.mydomain.com/somelink.ext by the page you wish to redirect to when someone is trying to access (2)
Hope it helps
// Jo
How to do a menu with sub items using CSS
November 1st, 2008Every website needs a menu, in this tutorial i am gonna show you how to do a menu with sub items using only CSS and javascript.
First lets take a look at the final result:

The CSS
margin:0;
padding:0;
border:0;
}
.nav{
background: url(../images/nav-bar.gif) no-repeat 0 18px;
width: 934px;
height: 30px;
margin: 0 auto;
list-style: none;
font-size: 14px;
padding-left: 5px;
line-height: 15px;
margin-bottom: -8px;
position: relative;
padding-top: 18px;
}
.nav li{
display: inline;
line-height: 30px;
height: 30px;
float: left;
padding-bottom: 5px;
margin-bottom: -5px;
}
.nav li a{
color: #fff;
float: left;
height: 30px;
padding: 0 19px;
text-decoration:none;
}
.nav li a:hover,
.nav li:hover a,
.nav li.hover a{
background: url(../images/hover.gif) repeat-x;
text-decoration: none;
}
.nav li ul{
background: url(../images/1×1.gif);
display: none;
}
.nav li:hover,
.nav li.hover{position: relative;}
.nav li:hover ul,
.nav li.hover ul{display: block;}
.nav li ul{
width: 125px;
position: absolute;
top: 31px;
left: 0px;
}
.nav li li{
background: #5a8a47;
display: block;
float: none;
height: auto;
font-size: 12px;
line-height: 14px;
padding: 4px 0 3px 18px;
margin-bottom: 1px;
}
.nav li li a{
float: none;
padding: 0;
}
.nav li:hover li a,
.nav li.hover li a{background: none;}
.nav li li a:hover{
background: none;
text-decoration: underline;
}
Defining “html,body,ul,li” to avoid any not desired margin, padding and border.
Class “nav” is for the whole “ul”, of course you can change the width (so background pic) to suit your needs.
You can easily figure out your way in the rest
The Javascript
var nav = document.getElementById(“nav”);
if(nav){
var nodes = nav.getElementsByTagName(“li”)
for (var i=0; i
this.className+=" hover";
}
nodes[i].onmouseout=function() {
this.className=this.className.replace(new RegExp(" hover\\b"), "");
}
}
}
}
if (window.attachEvent) window.attachEvent("onload", hover);
The javascript here is responsible for the rollover menus, all it does really is add the “hover” class to an “li” element on mouseover and replace it with “” on mouseout.
Hope this is useful, you can download the files from http://mazesolutions.me/demos/hmenu/hmenu.tar
Demo: 
// Jo
Style any website using 'Stylish'
August 3rd, 2008We all know how styles are important to any website and we all spend some time styling our websites, but can you style other websites ?
For example: You often visit cnn.com, you read the content… but dont like the design ? well you can change it using firefox and stylish.
I have done this for gmail and the result is incredible ![]()



You can get stylish from here
You can also get already done styles from here
A good style that i found there is:
Gray YouTube ( http://userstyles.org/styles/1078 )

Enjoy ![]()
// Jo
Problems with sound and video on ubuntu ?
May 31st, 2008Howdy,
I am writing this post because so many people are asking me about it.
I will not invent anything new here, i will just make a general tutorial that will fix 80% of your audio/video problems.
Please understand that i do not guarantee 100% success result, because it all depends on the hardware you have.
Before digging in complicated stuff, lets first try to install the Medibuntu packages.
Some of these packages include the libdvdcss package from VideoLAN and the external binary codecs package (commonly known as w32codecs) used by MPlayer and xine.
Step 1:
Add Medibuntu to your system’s list of APT repositories.
For ubuntu 7.10
For ubuntu 8.04
Now add the GPG Key:
Step 2:
Install the libdvdcss2 package.
This package is used to play encrypted DVDs, more information about it here
Step 3:
Installing Non-Native Media Formats.
These media formats includes but are not limited to: wmv, mp3, .mov, .rm etc…
For i386 (use this if you are not sure)
For amd64
For ppc
This is it, restart your PC now and try to play some music. If you still cannot hear the beat continue reading this post.
mmm… I see you are still having problems ? Lets try to do more complicated stuff.
What we will do now is recompile the alsa drivers
When you compile stuff from source apt don’t know about them, so it wont keep track of it.
Step 1:
Lets download them first.
We need to get: alsa-driver, alsa-lib and alsa-utils.
You can download the latest releases from here:
- alsa-driver: ftp://ftp.alsa-project.org/pub/driver/
- alsa-lib: ftp://ftp.alsa-project.org/pub/lib/
- alsa-utils: ftp://ftp.alsa-project.org/pub/utils/
Step 2:
Untar these packages.
You can untar them using GNOME or by typing this line of code in terminal
Note: dont forget to replace xxx by your version number.
Step 3:
To configure/install alsa utilities we need the following package.
Step 4:
Installing alsa
In the alsa drivers folder type:
In the alsa Lib folder type:
In the alsa utilites folder type:
Restart your PC and cross your fingers
Hope I helped you in a way.
// Jo
Control Your Firefox RAM Usage
January 16th, 2008Mozilla Firefox is a web browser project descended from the Mozilla application suite, managed by the Mozilla Corporation. Firefox had 16.80% of the recorded market share in Web browsers as of December 2007, making it the second-most-popular browser in current use worldwide.
Background
On Windows operating systems, when a program is minimized and left for a period of time, Windows will swap memory the program is using from RAM onto the hard disk in anticipation that other programs might need RAM. Because of the way Mozilla applications are stored in memory, Windows is much more aggressive in swapping out the memory they use, which can cause a delay when the program is restored.
The “Config.trim_on_minimize” preference determines whether to allow Windows to swap out memory from a minimized Mozilla application.
Possible values and their effects:
true — Allow Windows to swap out memory when the program is minimized.
false — Prevent Windows from swapping out memory when the program is minimized. (Default)
This preference does not exist by default, in order to change it’s default value:
- Open Firefox and go to the Address Bar. Type in about:config and then press Enter.
- Right Click in the page and select New -> Boolean.
- In the dialog box that pops up, enter config.trim_on_minimize and hit Enter.
- Now set value to True.
- Restart Firefox.
Setting this preference to true has it’s advantages
If you’re experiencing problems with the application consuming too much RAM (Mem Usage in the Windows Task Manager), you can try setting this preference to true.
and disadvantages
Now, Firefox would use very less memory, which is very evident from the Task Manager too, however, when you restore Firefox again, it takes more time as everything needs to be brought back .
So, it’s better not to enable trim_on_minimize if you have a decent enough system.
Manage your workplace stress !
December 16th, 2007

Stress is the “wear and tear” our bodies experience as we adjust to our continually changing environment; it has physical and emotional effects on us and can create positive or negative feelings.
Most of us experience stress at work, maybe while giving a presentation, racing to meet a deadline. Remember how your heart was pounding and you were breathing harder?
I am not a doctor or anything but this is what i do when i am stressed: Most of the time I take 15 to 20 minutes to sit quietly and maybe play an online game.
Instant Chess has been a perfect solution for me.
It will take you 10 secs to start a game, usually one round of chess could take 15 mins with a possibility of limiting the time frame. In those 15 mins you will think in a fast way, unload your stress and recharge your energy (at least it worked with me).
Anyway, enough with the words… why don’t you give it a shot ? www.instantchess.com and tell me if it worked.
By the way i wrote this article in order to get a free subscription… Yep !! Thats even possible
Wish me luck hehe
// Jo
Google Pagerank using Ajax
November 13th, 2007Lately I’ve been searching for a good Google Pagerank function.
Couldn’t find any… So i decided to make my own.
Here is an Ajax Google Pagerank I have done today
Download files: click here
Brief description:
- _ajax.new.js: is the main ajax class. I have already explained this class here
- pagerank.php: functions to calculate the hash
- ouf.php: php call to the function
- index.html: simple input form
- style.css: simple stylesheet
If you like it digg it here
Please provide me with any comments to improve it.
//Jo
Installing LAMP on Ubuntu 7.10/8.04/8.10 (Linux,Apache,MySQL,PHP)
November 5th, 2007Lately I’ve been using ubuntu 7.10 for all my projects/daily work.
As a web developer i should have LAMP on my machine and now i would guide you through installing it on yours.
This guide is divided into 3 steps: installing/tesing Apache, PHP and finally MySQL.
Lets start with Apache:
1. Open the terminal (we will be using it through most of my guide) from Applications > Accessories > Terminal
2. Install apache2 using apt-get by typing the following
Note that you should know the root password.
Now everything should be downloaded and installed automatically.
To start/stop apache2 write:
Your www folder should be in: /var/www/
If everything is OK you should see an ordinary HTML page when you type: http://localhost in your firefox browser
Finished with Apache ? lets conquer PHP:
1. Also in terminal write:
or any php version you like
2. restart apache
This is it for PHP ![]()
Wanna test it ? Just create an ordinary PHP page in /var/www/ and run it.
Example:
and write in it: < ?php echo “Hello World”; ?>
Now run it by typing http://localhost/test.php in firefox… You should see your ” Hello World ”
66 % is over, lets continue to installing MySQL:
1. Again and again in terminal execute:
2. (optional) If you are running a server you should probably bind your address by editing bind-address in /etc/mysql/my.cnf and replacing its value (127.0.0.1) by your IP address
3. set your root password (although mysql should ask you about that when installing)
4. Try running it
where xxx is your password.
Note: You can install PHPMyAdmin for a graphical user interface of MySQL by executing
5. restart apache for the last time
Congratulions your LAMP system is installed and running ![]()
Happy Coding
//Jo
UPDATE:
Due to the large number of people emailing about installing/running phpmyadmin.
Do the following:
The phpmyadmin configuration file will be installed in: /etc/phpmyadmin
Now you will have to edit the apache config file by typing
and include the following line:
Restart Apache
Another issue was making mysql run with php5
First install these packages:
then edit php.ini and add to it this line : ” extensions=mysql.so” if it isnt already there
Restart Apache
Hope this helps
Convert anything to anything !!
October 22nd, 2007Feeling the urge to convert ? ?
Check that:
http://www.zamzar.com/
You can convert any type of document to any type you want and no need to install any software.
NB: good connection required for large files.
Enjoy it
Italian translator needed :P
September 26th, 2007This morning i was checking the stats on my blog and i noticed a new referral in my referrals list.
Anyway it seems that an italian blog has mentioned my Ajax login form (PHP & Javascript) post in an article of his.
The article can be found here.
So the reason i am writing this post is to find what the article talked about and specially the meaning of this sentence
‘ Fresco fresco di pubblicazione anche questo esempio di modulo di login in Ajax e PHP di cui è disponibile per il download il codice completo. ‘ ![]()
Anyone speaks italian ? ![]()
I would really appreciate your answer …
hehehe
//Jo
Ajax login form (PHP & Javascript)
September 22nd, 2007Ok, here’s another AJAX login form example…
In this example I am using 3 javascript files, 2 php files and 1 stylesheet.
click here: http://mazesolutions.me/demos/ajax2 for the demo
click here: http://mazesolutions.me/demos/ajax2/ajax2.rar to download the files
Brief description:
_ajax.new.js: is the main ajax class. I have already explained this class here
_formdata2querystring.js: used for posting the element of a form
_applogin.js: specific ajax class to handle the login form
index.php: simple login form
style.css: simple stylesheet
If you like it digg it here
Next post will be a tutorial on how to make it
Stay tunned …
//Jo
Peace
Compiz fusion with ubuntu gutsy 7.10
September 16th, 2007Wooowww, take a look at this video showing what ubuntu gutsy 7.10 ( isn’t released officially yet ) and compiz fusion has to offer.
EDIT:
I’m sorry for the typing mistake in digg.
Ubuntu gutsy was called 7.10 for a reason (October). Thank you Duncan.
Finally i got to know the author of this video : mike
Chao
//Jo
Validate a username using Javascript and PHP ( AJAX )
August 11th, 2007

Who doesn’t hate these long forms ? You fill each field in them and when you submit, it will return something like :
‘ SORRY BUT YOUR USERNAME IS ALREADY TAKEN ‘.
In this tutorial I m gonna show you how to check if a username is valid without leaving the page using ajax (Asynchronous Javascript And XML).
Before I start, check the final result to see if this what you are looking for.
Demo: click here
Download files: click here
Ready ?
Lets roll
First of all what is AJAX ?
Ajax, or AJAX, is a web development technique used for creating interactive web applications. The intent is to make web pages feel more responsive by exchanging small amounts of data with the server behind the scenes, so that the entire web page does not have to be reloaded each time the user requests a change. This is intended to increase the web page’s interactivity, speed, functionality, and usability.
Like DHTML, LAMP, and SPA, Ajax is not a technology in itself, but a term that refers to the use of a group of technologies.
Now lets see those files
- _ajax.new.js: is the main file. Javascript is the glue that connect the server side language to the HTML page.
- index.html: is the HTML page where the user sends its request and receives the answer
- ajax-test.php: is the php file where we will make all the database operations or simple checkings like string lenght etc…
_ajax.new.js:
We’ll start by creating a basic class, called Ajax, in which we’ll wrap the functionality of the XMLHttpRequest class
Note: I will not analyse the whole class here, i will just explain briefly some key functions.
I will do another tutorial later, on how to make an advanced Ajax class using javascript.
Here are the beginnings of our Ajax’s class constructor function.
This code just defines the properties we’ll need in our Ajax class in order to work with XMLHttpRequest objects.
this.req = null;
this.url = null;
this.status = null;
this.statusText = ”;
this.method = ‘GET’;
this.async = true;
this.dataPayload = null;
this.readyState = null;
this.responseText = null;
this.responseXML = null;
this.handleResp = null;
this.responseFormat = ‘text’, // ‘text’, ‘xml’, ‘object’
this.mimeType = null;
this.headers = [];
}
Now lets add an init method.
Here I am creating an XMLHttpRequest object. As you can see i tried to instantiate the object in a number of different ways, because XMLHttpRequest is implemented differently in Firefox, Safari, and Opera than it is in Internet Explorer.
Internet explorer 6 and earlier use a class called ActiveXObject while Firefox and Safari use class called XMLHttpRequest.
var i = 0;
var reqTry = [
function() {
return new XMLHttpRequest(); },
function() {
return new ActiveXObject('Msxml2.XMLHTTP') },
function() {
return new ActiveXObject('Microsoft.XMLHTTP' )} ];
while (!this.req && (i < reqTry.length)) {
try {
this.req = reqTry[i++]();
}
catch(e) {}
}
return true;
};
SENDING A REQUEST:
Now that we created an XMLHttpRequest, lets write a function that uses it to make a request.
Here are the steps
1- Calls init to create an instance of the XMLHttpRequest class and displays an alert if the call is not successful.
2- Call the open method on this.req this.req.open(this.method,this.url,this.async) to begin setting up the HTTP request.
The open method takes 3 parameters:
a- this.method ( GET or POST )
b- this.url ( the URL of the server side page )
c- this.async ( if this is set to true, then our javascript will continue to execute normally while waiting for a response. If you set it to false then our javascript will stop until the response comes back from the server… This should be set to true as this is the whole point of an AJAX application )
3-Set the headers of the page, depending on the method used
4-Setting up the onreadystatechange event handler.
As the HTTP request is processed by the server, its progress is indicated by these set of integers:
0: uninitialized
1: loading
2: loaded
3: interactive
4: completed
Now we have to wait until the request is completed ( state 4 ) so we can handle the response ( or maybe launch a function )
5-Processing the response.
When the response completes we should check first if the request succeeded. The status property contains the HTTP status code of the completed request.(now this could a 404 page or 500 page… )
But if req.status is bigger then 199 and smaller then 300 then we are ok ![]()
Note: a full list of the HTTP status code can be found here
Talaaaaaaaaa here’s the code
var self = null;
var req = null;
var headArr = [];
if (!this.init()) {
alert(‘Could not create XMLHttpRequest object.’);
return;
}
req = this.req;
req.open(this.method, this.url, this.async);
if (this.method == “POST”) {
this.req.setRequestHeader(
‘Content-Type’, ‘application/x-www-form-urlencoded’);
}
if (this.method == ‘POST’) {
req.setRequestHeader(
‘Content-Type’, ‘application/x-www-form-urlencoded’);
}
self = this; // Fix loss of scope in inner function(s)
req.onreadystatechange = function() {
var resp = null;
self.readyState = req.readyState;
if (req.readyState == 4) {
self.status = req.status;
self.statusText = req.statusText;
self.responseText = req.responseText;
self.responseXML = req.responseXML;
switch(self.responseFormat) {
case ‘text’:
resp = self.responseText;
break;
case ‘xml’:
resp = self.responseXML;
break;
case ‘object’:
resp = req;
break;
}
if (self.status > 199 && self.status < 300) {
if (!self.handleResp) {
alert('No response handler defined ' +
'for this XMLHttpRequest object.');
return;
}
else {
self.handleResp(resp);
}
}
else {
self.handleErr(resp);
}
}
}
req.send(this.dataPayload);
};
Now all what we still need is a URL and a HANDLER function for the response.
This method here will kick off the request.
this.url = url;
this.handleResp = hand;
this.responseFormat = format || ‘text’;
this.doReq();
};
index.html:
First lets call our Ajax class. Here we have 2 functions:
hand(): this function will handle the response received and will write it .
validateUsername(): this function will actually launch the ajax class and call the method doGet.
window.document.getElementById(‘response_span’).innerHTML=str;
}
function validateUsername(user){
var strDomain=”;
window.document.getElementById(‘response_span’).innerHTML=
“Validating username…”;
var ajax = new Ajax();
ajax.doGet(strDomain+’ajax-test.php?action=validateUsername&
username=’+user,hand,’text’);
}
The HTML:
| Choose your username |
size="30" onchange="validateUsername(this.value)"/> |
|---|
ajax-test.php:
All what this page does is check if the username is > then 3 characters and if it is equal to some pre-defined values.
You can easily change the code below to suit your needs and write some SQL statements in it.
case ‘validateUsername’:
$username = trim($HTTP_GET_VARS['username']);
if ( strlen($username) >= 3 ){
if ( $username == “joe” || $username == “rony”
|| $username== “joo” )
print “Username is valid“;
else
print “Username is not valid“;
}
else{
print “Username must be longer then
3 characters“;
}
break;
default:
//silence is golden
endswitch;
I hope i was comprehensible in my first big tutorial.
Just leave some comments and tell me your advices.
//Jo
Signing out
Peace
XML post over HTTPS using PHP
July 14th, 2007Ever try to post XML over HTTPS using php ?
Well it can get almost complicated if you don’t have the right materials.
In this article I will show you how to do it using PHP’s cURL functions.
Requirements:
1- libcurl package ( In PHP 4.2.3, you will need libcurl version 7.9.0 or higher. From PHP 4.3.0, you will need a libcurl version that’s 7.9.8 or higher. PHP 5.0.0 requires a libcurl version 7.10.5 or greater )
Installation
1- Go to http://curl.haxx.se/download.html and download the corresponding libcurl package.
2- For windows users you will have to enable the ‘;extension=php_curl.dll’ in the php.ini file. (libeay32.dll and ssleay32.dll must be present in your PATH.)
For linux/unix users you will have to compile build and then install the package using these 3 steps:
make
make install
Note: You will have to be root in order to do the last step (more info can be found here)
3- Restart apache
Now that your libcurl package is installed you can use the curl library functions.
The function that we will use to POST those nasty XMLs is something like this:
$Url : the url at which i am posting the XML
$strRequest: The XML that i am posting
{
// Initialisation
$ch=curl_init();
// Set parameters
curl_setopt($ch, CURLOPT_URL, $Url);
// Return a variable instead of posting it directly
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// Active the POST method
curl_setopt($ch, CURLOPT_POST, 1) ;
// Request
curl_setopt($ch, CURLOPT_POSTFIELDS, $strRequest);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
// execute the connexion
$result = curl_exec($ch);
// Close it
curl_close($ch);
return $result;
}
#usage
$strRequest = utf8_encode(‘
RequestPassword="xxx"
/>‘);
$Response = httpsPost($url, $strRequest);
As you can see i tried to comment it as much as i can…
Here I am returning the result instead of posting it directly, you can change this by removing this command ‘ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);’
Enjoy
and if you have any questions… do ask ![]()
Jo