Thursday, November 6, 2008

PLANNING FOR A LIVE SERVER

Here are a few important guideline that are ought to be followed if there is any server going live at ArijaSoft:

QA SIDE PLANS FOR QUALIFYING:

1. QA should be able to discuss and deliver a testing plan for any of the software/ component that is meant for testing purpose even before starting of testing.

2. This testing plan should contain for each functionality:

a. The testing scenarios where it is supposed to be tested.

b. A proper logic as to define why functionality will be qualified as working if tested with the given scenarios of testing.

3. This testing plan needs to be reviewed and modified before it is being approved.

4. Once the testing plan is approved, the tester is supposed to test each of the testing cases and properly present the results.

5. Once the test cases have been tested, the report needs to be submitted to the developer for any bug rectification with a back up kept at tester for revalidating.

DEVELOPPER SIDE PLANNING FOR WRITING/DELIVERING FUNCTIONALITY:

  1. There are three things that needed to be done while writing a functionality:
    1. Validate the data that is received
    2. Doing the actual functionality
    3. Presenting the results properly
  2. In any of the smaller or bigger code the developer writes, these three blocks are to be present to make the code into a production/ qualifying.
  3. Have to enable logs for all the dependent functions/ programs. These need to be accessible to the concerned QA and also anyone who is responsible for keeping the program running
  4. Have to enable a remote start/stop of the servers if found any discrepancy and if no one is available to manually do the shutdown process.

PLANNING FOR THE EXECUTION OF A LIVE SERVER:

1. The server should be prequalified by QA.

2. Developer has to enable a logging functionality for all the servers running live. In our case: PHP log, APACHE log, SCHEDULER log, mySQL log.

3. The log should present the last 100 lines of log from the time of viewing.

4. Since we have a trigger by SMS functionality already implemented earlier on ArijaMobipay server, this type of functionality can be used to start/ stop the servers remotely by using an SMS

5. Remote stopping of the server needs to be enabled by the developer.

6. Look for the dependencies of the server:

a. What are the transactions it does

b. What will be the effects of it

c. Why is the server kept alive

d. What are the resources used by the server

e. What is the correct location to handle/control server? Can it be started and shut down remotely?

7. Always keep a follow up:

a. The server needs to be checked for its health once in a while either by human intervention or by another program.

b. Proper alerts for each exception and proper handlers are to be written.

c. Server needs to be monitored 24x7 for any failure/ mishap.

8. Use of limited resources:

a. Instead of redirecting the server for main transactions, always redirect it a dummy or testing account where the allotted resource (money) will be limited. This shall reduce the threat for continuous transactions.

b. Never allocate the main account which has all the transaction resources to the live server. Even if it goes to the client side also, always keep the resource limited to the server.

9. Monitor the server:

a. The server should never be left unattended. It should either be shut down or should be monitored by someone. This might call for shift system where the server monitoring is to be divided among two/ three people who will monitor the same for certain period of time everyday.

b. There should be a trigger embedded in the server when there is a heavy/ imbalanced flow of information from the server

c. Always intimate the server support (whoever is monitoring the server) about the present status of the server when leaving charge. The status of server will include :

i. Number of requests to be processed

ii. Any downtime that has occurred.

iii. Settings if any changed.

iv. If any transactions are bound to happen.

10.Only when the above things are done, then the server is allowed to go live

PROCESS:

1) Resource (Monitory):

Always use Limited Monitory resources.

2) First week of Live Server:

Server has to be monitored by 24x7.

Team has to have shifts in managing it.

3) Further days of Live Server:

Check Health scripts need to be written.

Every 1hr scrutiny scripts have to be enabled..

4) A New Script - That can catch all possible mistakes.

Like resending etc

5) DISAGREE_COMMIT –

Always disagree on a particular work/statement/plan if it is different from what we anticipate. Then have a common view on the same which shall have to be agreed by both. Once it is committed, both the parties will be aware of the same. This reduces a lot of communication gap and other burdens.


Blogged with the Flock Browser

How to redirect a page to avoid post data reposting

PROBLEM:

There is a Login page which requires a username and password and sends the data to another page. The page action goes to a page authenticate.php which performs the authentication and if authentication is success, it includes a homepage. when the user logs out from the page and presses a back button on the browser, the browser asks for an alert of reposting the POST data. If this is pressed OK, the user can log in again without giving username and password.


SOLUTION:

We use a redirect method:
This has come helpful in redirecting the page to a home page

The page authenticate.php takes the POSTed values from login.php page. It connects to mysql and then gets the authenticated value. These values are set in session.
say $_SESSION['authenticate']='1';
Now the next command will be to redirect using the header.
header("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/homepage.php")

$_SERVER['HTTP_HOST'] will give the location of root directory of Apache server in the local machine.This location is independent of the system that access the server.
dirname is the function  that returns the directory name of the specified file path
$_SERVER['PHP_SELF'] refers to the same file (authenticate.php).
So the header refers to the homepage of the same directory of the authenticate.php page.

There had been an error saying that the headers are already sent and the line was specified. This was due to a blank space left after the end of file of an individual file which was included in the authenticate.php prior to the header function. This leads to sending of blank headers to the browser.

Any queries on the same may be posted to nareshkumar@arijasoft.com

Thank you
Blogged with the Flock Browser

Saturday, October 18, 2008

How the tables for the forms have been set to suit the look and feel of the page

There have been three cases in the present school solution which needed tables in forms to ensure the alignment of the data fields as well as the data names in html page.


CASE 1:

Reference ScheduleAdd.php page:

The table needs four columns and four rows. There is a row with recipient field that needs to be changed everytime the user selects from the select option.

The display of the particular table row tag has to be set to 'none' or 'table row' depending upon the selected item. this can be done by javascript by using an id of that name. the script needs to be written in the body element due to the constraints on the page. This will prevent the javascript to add elements in the table body if the browser is IE. Hence for IE, the table needs to be broken down and another table needs to be added with the same column width definitions. The column width definitions are given to the table using tag.
Description of tag :

defines the attributes for the number of columns present in the table by specifying the span of the colsgroup..( implies the style to be applied.

The width of the cells is usually auto set default by the browser. but the problem stays with the div element when IE is the browser. This element can be aligned by giving the same property to the division as was given to the table (width ).

The text box will have the same attribute as the table cell(width).

The best way to define the widths will be to give them as percentages so that the alignments are not lost when the browser size is changed.

width when specified in percentages will be calculated as the percentage of the total space that is available for the element.

For example:
if a divison has div style="width:100px"

and a table is defined in it as table width="70%" , the table will have the width of 70px.

Same applies for all the fields in the table. Each cell td will be set by default the sizes according to the browser, but this can also be specified by a style element in td specifying the exact width in percentages.

Saturday, August 23, 2008

how to write to a server running on a certain port using php client

Lets say i have a server running on a machine on a certain port number...

ex: serverIP :192.168.1.103
    port :3201

Now i will need a php script to write to that server..
Here is the logic..
create a stream socket client using the function : stream_socket_client() function.
and assign it to a variable... this variable will be like a file pointer..
then just user fwrite() function to write to that stream..
dont forget to close the file pointer..
Thats it problem solved..
Blogged with the Flock Browser

Sunday, July 6, 2008

How to execute a C# program using PHP

There are many situations where u may want to call another program from the system once a particular condition/requirement is done in a web application.
For instance, I have a web interface in php for the user to send messages through a mobile phone. Unfortunately I dont have a script in php that could send a command to the SMS gateway to send the message i wanted.

I have a C# program which can send messages through mobile phone using a third party library. Here is what i did...
First set the program for sending messages as a program that will take arguements from the command line.
Lets say my C# program name is "sendmessage.c" In the main method of the program
main(string args[]) should be there.
Once the program is compiled,I shall go to the location where the ".exe" file of the same program is present.
In the command line i shall type sendmessage recepient_number message; The program gets executed and the message will be sent.

Now i shall take all the files present in the folder where ".exe" file is present and then transfer them to the folder where .php file is present.
Now in the php scrypt i shall write the following statements:
$command= "sendmessage recepient_number message";

exec($command,$return_var);

The exec will execute the c# code from the command line.
The output of the program (the out put u want to be displayed on console) will be returned in the form of a string array to the variable $return_var.
The values of $return_var can be further used for processing the request in php scrypt(Lets say whether the message was sent successfully to the code..
Whether the program was executed..etc);
Blogged with the Flock Browser

Wednesday, June 4, 2008

How to connect ur mobile phone as a GSM modem to ActiveXperts Messaging service

firstly the phone should be connected using USB to the system.
GO to Control Panel and select the phones and modems tab and open it.
Under the modems tab u will find the COM port number under which the modem is connected.
Now open the ActiveXperts service center and go to the channel wizard.
Select the GSM modem from the list and press next.
Select the exact COM port number from the list.
The device will send a test message to the given number.
This will complete the activation of a channel using a GSM Mobile phone as a modem.
Problems with this will be discussed later.
Blogged with the Flock Browser

Thursday, May 29, 2008

How to setup a https server

This post deals with the security adding aspect of a webserver. A https protocol is a secured hyper text transfer protocol which allows all the transactions of a server-client to be done a Secured Socket Layer(SSL). The flow will be :
1. The request from the client or the response from the server is fragmented.
2. The fragmented message will be compressed
3. The compressed message will be encrypted and sent with a summary as a packet.
4. The transfer of the packet is done by usual TCP/IP layer.
An SSL layer stands between the client/Server and the TCP Layer. This allows for the sensitive information to be transferred securely over the internet.

Requirements:
APACHE server with SSL module Enabled.
If U dont have a server with SSL enabled, its better to download a full version of APACHE with SSL module enabled rather than to hunt for the mod_ssl.so file. Every version has its own module file which will not be compatible with the other version's file. Hence i recommend to either download the full server or to download the EXACT module file for the system.

CHANGES TO BE DONE:

In httpd.conf:

1. Look for the LoadModule Statements in this file:

U will find something like:

LoadModule setenvif_module modules/mod_setenvif.so
#LoadModule speling_module modules/mod_speling.so
#LoadModule ssl_module modules/mod_ssl.so
#LoadModule status_module modules/mod_status.so

Forget the rest but remove the "#" mark from the statement : #LoadModule ssl_module modules/mod_ssl.so

This will enable the mod_ssl.so when the server is starting.

2.Inorder to configure the module, there need to be some extensions and commands for the ssl module. These are already included in a config file called httpd-ssl.conf. Locate this file. It will be usually in conf/extra folder.

Locate the include statements in the httpd.conf  file.
# Secure (SSL/TLS) connections
Include conf/extra/httpd-ssl.conf

Ensure that there is no '#' is not present at the start of the second line above. This will include the httpd-ssl.conf.

IN httpd-ssl.conf:

1.Locate the Document root  statement in this folder. And edit the document root to the location where the files for the https connection are stored.
2. The default listening port for https type is 443. U can also change the same to any port which is not used by the server.
3. Server certificates and server keys: the location of the server certificate and the server key are to be specified in this statement.

HOW TO CREATE A SERVER CERTIFICATE AND SERVER KEY:

This can be done usually using an OPENSSL.
Open command prompt and go to ".../Apache/bin"
and type OPENSSL
The command line will show
OPENSSL>
Now type the following command:

req -new -x509 -nodes -out server.crt -keyout server.key

The command prompt will ask certain information like country name, state, city and organisational details. Once filled, the server.crt will be the certificate for testing in ur system. and server.key will be the server key in the system

Locate the .crt and .key files in the system and paste the same location in the httpd-ssl.conf where it shows server certificate location.

This will end the certificate and key integration part of the server. once the server is started..
Type   https://localhost:443/file_name  will give the secured page as output.


Blogged with the Flock Browser

Wednesday, May 7, 2008

Using Mobile phone as GSM modem



This post is dedicated to using the mobile phone as a GSM modem.

SMS Gateway is a server that serves as an interface between ur PC and mobile network. Combined with a GSM modem, one can actually send SMS to any valid mobile phone. The architecture and the design of SMS flow through a PC is shown in the picture.

CASE :
I have used Nokia E61 mobile phone with a GSM SIM card for sending out SMS to valid mobile numbers.
It involves the following requirements for the System:
1. An interface software for the mobile phone to act as a GSM Modem
In this case its Nokia PC tools. Once connected to the system through USB cable, the system recognises it and sets it to Modem configuration provided the system has Nokia PC Suite.There will be a popup window on the phone asking which mode to be selected.
Choose PC suite.

2. An SMS gateway server to interact with the GSM modem.
I have installed ActivXperts SMS gateway free version for testing purposes. Once installed u can actually setup E-mail as well as an SMS gateway through the same server. Go to SMS Messaging Channel Wizard which appears in the Program Files>ActivXperts Software. Choose Create a Channel mode for SMS and Next.
The gateway automatically detects the GSM modems included/connected to the PC. Click on the modem which has the mobile phone name. If the mobile needs a pin to activate that code, then the code is also entered in the same menu.
It will then ask for the GSM number that is present on the phone. Give the number. The next form will ask a sample number to give a test message through the phone. The test message is sent and a confirmation is acknowledged at the PC.
This opens the SMS Server manager. It has log file of all the outgoing and incoming messages through this system, the status of the outgoing messages, failed messages, reasons of failed messages and also all the outgoing messages numbers.
To send an SMS, go to the New message option on the server. This will open up a form to be filled which has channel to be specified as SMS channel which was created earlier with the Mobile phone name.
once the message is created, one can actually schedule it to a particular time to be delivered. the message will be delivered immediately if there is no time specified.

Drawbacks:
Some mobile phones donot give access to the modem once connected to the PC. These will be dedicated to the mobile phone services only.(One such case was with Motorola Razor V8). This makes the device detectable it will not be available for the services of the Gateway server.
Best solution is to install a GSM modem totally dedicated to the Gateway server.
Virtually u are sending SMS through the same phone using the Same GSM SIM card and will be charged on the phone. This problem can be solved by installing GSM modem with a SIM card that has offers for free SMS

Monday, April 28, 2008

How to install Magento from scratch

This page is written for reference to install Magento software in a system starting from the scratch.

System Requirements:
Apache 2.2 or higher server
PHP 5.2.5
MySql server.

Installing and configuring Apache 2.2 software. The installation file for Apache 2.2.8 version is provided at http://httpd.apache.org/download.cgi.

The Apache 2.2.8 server for windows is required for a virtual in-house server to be run on a system. This enables to test and experience the functionalities and features of the solution.
While installing, the setup will prompt for a Domain Name Server. Type localhost to ensure that your system only is acting as a server.
This will install Apache 2.2.8 server into the system.

To start the server, one needs to know of the location in which the server is installed. Go to the location of the server folder.
It is usually “C:\Program Files\Apache Software Foundation\Apache2.2\bin” in the command prompt. Type “httpd.exe” excluding the double quotes.
Now the server will look for a domain or the host which is set at the installation. If not found the server uses the present system itself as a default.

Uploading files onto the server: Locate the folder named htdocs in Apacha2.2 folder.
The folder displays all the documents that need to be there for display on the browser.
“Index.html “ is a test page given for testing the server’s action.

Go to internet browser and type: http://localhost:8080/index.html. The page shows that the server is working.
This completes the installation and configuration of Apache server 2.2

Installing and configuring PHP 5.2.5
Download site for PHP 5.2.5 is http://www.php.net/downloads.php Get the msi installation file for easy setup.
Magento needs support of PHP to execute certain scripts. Basic Apache server supports only html. Hence it needs to be enhanced with PHP to run certain modules and files in Magento.
The installer will ask for the type of server to be looking for to enable the inclusions. Select Apache 2.2 from the list. The setup will usually configure itself to be included in the server. Try to locate the download as “C:\PHP\” which makes life easier as the configuration file has the default location as that only.


Go to php.ini file in the php folder and open with Wordpad

Look for Short_open_tag and set it to On.
Look for magic_quotes_gpc and set it to On.
Look for display_errors and set to On.
Look for extension_dir and type as extension_dir=”c:\php\ext\”
Look for extension= statements in the file and remove the semicolon(;) for the following files:
Php_pdo_mysql.dll
Php_mcrypt.dll
Php_curl.dll
This specific requirement is for magento to run.

This finishes configuring PHP for apache server.

Apache server configuring.
Locate the file httpd.conf in Apache2.2/conf folder. Open it with Wordpad or any text editor.
Look for LoadModule statements and add
LoadModule php5_module “C:/php/php5apache2_2.dll” at the end of these statements.
Look for AddType statements in the file.
Type: AddType application/x-httpd-php .php
Don’t forget the space after the pre-final “php” and the “.” After that.
Ensure PHPIniDir “c:/php”. This will be the location of the folder php.
Look for DirectoryIndex in the file and update it to
DirectoryIndex index.php index.html
Restart the apache server and run the test php file.
All the files to be located in htdocs folder only.

Refer to http://www.thesitewizard.com/php/install-php-5-apache-windows.shtml for configuring both PHP and Apache to be linked.

This will complete the configuration and linking of both apache server and PHP.

MySql Server Installation and configuring:
Download Mysql 5.0.51b fromhttp://dev.mysql.com/downloads/mysql/5.0.html. Download the community server for windows.

Get the zip file for installation from any of the download sites. Unzip the file and installation will ask for the username and configuration setup. A standard setup will suffice the settings. The port number for the sql server is 3306. This will be required for further installation of magento. Remember the password of the sql for further usage.
Once the SQL is installed, go to Programs>Mysql> mysql. This will start a command prompt with my sql collan. The password given will be the password for the root.
Type CREATE DATABASE magento.
This will create the database with name magento.

4.Installing and setting Magento:
Download from http://www.magentocommerce.com/download and the file name is "magento-1.0.19700.zip"
Download the msi setup file for Magenta’s latest version. All the files and setup is to be shifted to htdocs folder of apache. Now run both apache and mysql server.
Type http://localhost:8080/install.php in the address bar. An installation guide will take you to the rest of the steps in Magento. Note that this works only once for the system
The last page of installation will ask the user to move to either frontend or the backend of the software. Please store the last page for any reference or if anything goes wrong. Frontend represents the usual look and feel of a customer on the site. All the items/articles/goods for sale and discount/offers/ carts/shopping lists etc will be visible in the front end.
The backend goes to the administrative part of the system where one can manage with the admin account all the access to change the way the front end looks.It involves adding catalogues, products, product types etc.
This completes the installation of Magento.
How to restart Magento:
Once the server is shutdown, the access to the frontend and the backend of Magento is not known.
Heres how:
Start apache server as well as mysql server.
Open the browser and type http://localhost:8080/magento/index.php
this will take you to the front end of the application
To open in admin's account, type http://localhost:8080/magento/index.php/admin
This will go to the admin's login page and further accessed.
Happy Developping.

Problems:
1. Not able to see index.php file (shows cannot find server)
This usual problem is mainly due to the change of parameters in mage.php which index.php refers to. The only solution being to replace the whole magento setup.
Delete all the files related to magento in the htdocs folder.
Go to sql server and type "drop database magento"
This will delete the database magento which was appended by magento. Again create another database by name magento which has no values.
Install all the files from magento setup to htdocs folder of apache server.
Redo the same steps for installation of magento (From step 4)
This will fix the problem

Friday, April 4, 2008

Pointers and Structures

This post discusses the basics of pointers and Structures.

POINTERS:

A pointer stores the address of a variable. It can also be used to store the address of an array, structure(which is a user defined variable), function and even a pointer.
Declaration:
A pointer for custom type variables is defined as:
int * p(where p is the pointer we are using)
float *p
char *p
A pointer for a structure:
Lets say the structure is named struct student {
int m_iinfo;
char m_pname;}
the pointer will be defined as struct student *p;

A pointer to a function:
A pointer to a function is defined and can be used only for the same TYPE of functions.
Same type functions are those who have the same return types and have same arguements.
Example:
int func(int x, int y) be the function.
pointer to the function will be : int (*p)(int x, int y);
Always remember the braces for the pointer p. If there are no braces, it will be treated as a function p whose return type is an integer pointer and arguements are integers. This type of notation is extensively used for interface with OS and registers to point to a particular function.

Pointers to pointers:
int *p is a pointer to an integer. We can also create q which is a pointer to an integer pointer.
int ** q defines a pointer q to an integer pointer.
it is equivalent to a two dimensional array. This type of declaration is called COMPLEX DECLARATION.

Wednesday, April 2, 2008

ActiveSync Usage

Active Sync is a programme that acts as an interface between a mobile and a PC. Any file that needs to be downloaded to and from the mobile phone can be done using activesync.
Inorder to make this happen, both system and the mobile should have activesync installed.

Mobile Phone to PC:
Connect the mobile to PC using USB or any other ports whichever is applicable. Enable activesync on the system and the same on the mobile phone also. The phone automatically Synchronizes with the system once the active Sync is switched. The explore button in ActiveSync allows the user to explore through the files existing on the mobile phone. Similarly any file that needs to be copied on to the mobile phone can be done in the same way.

Emulator to PC:
Connecting the emulator to PC using Active sync is a tricky job. We have to cheat the system that there actually exists a mobile phone with activesync control and is trying to connect into the system. Lets go to the "First" source file that has been created already in the earlier session.
Build and start the emulator. Donot exit from the emulator. In the main VS screen,
Tools> Device Emulator Manager
If all the drop down menus are opened, there will be one simulator which actually is ready to get connected into the system. Right click on that and click on cradle. Active sync gives a setup for connecting onto the device.
Choose "standard partnership" and click next.
Choose "Synchronize with desktop" and click next.
Once the setup is completed, ActiveSync looks for the changes in the emulator since it was last used and updates them. Once it is completed, Click on Explore of Activesync. This gives access on to the files of the mobile phone.
This completes the process of Activesync for an Emulator.

Things to be remembered:
1. Emulator should be executed by VS before starting the Active Sync.
2. Please ensure the files transfer on the emulator/ mobile once the transfer has taken place.
3. Always close the emulator before debugging or writing other code in VS.
4. Both system and the device should have activesync installed.



starting and editing a smart phone application

This session will enable to start a smart phone application on Visual basic platform.
shortcut for getting visual basic environment:
Windows> Run> devenv
This is applicable only for the systems that are at the company and might differ for depending upon the VS package available in the systems.
Once the start page is displayed, go to:
File> New>Project. (short cut for the same Ctrl+Shift+N)
A subwindow appears on the screen which has "Project types" on the left and "Templates" on the right.
Project types:
click on the visual c++ button. This drags down ATL, CLR, General,MFC, Smart Devices.
Click on Smart Devices.
Choose the Win32 smart device project template on the right side.
Enter the location at which the project needs to be stored in the 2nd bottom line of the menu.
Give a name to the project prior to its editing and press OK. Lets put the name "First"
A creation Wizard will guide you for the rest of the process.
Choose the application in which the programme is to be executed. The present ones in the system are Smarphone and Pocket Pc both belonging to 2003 version.
Then the wizard asks for the application type. Be it a library,DLL,Windows application.
For our example we will take Windows application. Click Finish once it is selected.

The environment will be loaded with the source that has been created by us.

In order to run this dummy programme in an emulator, first the programme needs to be built.
Right click on " First" displayed at the left top side of the solution explorer. Click on Build.
Once there are no errors and the system shows success on the bottom running line, click on
Debug> start without debugging>
The emulator which exactly resembles the smart device appears on the screen. Since we have not entered or altered anything in the application, a blank screen appears on the phone with two options OK and HELP.
Clicking on OK will take the menu out of the blank screen. Click on the File shown on the emulator window.
Golden Rule: ALWAYS EXIT THE EMULATOR WITHOUT SAVING ANY CHANGES.
Any changes saved onto the emulator will remain on it the next time it is used which means any bugs on the code will be entered into the emulator.
The emulator needs to be closed inorder to again re run the code on it.
The files for the project will be given as source files, header files, resource files. Exploring into these files lets u change/ delete/edit anything that comes on the blank screen.

Exercise: try to change the About me that comes on the Help screen of emulator into your name or anything that suits u.

what and why of an Emulator




This post deals with the creation, building and deployment of a smart phone application on to an emulator.


An emulator is a virtual system almost equivalent to a smart mobile phone. Any program that needs to be deployed onto a mobile phone can be simulated with an emulator. Now about the mobile phone applications:


All the electronic devices have basic hardware which includes Processor, RAM, BIOS, data ports, Operating systems. A computer also has an application development environment where in programs regarding the OS can be done to suit our applications. A mobile phone on the contrary doesnt have an application development environment due to the constraints of memory and also the response. Hence applications pertaining to mobile phones have to be written and tested somewhere else and then deployed for usage on mobile.
The same is at the start of this post.
Emulator is a simulation program that resembles a mobile phone so that applications written for a Mobile phone can be tested over this. This reduces the risk of any damage caused due to malfunctioning of programme on the original phone. Once the program works on the Emulator, the same can be deployed on to the phone for usage.