Friday, October 10, 2008

Video Conversion Dynamically Using FFMPEG,PHP

Every programmer has an idea to convert the video file types dynamically into any formats on the fly. They all know there is a tool called FFMPEG to convert video formats to their desired formats which they want. In this tutorial i'll let you know how to use the FFMPEG tool during file upload dynamically.

1. Download FFMPEG.EXE from here
2. Extract the FFMPEG.EXE from the archive.
3. Place the FFMPEG.EXE in the webdirectory.
4. As you all know how to upload a file (So i'm moving to the next step).
5. After the file uploaded just put the below line
exec("ffmpeg -i recipe_videos/$path -f flv recipe_videos/$test[0].flv");
//Format exec("ffmpeg -i pathofthevideouploaded -f towhichformat wherethefiletobesavedwithextension");
6. If you want delete the old file.
7. Now you can view the video in the desired format.

Friday, August 29, 2008

FAQ

Frequently Asked Questions
1. How to create multiple rows using javascript?
2. Is it possible to integrate Highslide codings in the website?
3. What is the syntax for getting the url value?
4. What is the procedure to read the xml file using php?
5. How to create rss feeds using php?
6. How to use post method in Ajax?
7. How to configure php in IIS?
8. Is there any Free source to configure php5 in IIS?
9. How to use div concepts in php?
10. Dont you know how to use peel effect in website?
11. How to submit flash values to php?
12. Where can i get free photoshop,flash,Dream weaver,actionscript tips & tricks ?
13. Which method in php should i use to get the value of the url?
14. How to make a website rich,userfriendly & browser compatability using php?
15. Will PHP5 work in IIS?

Add Multiple rows dynamically by clicking Add New Button

Copy the javascript coding & paste it in head.

<1script type="text/javascript">
function AddRow()
{

var dcname =document.getElementById("dcname");
var dqty =document.getElementById("dqty");
var dstype =document.getElementById("dstype");
var dnature =document.getElementById("dnature");
var morerow=document.getElementById("tbl")
var newtr = document.createElement("tr");

var newtd1 = document.createElement("td");
newtd1.innerHTML = dcname.innerHTML;
newtr.appendChild(newtd1);
var newtd2 = document.createElement("td");
newtd2.innerHTML = dqty.innerHTML;
newtr.appendChild(newtd2);
morerow.appendChild(newtr);
var newtd3 = document.createElement("td");
newtd3.innerHTML = dstype.innerHTML;
newtr.appendChild(newtd3);

var newtd4 = document.createElement("td");
newtd4.innerHTML = dnature.innerHTML;
newtr.appendChild(newtd4);
}
<1/script>

Paste the below content in the body section
<1table width="100%">
<1tbody id="tbl">
<1tr>
<1td><1div align="center">Chemical Name <1/div><1/td>
<1td><1div align="center">Quantity<1/div><1/td>
<1td><1div align="center">Storage Type <1/div><1/td>
<1td><1div align="center">Nature Of <1/div><1/td>
<1td> <1/td>

<1tr>
<1td><1input name="cname[]" type="text" id="cname" style="font-size:10;">
<1td><1input type="text" name="qty[]" id="qty" style="font-size:10;">
<1td><1input name="stype[]" type="text" id="stype" size="10">
<1td><1input type="text" name="natureof[]" id="natureof" style="font-size:10;">
<1td><1input name="Add" type="button" value="add" onclick="return AddRow();">
<1/tr>
<1/tbody>

<1div id="dcname" style="display:none; visibility:hidden"><1input name="cname[]" type="text" id="cname" size="10"><1/div>
<1div id="dqty" style="display:none; visibility:hidden"><1input type="text" name="qty[]" id="qty" size="10"><1/div>
<1div id="dstype" style="display:none; visibility:hidden"><1input type="text" name="stype[]" id="stype"><1/div>
<1div id="dnature" style="display:none; visibility:hidden">

<1input type="text" name="natureof[]" id="natureof" size="10"><1/div>

That's it now you have created a single row and by clicking add new it will add any number of rows dynamically

Note : Remove 1 on every html tag

Thursday, August 28, 2008

Read XML Using PHP DOM

This tutorial is for PHP starters as well as for those who are using XML parser functions to read/write XML files. This tutorial will not go into details on XML. The focus will be more on the Document Object Model (DOM) extension.


This should not be confused with DOM XML extension, which is not packaged into PHP5 and will never be (according to php.net). DOM extension allows PHP users to use the DOM functions. The function then allow users to read, write, rename tags and do all types of crazy stuff with XML documents.



First we need a XML document to experiment with. I have created a simple XML document and named it readfromxml.xml


readfromxml.xml


<1?xml version="1.0" encoding="ISO-8859-1"?>

<1html>

<1head>

<1pagename>Current page name<1/pagename>

<1title>Title for Pagename<1/title>

<1keyword>meta keyword for current page<1/keyword>

<1description>meta Description for current page<1/description>

<1/head>

<1/html>


This XML document stores pagename,title of the page,keyword for the page and description for the page. You can create one for any type of webpage to create keywords, description dynamically & manage for every single page. Every note in this XML file beings < with and ends with >. Within the tab I have created a tab for the keyword ( ),description ( ),title ( ),pagename ().



Next step is to read this XML and display the results on a web page.


Create another file and call it readfromxml.php. Copy the following code into it and run it.



// DOMElement->getElementsByTagName() -- Gets elements by tagname
// nodeValue : The value of this node, depending on its type.
// Load XML File. You can use loadXML if you wish to load XML data from a string

$objDOM = new DOMDocument();
$objDOM->load("readfromxml.xml"); //make sure path is correct


$note = $objDOM->getElementsByTagName("head");
// for each note tag, parse the document and get values for
// tasks and details tag.

foreach( $note as $value )
{

$page = $value->getElementsByTagName("pagename");
$page = $page->item(0)->nodeValue;
if($page == $pagename)
{
$title = $value->getElementsByTagName("title");
$title = $title->item(0)->nodeValue;

$keywords = $value->getElementsByTagName("keyword");
$keywords = $keywords->item(0)->nodeValue;

$description = $value->getElementsByTagName("description");
$description = $description->item(0)->nodeValue;
}
}


?>

create a webpage as index.php and copy the following content and paste it in index.php

$pagename = "index.php";
require("readfromxml.php");
?>
<1!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<1html xmlns="http://www.w3.org/1999/xhtml">
<1head>
<1meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<1META NAME="DESCRIPTION" CONTENT="" />
<1META NAME="KEYWORDS" CONTENT="" />

<1title><1/title>
<1/head>

<1body>
<1/body>
<1/html>



This tutorial is a kick start for beginners. You can retreive data from a database and create a XML document on-the-fly with DOM functions, rename tabs in an existing XML document and validate format.

Note : Remove 1 on every tag

oDesk Certified Software Testing Engineer

Get the current page url using php

//This function returns the full url of the current page
function getcurrentpageurl() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
echo getcurrentpageurl();
?>

//This function returns the filename alone
function getcurrentpagename() {
return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
}

echo "The current page name is ".getcurrentpageurl();
?>
oDesk Certified Software Testing Engineer

Monday, July 21, 2008

Installing Apache 2 and PHP 5 (and MySQL) on Windows XP

Installing Apache 2 and PHP 5 (and MySQL) on Windows XP

Contents


  1. Introduction

  2. Set up a directory structure

  3. Download and Install Apache 2.0

  4. Download and Install PHP 5

  5. Configuring Apache

  6. Some extra steps: Setting up a development environment and installing MySQL

  7. Conclusion

0. Introduction

First, a couple short notes on whom this tutorial is for. First, it's for people who want to install
PHP 5 and Apache 2; other versions will follow similar procedures, but they will by no means be identical, and these instructions will not work with them. Second, I've written this mostly with the beginner in mind, with the objective being to walk you through installation and setup of your own local web server to use as a learning and testing tool.That said, the instructions here should serve as useful information for the more experienced web developer/administrator who needs a refresher on installation, or runs into a problem along the way. If you're planning on connecting your server to the internet and serving files to the World, as usual, make sure you know what you're doing first -- you'll get very little sympathy if something goes wrong because you didn't.

On business: In this tutorial, I'll show you how to install Apache and PHP on Windows XP, as well as how to set up a nice working environment. As a bonus, I'll also show you how to install MySQL if you're interesed.

Below are some words of encouragement for those who might not know what all of this means. If you're already convinced, skip ahead to the next section. :-)

Note: If you're a little unsure of what a web server is, it can mean two things: (1) a computer that serves web pages and other content to web browsers and other client programs (this is the definition most people learn first), or (2) a program on a computer
that enables it to serve such content. Apache is a web server as defined in the second sense, i.e. it is software. Once you install it on your computer, you will be able to view web pages, PHP pages, etc, on your local machine as if they were on a site on the internet. In fact, other computers connected to your local network will be able to access the content you serve, and if you choose, you can even make your server available on the internet.

Many people think they need to buy web hosting in order to learn PHP and test their scripts.
You can learn a lot by having some space on a remote server, and they often have many modules and extensions installed and configured, so you can focus on your programming and not have to worry about the details. I learned to program on a remote server, and I picked up a lot of skills, like using the Linux shell, along the way. But you don't have to do it this way. Inevitably, you will eventually want to run a web server on your local machine so you can test scripts quickly and easily, and you might be surprised at how much faster you can actually program if you do this. My advice is, start early and install a web server and PHP on your local machine today!
Like learning to program remotely, it will teach you useful skills. It allows you to program more quickly, to play with different configurations both on- and offline, and best of all, if the web server is free it doesn't cost you a dime. In this tutorial, I will show you how to install one of the most popular web servers, Apache 2.0, and PHP 5 on your Windows XP machine. I'm choosing the Windows environment simply because a lot of people, especially people who are learning to program, have it and I'd like this to be useful to as many people as possible.
Apache and PHP can be installed on other versions of Windows and other operating systems as well. I've chosen Apache because it is immensely popular, and because it is free.

1. Set up a directory structure

First, let's make a directory where you can put PHP and Apache (and maybe other programs such as Perl in the future).
To avoid any potential problems, it's best to create this directory on a path that does not have any spaces. I put mine on a second partition, in the WebServer directory of the Web folder where I keep all my web development data:

D:\Web\WebServer

Pick something similar for yourself, and create your folder.

Inside that folder, create a folder called PHP. Simple enough: now on to the good stuff.

2. Download and Install Apache 2.0

Note: I've gotten a couple questions about installing PHP 5 with Apache 2.2.
When I first wrote this tutorial, that would not work, because the php5apache2.dll
that came with PHP 5 was incompatible with Apache 2.2. However, PHP 5.2.5 (the latest version as of this revision) includes an php5apache2_2.dll file that is compatible with Apache 2.2. If you want to install Apache 2.2, use this DLL instead when following the instructions in this article. Thanks to Wouter Smit for pointing this out.

First, download the Win32 Binary (MSI Installer — see the note immediately below) from the Apache download page. To the right of the download link, you will see a link called "[MD5]". Follow this link after your file has downloaded, and you will see some text that looks like

Note: If your Windows Installer (msiexec) is not up to date, using an MSI installer may not work properly. In that case (or if you're unsure), you are better off using the EXE installer instead, which you can download from one of Apache's binary mirror sites. 44358b283212d5c144524231fc0cb562 apache_1.3.34-win32-x86-no_src.exe

Leave this page open - we will use it in a minute to verify the integrity of the
installer we just downloaded.

Next, go to pc-tools.net
and download the md5sums-1.2.zip file to the same folder where you saved the Apache installer
(the desktop is fine), and unzip it. Make a new text file in the same folder and put the following in it:

md5sums -p -n -b apache_2.0.55-win32-x86-no_ssl.msi

(if you have downloaded a slighly different version of the installer, change the name of the file to match yours).
Save the file as check_Apache_md5.bat, and run (open) it. The screen that pops up should look something like




Compare the code in the red box to the code on the page opened by the "[MD5]" link. If it is the same, then your file integrity is good, and you can proceed. If it is different, the file is damaged and you should download it again, probably from a different mirror (see the top of the Apache download page).

Once you have a file that is authenticated, you can delete the check_Apache_md5.bat, the
md5sums-1.2.zip file, and the md5sums.exe and md5sums.txt files (although you may want to keep the md5sums program for future use).

Now we're ready to install. Double-click on the installer. Read the agreements and information, clicking next to move through each screen. On the fourth screen, you will see the following:




I'll quote the explanation of each of these settings directly from the Apache documentation:

# Network Domain. Enter the DNS domain in which your server is or will be registered in. For example, if your server's full DNS name is server.mydomain.net, you would type mydomain.net here.
# Server Name. Your server's full DNS name. From the example above, you
would type server.mydomain.net here.

# Administrator's Email Address. Enter the server administrator's or
webmaster's email address here. This address will be displayed along
with error messages to the client by default.

# For whom to install Apache Select for All Users, on Port 80, as a
Service - Recommended if you'd like your new Apache to listen at port
80 for incoming traffic. It will run as a service (that is, Apache will
run even if no one is logged in on the server at the moment) Select
only for the Current User, on Port 8080, when started Manually if you'd
like to install Apache for your personal experimenting or if you already
have another WWW server running on port 80.

Here you have a few options:

  • If you are going to be using Apache only for testing scripts on your own machine, you can enter localhost for the first two values and anything you'd like for the email
    address (e.g. admin@localhost). If you're only going to be using Apache sometimes and
    only when you are logged on, it does not make sense to run it as a service, because it will eat up system resources and potentially pose a security risk. Select "only for the Current User, on Port 8080, when started Manually". Press "Next" and skip ahead.

  • If you would like to install Apache to be used as a local area network server, you should set your router to assign the computer you are installing Apache on to have a static LAN ip address (if it does not already have one. This issue is beyond the scope of this article; refer to your router's documentation, or consult the person in charge of your network). Enter either this IP address, or a network name that you will use to acess the server from within your network in the first two boxes (if you choose a name, you will need to update the
    Hosts file of the users on your network so that when they type the name in a browser, it maps to your computer's IP addresss). Enter an appropriate email address in the
    third box, and choose "for All Users, on Port 80, as a Service - Recommended". Press "Next" and skip ahead.

  • If you would like your server to be accessible through the internet, you will need your computer to either have a static internet IP address and set up a domain name server
    (DNS) to point your domain name to your computer's IP (this is beyond the scope of this article). If you do not have a static IP, you can set up your computer to have a static local IP as described in the last paragraph, and use a dynmaic DNS service such as
    dyndns.com to keep your current IP up to date on the DNS. A good router
    will allow you to automatically update the dynamic DNS when the router acquires an IP address. You will also need to set up port forwarding so that all incoming traffic on port 80 is forwarded to your computers static local IP address. Enter the dynamic DNS domain name, e.g. mysite.dnydns.org, for the first two entries, and an appropriate email adress for the third. choose "for All Users, on Port 80, as a Service - Recommended". Press "Next" and skip ahead.

Note:
If the last paragraph does not make sense, you should probably not do it yet, because there are important security issues you are most likely not aware of. Before setting up a web server to run on the internet, make sure you have educated yourself about all the factors involved. You make your computer available to outsiders at your own risk; if you make it available in ignorance, you do so at your peril.

The next screen you see will look like this:




Choose "Custom" and press "Next". On the following screen
you will see the default path Apache installs to:




Click the "Change..." button (boxed in red in the picture), and choose the WebServer folder (or
whatever other name you chose) you made when you created the directory structure above. Click "Next".

On the next screen click "Install". After it installs click "Finish". Congratulations, you just installed Apache.
It is located in your WebServer folder in the Apache2 directory.

Let's make sure it worked. Go to your programs folder in the Start menu and find the Apache HTTP Server folder.
Go to the Control Apache Server folder, and start Apache








If you installed Apache as a service, you can also start it by double-clicking on the Apache Service Monitor
tray icon (which looks like: ) and pressing the "Start" button in the window that appears.
If you did not install it as a service, you will see a blank command prompt window appear while Apache is running.
This is normal.

The first time you run Apache, you will probably see a security warning pop up:





This is because windows has detected that Apache is opening a port on your computer, and it is checking with you about whether it should let Apache continue. Click the "Unblock" button to allow Apache to function.


Note: While we're talking about these security warnings, it's worth noting that the Winows XP firewall is far from ideal, especially for advanced users. Even compared to most free alternatives, the best you can usually say is that it's better than nothing. Especially if you're considering connecting your web server to the internet, you ought to get a separate firewall program.
Some good freeware/shareware alternatives are ZoneAlarm,
Kerio Personal Firewall,
Agnitum, and
Sygate Personal Firewall.

Now, let's open up a web browser and make sure Apache is running. Type in the name of your server (e.g. localhost, or your domain name or IP address) in the location bar of the browser. If you did not install Apache as a service, follow the server name with :8080 (for example, if you are running the server as localhost, you would type localhost:8080. If Apache is working, you should see a page that looks like




If so, you're ready to move on. If not, something is wrong. It is hard to be sure what, but it might help to ask for assistance in the ERT forum. Otherwise, your best
bet is to uninstall Apache and try again.

Note if you did not install Apache as a service:

Unless you have some reason for Apache to run on port 8080, it is far more convenient to run it on port 80 instead so that you do not have to add on :8080 to your server name every time you type it (port 80 is the default HTTP port). Go to your Apache2 folder, and open the file httpd.conf in the conf folder. On around line 956, you will see

Listen 8080

change that to

Listen 80

Save the httpd.conf file, and restart Apache (in the Service Monitor, or manually quit and
start it again if you have not installed Apache as a service). We'll do more configuration of Apache later.

3. Download and Install PHP 5

The PHP documentation is very good,
I encourage you to read it over a bit before proceeding, or if you get stuck/confused below.

Start by going to the PHP.net download page and getting the
PHP 5.x.x zip package under the "Windows Binaries" heading. It may seem easier to use the installer, but as you work with PHP, you will probably want to enable several extensions that are not enabled by default, and this is much simpler if you have installed PHP manually.

After the zip file downloads, place it in your WebServer\PHP directory, and unzip it there. When
it is done decompressing all the files, you can delete the zip file. Notice that there are a few executables:

  1. php-cgi.exe: This is used when you run PHP through your webserver as a CGI executable.
  2. php-win.exe: Executes scripts without having to have an open command prompt. You can drag your php scripts onto this program to execute them. You'll use this for local command line (command line interface, or CLI) programs.
  3. php.exe: the CLI interface for command line scripting. You'll use this from the command prompt to execute PHP.

For PHP to work with Apache and to make the CLI available from any command prompt window, we need to add the PHP folder to the PATH environment variable. To do this,
right click on your "My Computer" icon (either on your desktop or the start menu) and select "Properties." In the window that pops up, select the advanced tab, and click on the "Environment Variables" button.




In the window that appears, select the "Path" variable line from the "System Variables" menu, and click edit:




At the end of the "Variable Value" field, type a semicolon (;) and the type in the full path to your
PHP folder. For me, this means typing the following at the end of the "Variable Value" field:
;D:\Web\WebServer\PHP.




Hit OK in each window until they have all closed, and restart your computer.
Pick up back here when you've restarted.

OK, you restarted and you're back. Let's make sure PHP is working. Go to Start->Run and type cmd and press OK to bring up a command window. At the command prompt, type php -v and press Enter. If you updated the PATH varaible correctly, you should see something like:


PHP 5.1.2 (cli) (built: Jan 11 2006 16:40:00)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
If you get an error message like,

"php is not recognized as an internal or external command,
operable program or batch file
" go back and check to make sure you completed all the steps
of adding your PHP folder to your PATH variable, and that you typed the file path correctly.

Now open you PHP folder, and change the name of the file php.ini-recommended
to php.ini. The settings in this file are all pretty much exactly as they should be.
If you are installing Apache and PHP on your own system for testing purposes, it is probably a good idea to open your php.ini file in a text editor, and change the setting on or about line
357 from display_errors = Off to display_errors = On so that you will see any errors generated by your scripts and will be able to easily debug them. If you are planning on making
your server public, it is best to leave this setting Off, because displaying errors can expose information about your file system, databases, and server configuration that should be kept private. Either way, the setting on line 367, log_errors = On will ensure that you will have a log of errors that you can review.

Make the following changes to the file:

Line 512: doc_root = D:\Web\WebServer\Apache2\htdocs

Line 519: extension_dir = D:\Web\WebServer\PHP\ext

Save the php.ini file and close it. You can find more information about
configuring PHP in the Runtime Configuration section
of the PHP manual.

4. Configuring Apache

Now that we've got PHP and Apache working separately, we need to get get them to work together.
Go to your Apache2/conf folder, and open up the httpd.conf file in a text
editor. You can get Apache to run PHP as either a CGI binary, or an Apache Module. Generally speaking,
it is faster and more secure to do the latter, which you do by adding the following to your
httpd.conf file:

  1. At the top of the LoadModule section, starting around line 130, add the line

    LoadModule php5_module "D:/Web/WebServer/PHP/php5apache2.dll"

    (note those are foward slashes, not backslashes, in the path) where you
    replace "D:/Web/WebServer/PHP/php5apache2.dll" with the path to php5apache2.dll on your computer (note: if you are installing Apache 2.2, you should use the php5apache2_2.dll file instead). You can actually add settings anywhere you would like, but putting the similar ones together helps keep things organized.

  2. In the AddType section around line 754, add the following line:

    AddType application/x-httpd-php .php

    You can add other extensions besides .php if you want PHP to parse other file types as well. For example, if you want to be able to include PHP in .html documents:

    AddType application/x-httpd-php .php .html

  3. Finally, add the following line, somewhere that seems sensible to you:

    PHPIniDir "D:/Web/WebServer/PHP/"

    (again, replace the path I used with the one you chose on your computer).

Note: If Apache does not seem to recognize your PHPIniDir directive,
make sure you have the trailing slash (i.e. not PHPIniDir "D:/Web/WebServer/PHP"), as mentioned in the user comments in the PHP manual

Save the httpd.conf file, and start Apache as discussed above (or restart it if it is running).

If for some reason you need to run PHP as a CGI binary, add these lines to your httpd.conf file instead.

ScriptAlias /php/ "D:/Web/WebServer/PHP/"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/PHP/php-cgi.exe"
Note that you cannot run PHP as a module and a CGI at the same time. If you are switching between the two types of setups, you'll need to comment-out (with a hash sign #) or delete the existing configuration lines before adding the new ones. Each time you change the server configuration by editing httpd.conf, you'll need to restart Apache for the changes to take effect.

Open your Apache2htdocs folder. This is the root folder for all of your web server documents that you will view in your web browser. Start by erasing all the default files currently in there. Next, make a file called phpinfo.php that contains the following:

<?php phpinfo(); ?>

and save it in your htdocs folder. Now open a web browser and go to

http://localhost/phpinfo.php. You should see a page that looks like



If not, make sure that all the lines that you added to your httpd.conf file are exactly as they appear above (including the trailing slashes where applicable), and that all paths are correct.


5. Some extra steps: Setting up a development environment and installing MySQL

In principle, we're done. You can now start writing your own PHP scripts in your htdocs folder
and viewing them in your web browser (when Apache is running, of course) at http://localhost or whatever URL where you have chosen to locate your webserver. There are a couple more things that are good to do in practice in order to set yourself up with a nice working environment.

  • Place some shortcuts on your desktop. Add one for your htdocs folder for easy access, and another to start Apache (if you're running Apache as a module, you can just as easily use the service monitor).

    Add a folder called PHPCLI to your WebServer directory, where you can will keep you command line PHP scripts. Place a shortcut to this on your desktop too, and make a file called PHPFolder.bat on your desktop that contains the following lines:

    D:
    cmd /k cd D:\Web\WebServer\PHPCLI

    This will open a command prompt in your PHPCLI folder so that you can easily test and run your CLI scripts.

  • Enable some extensions. Open up your php.ini file again, and go to abou line 620. There are a whole bunch of lines that look like

    ;extension=php_mbstring.dll
    ;extension=php_bz2.dll
    ;extension=php_curl.dll
    ;extension=php_dba.dll
    ;extension=php_dbase.dll
    ;extension=php_exif.dll
    ;extension=php_fdf.dll
    ;extension=php_filepro.dll
    ;extension=php_gd2.dll
    ;extension=php_gettext.dll
    ;extension=php_ifx.dll
    ;extension=php_imap.dll
    ;extension=php_interbase.dll
    ;extension=php_ldap.dll
    ;extension=php_mcrypt.dll
    ;extension=php_mhash.dll

    The semicolon (;) is the comment symbol in the php.ini (don't confuse it with the #
    in the httpd.conf), and thus these lines are commented-out, and the extensions are not running. To enable any extensions that you want, just remove the semicolon at the beginning of the line.

Some of the extensions, such as MySQL, require that you have other software installed. In fact, as an added bonus, here's how to install MySQL:

Installing MySQL Server

  1. Go to the MySQL website and download the installer.
    You want the Windows (x86) version (you'll have to scroll down a bit to see it -- don't confuse it with the Windows Essentials version). Note the MD5 checksum, which
    we'll use in step 2. Choose a mirror that is a close to you a possible and download the zip file (or just click "Download" and one will be chosen for you).

  2. Check the MD5 checksum with the value they have next to the download link on the site.
    You do this in the same way you did for Apache above, but this time using the name of the zip file, e.g.

    md5sums -p -n -b mysql-5.0.18-win32.zip

    If it checks out, unzip the file (this will produce a file called Setup.exe), and delete the zip file after it's done. If the checksum does not match, download again from another mirror.

  3. Make a MySQL folder in your WebServer directory. Run Setup.exe.
    Click "Next" at the first screen.
    At the second screen, choose "Custom" for the installation type and click "Next". Click on the "Change" button in the lower left to change the installation directory, and point it to the MySQL folder youjust created:





    Then click "Install" and let it do its thing. When it's done, you can sign up for a MySQL.com account if you want to. Otherwise, choose "Skip Sign-Up" in the bottom left and press Next, and then press Finish on the next screen.

  4. The MySQL Server Instance Configuration Wizard will pop up. Click "Next". Choose "Detailed Configuration"
    and click "Next". Answer the questions according to what kind of machine your computer is. The instructions are fairly straight forward. On the Windows Options Page, you may want to un-check the "Launch MySQLServer automatically" option, and check the Include Bin Directory in Windows PATH so that you can use the MySQL server from the windows command line. It is easiest to Run MySQL as a Windows service.






    Note that you can use the Apache Service monitor to start and stop MySQL (and other services).

    On the next screen, pick a root password. This is the main "superuser" password for your server:



    Finally, click the "Execute" button to configure your MySQL server:





    Its not a big deal if you do not configure your server right at first, you can always run the config wizard again later. It is in your MySQLbin folder, MySQLInstanceConfig.exe.

  5. Restart (this is so your PATH variable gets updated).
  6. Uncomment the line extension=php_mysql.dll (around line 650) in your php.ini
    and (re)start Apache.

  7. Have a look at your phpinfo.php file. If you sucessfully set up MySQL, it should have a section that looks like this:




That's all. Remember to use MySQL with PHP, it has to be running, and you need to create users, tables etc. for PHP to work with. Once MySQL is running, you can access it via the command line by typing mysql -u root -p and entering your root password (which you set during the MySQL installation) when prompted. You can also access the mysqladmin command this way to add other users to your databases (there is also a command line connection option in the MySQL section of your program list in the Start menu).

MySQL Administrator: A Graphical Interface

If you're not comfortable with using MySQL from the command line (or even if you are), you might want to get yourself a graphical administration tool. Several GUIs are available; I use the one made by MySQL, called the MySQL Administrator. Just download it
(be sure to check the MD5 checksum), and run the installer choosing the "Complete" installation type. You can install it anywhere you'd like (I put mine in my Program Files folder). Have a look at the documentation for more information about using MySQL Administrator.

Note: A couple times when I've installed MySQL Server and Administrator, I had trouble connecting to MySQL using the Administrator, even though it worked fine from the command line. I spent a very long time trying to figure out why this happened, and was never able to figure it out for sure. If this happens to you, try reconfiguring MySQL as described above (maybe you made a mistake the first time). If that doesn't work, the problem has always been solved for me by simply uninstalling both the Server and the Administrator (use the Add and Remove Programs option in your Windows XP Control Panel) and reinstalling.

6. Conclusion

Congratulations! You've got a great environment set up for building an testing websites and web applications. Hopefully you didn't find the process too painful. Have fun with it!


oDesk Certified Software Testing Engineer

Tuesday, July 15, 2008

PHP-Mysql Interview Questions

Q:1
How can we submit a form without a submit button?

A:1
The main idea behind this is to use Java script submit() function in order to submit the form without explicitly clicking any submit button. You can attach the document.formname.submit() method to onclick, onchange events of different inputs and perform the form submission. you
can even built a timer function where you can automatically submit the form after xx seconds once the loading is done (can be seen in online test sites).

Q:2
In how many ways we can retrieve the data in the result set of MySQL using PHP?

A:2
You can do it by 4 Ways
1. mysql_fetch_row.

2. mysql_fetch_array

3. mysql_fetch_object

4. mysql_fetch_assoc

Q:3
What is the difference between mysql_fetch_object and mysql_fetch_array?

A:3
mysql_fetch_object() is similar tomysql_fetch_array(), with one difference - an object is returned, instead of an array. Indirectly, that means that you can only access the data by the field names, and not by their offsets (numbers are illegal property names).

Q:4
What is the difference between $message and $$message?
A:4
It is a classic example of PHP’s variable variables. take the following example.$message = “Mizan”;$$message = “is a moderator of PHPXperts.”;$message is a simple PHP variable that we are used to. But the $$message is not a very familiar face. It creates a variable name $mizan
with the value “is a moderator of PHPXperts.” assigned. break it like this${$message} => $mizanSometimes it is convenient to be able to have variable variable names. That is, a variable name which can be set and used dynamically.

Q:5
How can we extract string ‘abc.com ‘ from a string ‘http://info@abc.com’
using regular expression of PHP?


A:5
preg_match(”/^http:\/\/.+@(.+)$/”,’http://info@abc.com’,$found);

echo $found[1];

Q:6
How can we create a database using PHP and MySQL?

A:6
We can create MySQL database with the use of

mysql_create_db(“Database Name”)

Q:7
What are the differences between require and include, include_once and require_once?

A:7
The include() statement includes and evaluates the specified file.The documentation below also applies to require(). The two constructs are identical in every way except how they handlefailure. include() produces a Warning while require() results in a Fatal Error. In other words, use require() if you want a missingfile to halt processing of the page.

include() does not behave this way, the script will continue regardless.

The include_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include() statement, with the only differencebeing that if the code from a file has already been included, it will not be included again. As the name suggests, it will be included just once.include_once() should be used in cases where the same file might be included and evaluated more than once during a particularexecution of a script, and you want to be sure that it is included exactly once to avoid problems with function redefinitions, variable value reassignments, etc.
require_once()
should be used in cases where the same file might be included and evaluated more than once during a particular execution of a script, and you want to be sure that it is included exactly once to avoid problems with function redefinitions, variable value reassignments, etc.

Q:8
Can we use include (”abc.PHP”) two times in a PHP page “makeit.PHP”?

A:8
Yes we can use include() more than one time in any page though it is not a very good practice.



Q:9
What are the different tables present in MySQL, which type of table is generated when we are creating a table in the following syntax:
create table employee (eno int(2),ename varchar(10)) ?


A:9
Total 5 types of tables we can create
1. MyISAM
2. Heap
3. Merge
4. INNO DB
5. ISAM

MyISAM is the default storage engine as of MySQL 3.23 and as a result if we do not specify the table name explicitly it will be assigned to the default engine.

Q:10
How can we encrypt the username and password using PHP?
A:10
The functions in this section perform encryption and decryption, and compression and uncompression:
encryption decryption

AES_ENCRYT() AES_DECRYPT()

ENCODE() DECODE()

DES_ENCRYPT()   DES_DECRYPT()

ENCRYPT() Not available

MD5() Not available

OLD_PASSWORD() Not available

PASSWORD() Not available

SHA() or SHA1() Not available

Not available UNCOMPRESSED_LENGTH()


oDesk Certified Software Testing Engineer

Get Flash Designing tips

You can get Flash Designing tips,Slideshow using flash & XML, Highslides using accordian in myinnovativeidea.blogspot.com

oDesk Certified Software Testing Engineer

Thursday, June 19, 2008

Simple Ajax Coding

oDesk Certified Software Testing Engineer

var xmlHttp // xmlHttp variable
function GetXmlHttpObject() { var objXMLHttp = null;
if( window.XMLHttpRequest ) {
try {
objXMLHttp = new XMLHttpRequest();
}
catch( e ) {
objXMLHttp = false; }
}
else if( window.createRequest ) {
try {
objXMLHttp = new window.createRequest();
}
catch( e ) {
objXMLHttp = false;
}
}
else if( window.ActiveXObject ) {
try {
objXMLHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch( e ) {
try {
objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch( e ) {
objXMLHttp = false;
}
}
}
return objXMLHttp;
}
function search_subcategory(){
//alert('sdfsdf');
document.getElementById('subcategory_label').style.display="none";
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null){
alert ("Browser does not support HTTP Request")
return
}
var val = document.getElementById('category').value;
var url="dropdown.php?val="+val;//alert(url);
xmlHttp.onreadystatechange = response;xmlHttp.open("GET",url,true);
xmlHttp.send(null);
function response(){
if (xmlHttp.readyState == 4) {
var x =xmlHttp.responseText;
document.getElementById('subcategory_label').style.display="block"; document.getElementById('subcategory_label').innerHTML = x; }
else {
document.getElementById(y).style.display = "block";
document.getElementById(y).innerHTML ="Loading...";
}
}
}

Tuesday, May 27, 2008

HighSlide works

oDesk Certified Software Testing Engineer
Place the below coding in any HTML file
------------------------------------------------------------------------------------
Place it in header
------------------------------------------------------------------------------------
<1script type="text/javascript" src="highslide.js"><1/script>
<1script type="text/javascript">
hs.graphicsDir = 'js/graphics/';
hs.outlineType = 'rounded-white';
hs.outlineWhileAnimating = true;
<1/script>
------------------------------------------------------------------------------------
<1div class="highslide-html-content" id="highslide-html-newsletter">
<1div class="highslide-header">
<1ul>
<1li class="highslide-move">
<1ahref="http://www.blogger.com/post-create.g?blogid=8488539832279332237#" onclick="return false">Move
<1/li>
<1li class="highslide-close">
<1a href="http://www.blogger.com/post-create.g?blogID=8488539832279332237#" onclick="return hs.close(this)">Close
<1/ul>
<1/div>
<1div class="highslide-body">
<1!-->
<1/div>
<1div class="highslide-footer">
<1div>
<1span class="highslide-resize" title="Resize">
<1/span> <1/div>
<1/div>
<1/div>

Remove 1 in every html tag
------------------------------------------------------------------------------------
Style sheet
Save the coding as slide.css
------------------------------------------------------------------------------------
* {
font-family: Verdana, Helvetica;
font-size: 10pt;
}
.highslide-html {
background-color:#FFC1FF;



}
.highslide-html-blur {
}
.highslide-html-content {
position: absolute;
display: none;
}
.highslide-loading {
display: block;
color: black;
font-size: 8pt;
font-family: sans-serif;
font-weight: bold;
text-decoration: none;
padding: 2px;
border: 1px solid black;
background-color: white;

padding-left: 22px;
background-image: url(highslide/graphics/loader.white.gif);
background-repeat: no-repeat;
background-position: 3px 1px;
}
a.highslide-credits,
a.highslide-credits i {
padding: 2px;
color: silver;
text-decoration: none;
font-size: 10px;
}
a.highslide-credits:hover,
a.highslide-credits:hover i {
color: white;
background-color: gray;
}


/* Styles for the popup */
.highslide-wrapper {
background-color: white;
}
.highslide-wrapper .highslide-html-content {
width: 350px;
padding: 5px;
}
.highslide-wrapper .highslide-header div {
}
.highslide-wrapper .highslide-header ul {
margin: 0;
padding: 0;
text-align: right;
}
.highslide-wrapper .highslide-header ul li {
display: inline;
padding-left: 1em;
}
.highslide-wrapper .highslide-header ul li.highslide-previous, .highslide-wrapper .highslide-header ul li.highslide-next {
display: none;
}
.highslide-wrapper .highslide-header a {
font-weight: bold;
color: red;
text-transform: uppercase;
text-decoration: none;
}
.highslide-wrapper .highslide-header a:hover {
color: black;
}
.highslide-wrapper .highslide-header .highslide-move a {
cursor: move;
}
.highslide-wrapper .highslide-footer {
height: 11px;
}
.highslide-wrapper .highslide-footer .highslide-resize {
float: right;
height: 11px;
width: 11px;
background: url(highslide/graphics/resize.gif);
}
.highslide-wrapper .highslide-body {
}
.highslide-move {
cursor: move;
}
.highslide-resize {
cursor: nw-resize;
}

/* These must be the last of the Highslide rules */
.highslide-display-block {
display: block;
}
.highslide-display-none {
display: none;
}

------------------------------------------------------------------------------
Now the highslide.js


var hs = {

// Apply your own settings here, or override them in the html file.
graphicsDir : 'highslide/graphics/',
restoreCursor : 'zoomout.cur', // necessary for preload
expandSteps : 10, // number of steps in zoom. Each step lasts for duration/step milliseconds.
expandDuration : 250, // milliseconds
restoreSteps : 10,
restoreDuration : 250,
marginLeft : 15,
marginRight : 15,
marginTop : 15,
marginBottom : 15,
zIndexCounter : 1001, // adjust to other absolutely positioned elements

restoreTitle : 'Click to close image, click and drag to move. Use arrow keys for next and previous.',
loadingText : 'Loading...',
loadingTitle : 'Click to cancel',
loadingOpacity : 0.75,
focusTitle : 'Click to bring to front',
allowMultipleInstances: true,
numberOfImagesToPreload : 5,
captionSlideSpeed : 1, // set to 0 to disable slide in effect
padToMinWidth : false, // pad the popup width to make room for wide caption
outlineWhileAnimating : 2, // 0 = never, 1 = always, 2 = HTML only
outlineStartOffset : 3, // ends at 10
fullExpandTitle : 'Expand to actual size',
fullExpandPosition : 'bottom right',
fullExpandOpacity : 1,
showCredits : true, // you can set this to false if you want
creditsText : 'Powered by Highslide JS',
creditsHref : 'http://vikjavev.no/highslide/',
creditsTitle : 'Go to the Highslide JS homepage',
enableKeyListener : true,


// These settings can also be overridden inline for each image
captionId : null,
spaceForCaption : 30, // leaves space below images with captions
slideshowGroup : null, // defines groups for next/previous links and keystrokes
minWidth: 200,
minHeight: 200,
allowSizeReduction: true, // allow the image to reduce to fit client size. If false, this overrides minWidth and minHeight
outlineType : 'drop-shadow', // set null to disable outlines
wrapperClassName : 'highslide-wrapper', // for enhanced css-control

// END OF YOUR SETTINGS


// declare internal properties
preloadTheseImages : [],
continuePreloading: true,
expanders : [],
overrides : [
'allowSizeReduction',
'outlineType',
'outlineWhileAnimating',
'spaceForCaption',
'captionId',
'captionText',
'captionEval',

'wrapperClassName',
'minWidth',
'minHeight',
'slideshowGroup',
'easing',
'easingClose',
'fadeInOut'
],
overlays : [],
faders : [],

pendingOutlines : {},
clones : {},
ie : (document.all && !window.opera),
safari : /Safari/.test(navigator.userAgent),
geckoMac : /Macintosh.+rv:1\.[0-8].+Gecko/.test(navigator.userAgent),

$ : function (id) {
return document.getElementById(id);
},

push : function (arr, val) {
arr[arr.length] = val;
},

createElement : function (tag, attribs, styles, parent, nopad) {
var el = document.createElement(tag);
if (attribs) hs.setAttribs(el, attribs);
if (nopad) hs.setStyles(el, {padding: 0, border: 'none', margin: 0});
if (styles) hs.setStyles(el, styles);
if (parent) parent.appendChild(el);
return el;
},

setAttribs : function (el, attribs) {
for (var x in attribs) el[x] = attribs[x];
},

setStyles : function (el, styles) {
for (var x in styles) {
try {
if (hs.ie && x == 'opacity')
el.style.filter = (styles[x] == 1) ? '' : 'alpha(opacity='+ (styles[x] * 100) +')';
else el.style[x] = styles[x];
}
catch (e) {}
}
},

ieVersion : function () {
var arr = navigator.appVersion.split("MSIE");
return arr[1] ? parseFloat(arr[1]) : null;
},

getPageSize : function () {
var iebody = document.compatMode && document.compatMode != "BackCompat"
? document.documentElement : document.body;

var width = hs.ie ? iebody.clientWidth :
(document.documentElement.clientWidth || self.innerWidth),
height = hs.ie ? iebody.clientHeight : self.innerHeight;

return {
width: width,
height: height,
scrollLeft: hs.ie ? iebody.scrollLeft : pageXOffset,
scrollTop: hs.ie ? iebody.scrollTop : pageYOffset
}
},

position : function(el) {
var p = { x: el.offsetLeft, y: el.offsetTop };
while (el.offsetParent) {
el = el.offsetParent;
p.x += el.offsetLeft;
p.y += el.offsetTop;
if (el != document.body && el != document.documentElement) {
p.x -= el.scrollLeft;
p.y -= el.scrollTop;
}
}
return p;
},

expand : function(a, params, custom) {
if (a.getParams) return params;

try {
new hs.Expander(a, params, custom);
return false;
} catch (e) { return true; }
},

focusTopmost : function() {
var topZ = 0, topmostKey = -1;
for (var i = 0; i <> topZ) {
topZ = hs.expanders[i].wrapper.style.zIndex;

topmostKey = i;
}
}
}
if (topmostKey == -1) hs.focusKey = -1;
else hs.expanders[topmostKey].focus();
},

getAdjacentAnchor : function(key, op) {
var aAr = document.getElementsByTagName('A'), hsAr = {}, activeI = -1, j = 0;
for (var i = 0; i < slideshowgroup ="=" activei =" j;" getparams =" a.onclick;" p =" a.getParams" getparams =" null;" src =" hs.getParam(a," node =" hs.$(id)," clone =" hs.clones[id]," a =" {};" clone =" node.cloneNode(true);" id =" '';" a =" d.attributes," l =" a.length;" i =" 0;" n =" a[i].name;" a =" d.childNodes;" l =" a.length;" i =" 0;" exp =" hs.last" adj =" hs.upcoming" e =" window.event;" target =" e.srcElement;" op =" null;" op =" 1;" op =" -1;" op =" 0;" returnvalue =" false;" op ="=" re =" /^highslide-wrapper-([0-9]+)$/;" el =" element;" el =" el.parentNode;" el =" element;" key =" 0;" exp =" hs.expanders[key];" a ="=" el =" el.parentNode;" el ="=" el ="=" el ="=" el =" hs.$(el);" i =" 0;" e =" window.event;"> 1) return true;
if (!e.target) e.target = e.srcElement;

var el = e.target;
while (el.parentNode
&& !(/highslide-(image|move|html|resize)/.test(el.className)))
{
el = el.parentNode;
}
var exp = hs.getExpander(el);
if (exp && (exp.isClosing || !exp.isExpanded)) return true;

if (exp && e.type == 'mousedown') {
if (e.target.form) return true;
var match = el.className.match(/highslide-(image|move|resize)/);
if (match) {
hs.dragArgs = { exp: exp , type: match[1], left: exp.x.min, width: exp.x.span, top: exp.y.min,
height: exp.y.span, clickX: e.clientX, clickY: e.clientY };

//if (hs.dragArgs.type == 'image') exp.content.style.cursor = 'move';

hs.addEventListener(document, 'mousemove', hs.dragHandler);
if (e.preventDefault) e.preventDefault(); // FF

if (/highslide-(image|html)-blur/.test(exp.content.className)) {
exp.focus();
hs.hasFocused = true;
}
return false;
}
} else if (e.type == 'mouseup') {

hs.removeEventListener(document, 'mousemove', hs.dragHandler);

if (hs.dragArgs) {
if (hs.dragArgs.type == 'image')
hs.dragArgs.exp.content.style.cursor = hs.styleRestoreCursor;
var hasDragged = hs.dragArgs.hasDragged;

if (!hasDragged &&!hs.hasFocused && !/(move|resize)/.test(hs.dragArgs.type)) {
exp.close();
}
else if (hasDragged || (!hasDragged && hs.hasHtmlexpanders)) {
hs.dragArgs.exp.redoShowHide();
}

hs.hasFocused = false;
hs.dragArgs = null;

} else if (/highslide-image-blur/.test(el.className)) {
el.style.cursor = hs.styleRestoreCursor;
}
}
return false;
},

dragHandler : function(e)
{
if (!hs.dragArgs) return true;
if (!e) e = window.event;
var a = hs.dragArgs, exp = a.exp;

a.dX = e.clientX - a.clickX;
a.dY = e.clientY - a.clickY;

var distance = Math.sqrt(Math.pow(a.dX, 2) + Math.pow(a.dY, 2));
a.hasDragged = (a.type != 'image' && distance > 0)
|| (distance > (hs.dragSensitivity || 5));

if (a.hasDragged) {
exp.move(a);
}
return false;
},

addEventListener : function (el, event, func) {
try {
el.addEventListener(event, func, false);
} catch (e) {
try {
el.detachEvent('on'+ event, func);
el.attachEvent('on'+ event, func);
} catch (e) {
el['on'+ event] = func;
}
}
},

removeEventListener : function (el, event, func) {
try {
el.removeEventListener(event, func, false);
} catch (e) {
try {
el.detachEvent('on'+ event, func);
} catch (e) {
el['on'+ event] = null;
}
}
},

preloadFullImage : function (i) {
if (hs.continuePreloading && hs.preloadTheseImages[i] && hs.preloadTheseImages[i] != 'undefined') {
var img = document.createElement('img');
img.onload = function() { hs.preloadFullImage(i + 1); };
img.src = hs.preloadTheseImages[i];
}
},
preloadImages : function (number) {
if (number && typeof number != 'object') hs.numberOfImagesToPreload = number;
var a, re, j = 0;

var aTags = document.getElementsByTagName('A');
for (var i = 0; i < a =" aTags[i];" re =" hs.isHsAnchor(a);" cur =" hs.createElement('img'," container =" hs.createElement('div'," loading =" hs.createElement('a'," lineartween =" function" easeinquad =" function" i ="=" dur =" 250;" i =" hs.faders.length;" dir =" oFinal"> o ? 1 : -1;
var step = (25 / (dur - dur % 25)) * Math.abs(o - oFinal);
}
o = parseFloat(o);
el.style.visibility = (o <= 0) ? 'hidden' : 'visible'; if (o < dir ="="> oFinal)) return;
if (el.fading && el.fading.i != i) { // reverse
clearTimeout(hs.faders[el.fading.i]);
o = el.fading.o;
}
el.fading = {i: i, o: o, step: (step || el.fading.step)};
el.style.visibility = (o <= 0) ? 'hidden' : 'visible'; hs.setStyles(el, { opacity: o }); hs.faders[i] = setTimeout(function() { hs.fade(el, o + el.fading.step * dir, oFinal, null, i, dir); }, 25); }, close : function(el) { try { hs.getExpander(el).close(); } catch (e) {} return false; } }; // end hs object //----------------------------------------------------------------------------- hs.Outline = function (outlineType, onLoad) { this.onLoad = onLoad; this.outlineType = outlineType; var v = hs.ieVersion(), tr; this.hasAlphaImageLoader = hs.ie && v >= 5.5 && v < table =" hs.createElement(" tbody =" hs.createElement('tbody'," td =" [];" i =" 0;" 3 ="=" tr =" hs.createElement('tr'," style =" i" classname =" outlineType;" prototype =" {" src =" hs.graphicsDir" appendto =" hs.safari" graphic =" hs.createElement('img'," pthis =" this;" onload =" function()" src =" src;" o =" this.offset" pos =" [[0,0],[0,-4],[-2,0],[0,-8],0,[-2,-8],[0,-2],[0,-6],[-2,-2]]," dim =" {" i =" 0;" w =" (i" i ="=" div =" hs.createElement('div'," sizingmethod="scale," src="'" i ="=" i ="=" visibility =" (h">= 4 * this.offset)
? 'visible' : 'hidden';
this.table.style.left = (x - this.offset) +'px';
this.table.style.top = (y - this.offset) +'px';
this.table.style.width = (w + 2 * (exp.offsetBorderW + this.offset)) +'px';
w += 2 * (exp.offsetBorderW - this.offset);
h += + 2 * (exp.offsetBorderH - this.offset);
this.td[4].style.width = w >= 0 ? w +'px' : 0;
this.td[4].style.height = h >= 0 ? h +'px' : 0;
if (this.hasAlphaImageLoader) this.td[3].style.height
= this.td[5].style.height = this.td[4].style.height;
},

destroy : function(hide) {
if (hide) this.table.style.visibility = 'hidden';
else {
hs.purge(this.table);
try { this.table.parentNode.removeChild(this.table); } catch (e) {}
}
}
};

//-----------------------------------------------------------------------------
// The expander object
hs.Expander = function(a, params, custom, contentType) {
this.a = a;
this.custom = custom;
this.contentType = contentType || 'image';
this.isImage = !this.isHtml;

hs.continuePreloading = false;
hs.genContainer();
var key = this.key = hs.expanders.length;

// override inline parameters
for (var i = 0; i < name =" hs.overrides[i];" el =" this.thumb" thumbsusersetid =" el.id" i =" 0;" a ="=" i =" 0;" overlays =" [];" pos =" hs.position(el);" thumbwidth =" el.width" thumbheight =" el.height" thumbleft =" pos.x;" thumbtop =" pos.y;" thumboffsetborderw =" (this.thumb.offsetWidth" thumboffsetborderh =" (this.thumb.offsetHeight" wrapper =" hs.createElement(" onmouseover =" function" onmouseout =" function" contenttype ="=" outlinewhileanimating ="=" outlinewhileanimating =" 0;" exp =" this;" prototype =" {" w =" hs.pendingOutlines[this.outlineType];" objoutline =" w;" zindex =" this.wrapper.style.zIndex;" originalcursor =" this.a.style.cursor;" cursor =" 'wait';" loading =" hs.loading;" exp =" this;" onclick =" function()" top =" (this.thumbTop" exp =" this," left =" (this.thumbLeft" left =" left" exp =" this;" img =" document.createElement('img');" content =" img;" onload =" function" oncontextmenu =" function()" classname =" 'highslide-image';" visibility =" 'hidden';" display =" 'block';" position =" 'absolute';" maxwidth =" 'none';" zindex =" 3;" title =" hs.restoreTitle;" src =" null;" src =" hs.getSrc(this.a);" onloadstarted =" true;" left =" '-9999px';" loading =" null;" cursor =" this.originalCursor" marginbottom =" hs.marginBottom;" newwidth =" this.content.width;" newheight =" this.content.height;" fullexpandwidth =" this.newWidth;" fullexpandheight =" this.newHeight;" width =" this.thumbWidth" height =" this.thumbHeight" position =" 'relative';" left =" this.thumbLeft" top =" this.thumbTop" offsetborderw =" (this.content.offsetWidth" offsetborderh =" (this.content.offsetHeight" modmarginright =" hs.marginRight" ratio =" this.newWidth" minwidth =" this.allowSizeReduction" minheight =" this.allowSizeReduction" justify =" {" page =" hs.getPageSize();" x =" {" oldright =" this.x.min" x =" this.justify(this.x);" y =" {" oldbottom =" this.y.min" y =" this.justify(this.y);" x =" this.x;" y =" this.y;" href =" hs.getSrc(this.a);" dim =" p" hasmovedmin =" false;" allowreduce =" true;" min =" Math.round(p.min" min =" p.scroll" hasmovedmin =" true;" span =" p.minSpan;" allowreduce =" false;"> p.scroll + p.clientSpan - p.marginMax) {
if (hasMovedMin && allowReduce) {

p.span = p.clientSpan - p.marginMin - p.marginMax; // can't expand more

} else if (p.span < min =" p.scroll" min =" p.scroll" span =" p.clientSpan" span =" p.minSpan;" allowreduce =" false;" tmpmin =" p.min;" min =" p.marginMin;" span =" p.span" x =" this.x;" y =" this.y;" changed =" false;"> ratio) { // width greater
var tmpWidth = x.span;
x.span = y.span * ratio;
if (x.span < imgspan =" x.span;" span =" x.minSpan;" span =" x.span" changed =" true;" tmpheight =" y.span;" span =" x.span" changed =" true;" min =" parseInt(this.thumbLeft)" minspan =" x.span;" x =" this.justify(x);" min =" parseInt(this.thumbTop)" minspan =" y.span;" y =" this.justify(y);" imgpos =" {x:" hideselects =" (hs.ie" hideiframes =" ((window.opera" vendor ="=" margin =" '0" n =" this.wrapper.childNodes.length;" i =" n">= 0 ; i--) {
var child = this.wrapper.childNodes[i];
if (child != this.content) {
hs.purge(child);
this.wrapper.removeChild(child);
}
}
}

if (this.fadeInOut) {
from.op = up ? 0 : 1;
to.op = up;
}
var t,
exp = this,
easing = Math[this.easing] || Math.easeInQuad;
if (!up) easing = Math[this.easingClose] || easing;

for (var i = 1; i <= steps; i++) { t = Math.round(i * (dur / steps)); (function(){ var pI = i, size = {}; for (var x in from) size[x] = easing(t, from[x], to[x] - from[x], dur); setTimeout ( function() { if (up && pI == 1) { exp.content.style.visibility = 'visible'; exp.a.className += ' highslide-active-anchor'; } exp.setSize(size); }, t); })(); } if (up) { setTimeout(function() { if (exp.objOutline) exp.objOutline.table.style.visibility = "visible"; }, t); setTimeout(function() { if (exp.caption) exp.writeCaption(); exp.afterExpand(); }, t + 50); } else setTimeout(function() { exp.afterClose(); }, t); }, setSize : function (to) { try { this.wrapper.style.width = (to.w + 2*this.offsetBorderW) +'px'; this.content.style.width = ((to.imgW && !isNaN(to.imgW)) ? to.imgW : to.w) +'px'; if (hs.safari) this.content.style.maxWidth = this.content.style.width; this.content.style.height = to.h +'px'; if (to.op) hs.setStyles(this.wrapper, { opacity: to.op }); if (this.objOutline && this.outlineWhileAnimating) { var o = this.objOutline.offset - to.o; this.objOutline.setPosition(this, to.x + o, to.y + o, to.w - 2 * o, to.h - 2 * o, 1); } hs.setStyles ( this.wrapper, { 'visibility': 'visible', 'left': to.x +'px', 'top': to.y +'px' } ); } catch (e) { window.location.href = hs.getSrc(this.a); } }, afterExpand : function() { this.isExpanded = true; this.focus(); this.createOverlays(); if (hs.showCredits) this.writeCredits(); if (this.isImage && this.fullExpandWidth > this.x.span) this.createFullExpand();
if (!this.caption) this.prepareNextOutline();
},


prepareNextOutline : function() {
var key = this.key;
var outlineType = this.outlineType;
new hs.Outline(outlineType,
function () { try { hs.expanders[key].preloadNext(); } catch (e) {} });
},


preloadNext : function() {
var next = hs.getAdjacentAnchor(this.key, 1);
if (next.onclick.toString().match(/hs\.expand/))
var img = hs.createElement('img', { src: hs.getSrc(next) });
},

cancelLoading : function() {
hs.expanders[this.key] = null;
this.a.style.cursor = this.originalCursor;
if (this.loading) hs.loading.style.left = '-9999px';
},

writeCredits : function () {
var credits = hs.createElement('a',
{
href: hs.creditsHref,
className: 'highslide-credits',
innerHTML: hs.creditsText,
title: hs.creditsTitle
}
);
this.createOverlay({ overlayId: credits, position: 'top left'});
},

getCaption : function() {
if (!this.captionId && this.thumbsUserSetId)
this.captionId = 'caption-for-'+ this.thumbsUserSetId;
if (this.captionId) this.caption = hs.getNode(this.captionId);
if (!this.caption && !this.captionText && this.captionEval) try {
this.captionText = eval(this.captionEval);
} catch (e) {}
if (!this.caption && this.captionText) this.caption = hs.createElement('div',
{ className: 'highslide-caption', innerHTML: this.captionText } );

if (!this.caption) {
var next = this.a.nextSibling;
while (next && !hs.isHsAnchor(next)) {
if (/highslide-caption/.test(next.className || null)) {
this.caption = next.cloneNode(1);
break;
}
next = next.nextSibling;
}
}
if (this.caption) {
this.marginBottom += this.spaceForCaption;
}

},

writeCaption : function() {
try {
hs.setStyles(this.wrapper, { width: this.wrapper.offsetWidth +'px',
height: this.wrapper.offsetHeight +'px' } );
hs.setStyles(this.caption, { visibility: 'hidden', marginTop: hs.safari ? 0 : '-'+ this.y.span +'px'});
this.caption.className += ' highslide-display-block';

var height, exp = this;
if (hs.ie && (hs.ieVersion() < compatmode ="=" height =" this.caption.offsetHeight;" temp =" hs.createElement('div'," innerhtml =" '';" height =" this.caption.childNodes[0].offsetHeight;" innerhtml =" this.caption.childNodes[0].innerHTML;" height =" 'auto';" step =" (Math.round(height/50)" h =" height" t =" 0;" ph =" h," end =" (h" height =" height" visibility =" 'visible';" span =" this.wrapper.offsetHeight" o =" this.objOutline;" height =" (this.wrapper.offsetHeight" height =" o.td[5].style.height" els =" document.getElementsByTagName(tagName);" prop =" tagName" i =" 0;" prop ="=" hiddenby =" els[i].getAttribute('hidden-by');" visibility ="=" hiddenby =" hiddenBy.replace('['+" visibility ="=" elpos =" hs.position(els[i]);" w =" els[i].offsetWidth;" h =" els[i].offsetHeight;" clearsx =" (elPos.x"> imgPos.x + imgPos.w);
var clearsY = (elPos.y + elPos.h <> imgPos.y + imgPos.h);
var wrapperKey = hs.getWrapperKey(els[i]);
if (!clearsX && !clearsY && wrapperKey != this.key) { // element falls behind image
if (!hiddenBy) {
els[i].setAttribute('hidden-by', '['+ this.key +']');
els[i].origProp = els[i].style[prop];
els[i].style[prop] = 'hidden';
} else if (!hiddenBy.match('['+ this.key +']')) {
els[i].setAttribute('hidden-by', hiddenBy + '['+ this.key +']');
}
} else if (hiddenBy == '['+ this.key +']' || hs.focusKey == wrapperKey) { // on move
els[i].setAttribute('hidden-by', '');
els[i].style[prop] = els[i].origProp || '';
} else if (hiddenBy && hiddenBy.match('['+ this.key +']')) {
els[i].setAttribute('hidden-by', hiddenBy.replace('['+ this.key +']', ''));
}

}
}
}
},

focus : function() {
this.wrapper.style.zIndex = hs.zIndexCounter++;
// blur others
for (var i = 0; i < hs.expanders.length; i++) {
if (hs.expanders[i] && i == hs.focusKey) {
var blurExp = hs.expanders[i];
blurExp.content.className += ' highslide-'+ blurExp.contentType +'-blur';

if (blurExp.caption) {
blurExp.caption.className += ' highslide-caption-blur';
}

blurExp.content.style.cursor = hs.ie ? 'hand' : 'pointer';
blurExp.content.title = hs.focusTitle;
}
}

// focus this
if (this.objOutline) this.objOutline.table.style.zIndex
= this.wrapper.style.zIndex;

this.content.className = 'highslide-'+ this.contentType;

if (this.caption) {
this.caption.className = this.caption.className.replace(' highslide-caption-blur', '');
}

this.content.title = hs.restoreTitle;

hs.styleRestoreCursor = window.opera ? 'pointer' : 'url('+ hs.graphicsDir + hs.restoreCursor +'), pointer';
if (hs.ie && hs.ieVersion() < 6) hs.styleRestoreCursor = 'hand';
this.content.style.cursor = hs.styleRestoreCursor;

hs.focusKey = this.key;
hs.addEventListener(document, 'keydown', hs.keyHandler);
},

move : function (e) {
this.x.min = e.left + e.dX;
this.y.min = e.top + e.dY;

if (e.type == 'image') this.content.style.cursor = 'move';
hs.setStyles(this.wrapper, { left: this.x.min +'px', top: this.y.min +'px' });

if (this.objOutline)
this.objOutline.setPosition(this, this.x.min, this.y.min, this.x.span, this.y.span);

},

close : function() {
if (this.isClosing || !this.isExpanded) return;
this.isClosing = true;

hs.removeEventListener(document, 'keydown', hs.keyHandler);

try {

this.content.style.cursor = 'default';

this.changeSize(
0,
{
x: this.x.min,
y: this.y.min,
w: this.x.span,
h: parseInt(this.content.style.height),
imgW: this.x.imgSpan,
o: this.objOutline ? this.objOutline.offset : 0
},
{
x: this.thumbLeft - this.offsetBorderW + this.thumbOffsetBorderW,
y: this.thumbTop - this.offsetBorderH + this.thumbOffsetBorderH,
w: this.thumbWidth,
h: this.thumbHeight,
imgW: this.thumbWidth,
o: hs.outlineStartOffset
},
hs.restoreDuration,
hs.restoreSteps
);

} catch (e) { this.afterClose(); }
},

createOverlay : function (o) {
var el = o.overlayId;
if (typeof el == 'string') el = hs.getNode(el);
if (!el || typeof el == 'string') return;


var overlay = hs.createElement(
'div',
null,
{
'left' : 0,
'top' : 0,
'position' : 'absolute',
'zIndex' : 3,
'visibility' : 'hidden'
},
this.wrapper,
true
);
if (o.opacity) hs.setStyles(el, { opacity: o.opacity });
el.style.styleFloat = 'none';
el.className += ' highslide-display-block';
overlay.appendChild(el);

overlay.hsPos = o.position;
this.positionOverlay(overlay);

if (o.hideOnMouseOut) overlay.setAttribute('hideOnMouseOut', true);
if (!o.opacity) o.opacity = 1;
overlay.setAttribute('opacity', o.opacity);
hs.fade(overlay, 0, o.opacity);

hs.push(this.overlays, overlay);
},

positionOverlay : function(overlay) {
var left = this.offsetBorderW;
var dLeft = this.x.span - overlay.offsetWidth;
var top = this.offsetBorderH;
var dTop = parseInt(this.content.style.height) - overlay.offsetHeight;

var p = overlay.hsPos || 'center center';
if (/^bottom/.test(p)) top += dTop;
if (/^center/.test(p)) top += dTop / 2;
if (/right$/.test(p)) left += dLeft;
if (/center$/.test(p)) left += dLeft / 2;
overlay.style.left = left +'px';
overlay.style.top = top +'px';
},

createOverlays : function() {
for (var i = 0; i < hs.overlays.length; i++) {
var o = hs.overlays[i], tId = o.thumbnailId, sg = o.slideshowGroup;
if ((!tId && !sg) || tId == this.thumbsUserSetId
|| sg === this.slideshowGroup) {
this.createOverlay(o);
}
}
},


createFullExpand : function () {
var a = hs.createElement(
'a',
{
href: 'javascript:hs.expanders['+ this.key +'].doFullExpand();',
title: hs.fullExpandTitle,
className: 'highslide-full-expand'
}
);

this.fullExpandLabel = a;
this.createOverlay({ overlayId: a, position: hs.fullExpandPosition,
hideOnMouseOut: true, opacity: hs.fullExpandOpacity });
},

doFullExpand : function () {
try {
hs.purge(this.fullExpandLabel);
this.fullExpandLabel.parentNode.removeChild(this.fullExpandLabel);
this.focus();

this.x.min = parseInt(this.wrapper.style.left) - (this.fullExpandWidth - this.content.width) / 2;
if (this.x.min < hs.marginLeft) this.x.min = hs.marginLeft;
this.wrapper.style.left = this.x.min +'px';

hs.setStyles(this.content, { width: this.fullExpandWidth +'px',
height: this.fullExpandHeight +'px'});

this.x.span = this.fullExpandWidth;
this.wrapper.style.width = (this.x.span + 2*this.offsetBorderW) +'px';

this.y.span = this.wrapper.offsetHeight - 2 * this.offsetBorderH;

if (this.objOutline)
this.objOutline.setPosition(this, this.x.min, this.y.min, this.x.span, this.y.span);

for (var i = 0; i < this.overlays.length; i++)
this.positionOverlay(this.overlays[i]);

this.redoShowHide();



} catch (e) {
window.location.href = this.content.src;
}
},


// on end move and resize
redoShowHide : function() {
var imgPos = {
x: parseInt(this.wrapper.style.left) - 20,
y: parseInt(this.wrapper.style.top) - 20,
w: this.content.offsetWidth + 40,
h: this.content.offsetHeight + 40
+ this.spaceForCaption
};
if (hs.hideSelects) this.showHideElements('SELECT', 'hidden', imgPos);
if (hs.hideIframes) this.showHideElements('IFRAME', 'hidden', imgPos);
if (hs.geckoMac) this.showHideElements('*', 'hidden', imgPos);

},

wrapperMouseHandler : function (e) {
if (!e) e = window.event;
var over = /mouseover/i.test(e.type);
if (!e.target) e.target = e.srcElement; // ie
if (hs.ie) e.relatedTarget =
over ? e.fromElement : e.toElement; // ie
if (hs.getExpander(e.relatedTarget) == this || hs.dragArgs) return;
for (var i = 0; i < this.overlays.length; i++) {
var o = this.overlays[i];
if (o.getAttribute('hideOnMouseOut')) {
var from = over ? 0 : o.getAttribute('opacity'),
to = over ? o.getAttribute('opacity') : 0;
hs.fade(o, from, to);
}
}
},

afterClose : function () {
this.a.className = this.a.className.replace('highslide-active-anchor', '');

if (hs.hideSelects) this.showHideElements('SELECT', 'visible');
if (hs.hideIframes) this.showHideElements('IFRAME', 'visible');
if (hs.geckoMac) this.showHideElements('*', 'visible');
if (this.objOutline && this.outlineWhileAnimating) this.objOutline.destroy();
hs.purge(this.wrapper);
if (hs.ie && hs.ieVersion() < 5.5) this.wrapper.innerHTML = ''; // crash
else this.wrapper.parentNode.removeChild(this.wrapper);
hs.expanders[this.key] = null;
hs.cleanUp();
}
};
// history
var HsExpander = hs.Expander;

// set handlers
hs.addEventListener(document, 'mousedown', hs.mouseClickHandler);
hs.addEventListener(document, 'mouseup', hs.mouseClickHandler);
hs.addEventListener(window, 'load', hs.preloadImages);

------------------------------------------------------------------------------