Sunday, March 29, 2009

Exercise 6: Some server practice with PHP

1. Try the code by replaceing with $REMOTE_ADDR, $SERVER_NAME or $PHP_SELF

Replace with $REMOTE_ADDR

Code:
\

Result:


Replace with $SERVER_NAME

Code:


Result:



Replace with $PHP_SELF

Code:


Result:


2. Create application "hello_world.php" which contains in the body:

Code:


Result:

Exercise 7: User input for database access with PHP

1. Create an HTML page with the form:


2. create PHP file named submit.php with code:


Result input form:


Result after submit:

Exercise 8: PHP and MySQL database access

Setup and Create database and table in MySQL

a. Change the root password


b. Login MySQL database system


c. Create database named "mydatabase"


d. Access the created database with command "USE"


e. Create table named "employees"


f. Assign privileges to a user to access the database


Questions in exercise 8
1. Start with a simple table in the database:



2. Create a web page with the following PHP:
Code:


Result:


3. Create a file called add_record.html
Code:


Result:


4. Create a PHP file caleed add_record.php for POST method in web page.
Code:


Result:


5. Show multiple records as webpage.
Code:


Result:


I've found that the result is not as expected, I make changes to the code as follow:
that the field start from the left and the index is start from zero.

Fixed Code:


Result:

Tuesday, March 24, 2009

Exercise 5: Network and programming frameworks

1. Investigate a simple chat client/server system. Look at some program code and describe how it works with multiple users.

Source code of Chat Client Server by Boby, T. P., (2006)

Server Side Main program:

**********************************************************************************
int main(int argc, char* argv[])
{
int nRetCode = 0;
char buf[4096];

cout << "This is written by Boby Thomas.\r\n";
cout << "This aplication act as a chat server.\n";
cout << "Messages from any pc will be broadcasted to all connected pcs.\n";
cout << "Connect to the server pc port 8084(Digital BOBY).\n";
cout << "Press ONLY ENTER to quit.\n";
cout << "=================================================\n";

if(!CServerObj.IsConnected())
{
cout<<"\nFailed to initialise server socket";
cout<<"\nThis is boby signing off : Bye";
getch();
return 1;
}
AfxBeginThread(ServerListenThread,0);

while(gets(buf))
{
if(strlen(buf) == 0)
break;
if(CServerObj.SendMessagePort(buf))
{
cout<<"Problem in connecting to server. Check whether server is running\n";
break;
}
}

cout<<"This is Boby signing off.";
getch();

return nRetCode;
}
**********************************************************************************


Client Side Main program:

**********************************************************************************
int main(int argc, char* argv[])
{
char buf[4096];
cout<<"This is a client TCP/IP application\nConnecting to port 8084\n";
cout<<"\nPress ONLY ENTER to quit";
cout<<"\nWritten by Boby Thomas";
cout<<"\n===============================================\n";

FILE *fp = fopen("server.ini","r");
if(fp == NULL)
{
cout<<"\nUnable to open server.ini. Please specify server IPsddress in server.ini";
return 1; // main failed
}
string sServerAddress;
while((fgets(buf,4096,fp)) != NULL)
{
if(buf[0] == '#')
continue;
sServerAddress = buf;

}
fclose(fp);

if(sServerAddress.size() == 0)
{
cout<<"\nUnable to find server IPaddress in server.ini";
cout<<"\nPlease set server IPaddress";
cout<<"\nThis is Boby Signing off. BYE:";
getch();
return 0;
}

MyMessObj.Init(sServerAddress.c_str(),8084);
if(!MyMessObj.IsConnected())
{
cout<<"\nUnable to connect to the IPaddress specified in server.ini";
cout<<"\nPlease check server IPaddress";
cout<<"\nThis is Boby Signing off. BYE:";
getch();
return 0;
}

AfxBeginThread(MessageRecThread,0);
while(gets(buf))
{
if(strlen(buf) == 0)
break;
if(MyMessObj.SendMessagePort(buf))
{
cout<<"Problem in connecting to server. Check whether server is running\n";
break;
}
}

cout<<"\nThis is Boby Signing off. BYE:";
getch();
return 0;
}
**********************************************************************************


The chat program uses thread to serve multiple users. The server starts and listen to the network for client. The client side locates the server and starts chat. While each client connected to the server, a new thread creates in the server side for that client. As multiple threads created in the server side, multiple users can be served.

2. Describe the important and distinguishing properties of Peer to Peer computing and the Grid. How is this peer to peer and the Grid architecture changing work flow and service-oriented applications?

There are two common use of Grid computing. Both uses several computer to solve a problem. One of the usage is that the problem is complex and require a lot of computer cycle to complete such as a scientific problem.

The other usage is to handle a large amount of data. When a single server cannot handle all the requests, by using the grid computing, the servers are linked up to form a cluster, the transaction are distributed to the server members and is handled in parallel manner. (Wikipedia)

This is important for service-oriented applications. In e-commerce, all the transactions are handled in server. The server's power for handling the transaction become important. Instead of the security concern, the user or customer requires fast and efficient service via e-commerce. The slow transaction time leads the wait of customers or users, there will be a bad impact to the company goodwill and customer satisfaction.

Peer to Peer computing (P2P) links the computers in a ad hoc manner to increase the total bandwidth for sharing common interests such as audio, video and data files.

There are two roles for each computer that is linked up in Peer to Peer computing - server and client. It is a full duplex (two ways) communications to all computers that linked up. When a computer a linked to the P2P network, for example, download a Linux distribution, the computer downloads portions of the file from all the computers that it connected to, at the same time, the downloaded portions is uploaded to someone else who is connected and requiring that portion of file. (Wikipedia)

This is useful when a company cannot provide enough bandwidth for distribute their files. For example: RedHat and Novell SUSE, their files are in DVD format, if it provides only FTP service for download the file, there are not enough bandwidth to serve all the customers and users. By using the P2P techniques, the file can be distribute faster than the FTP to the customers and users.


3. Frameworks for development. Compare and contrast any TWO of:
a. Java
b. .NET
c. Ruby on Rails
d. Google Gears
f. AJAX frameworks

I would like to discuss on the frameworks for Java and Ruby on Rails.

The Ruby on Rails (RoR) providing Model-View-Controller approach as its development framework. It is the unique framework for the development platform. JAVA can adopt itself to different kind of the development frameworks. Some of the frameworks for Java are MVC framework.

While some of the development framework supporting Pull and Push architecture, the RoR only support Push technology. There is a weak point to the Java, most of the framework for Java is not able migrate with the database, but RoR does.

Most of the framework for Java supports AJAX while RoR does not support or still in prototype.


Table 1. Comparison of web application frameworks on Java and Ruby on Rails (Wikipedia)


Table 2. Comparison of web application frameworks components on Java and Ruby on Rails (Wikipedia)

Reference:
Boby, T. P., (2006), Chat Client Server, Retrieved 24 March 2009, from http://www.codeproject.com/KB/cpp/chat_client_server.aspx

GridCafe, (n.d.), How does grid computing work?, Retrieved 25 March 2009, from http://www.gridcafe.org/version1/gridatwork/architecture.html

Joseph, J., Ernest, M., Fellenstein, C. (2004) ,Evolution of grid computing architecture and grid adoption models, Retrieved 25 March 2009, from http://www.research.ibm.com/journal/sj/434/joseph.html

Wikipedia (n.d.), Peer-to-peer, Retrieved 25 March 2009, from http://en.wikipedia.org/wiki/Peer-to-peer

Wikipedia (n.d.), Grid computing, Retrieved 25 March 2009, from http://en.wikipedia.org/wiki/Grid_computing_infrastructure

Wikipedia (n.d.), Comparison of web application frameworks, Retrieved 30 March 2009, from http://en.wikipedia.org/wiki/Comparison_of_web_application_frameworks

Exercise 4: Virtual private networks

Describe the IP Protocol. What is DNS?

IP stands for Internet Protocol. It is a protocol on network layer and responsible for packet delivery from host to host. It is a connectionless and unreliable protocol for data transmission (Hollinger, 2001). It represents the host and network addressing. It is an unique identifier for the computer to the network for data and information transmission. When a computer connects to the internet, a unique IP is required.

There are two version of the IP Protocol, version 4 (IPv4) and version 6 (IPv6). The IPv4 uses 32-bits to address itself and according to the Brendan (2009), it supports more than four billion unique addresses. As the internet population growth during the years and each computer required to have a unique IP address for direct internet connection, the number of the IP address reduces. The IPv6 provides two to the one-hundred twenty-eighth power of unique addresses which is enough for the future growth of the internet population. (Brendan, 2009)

DNS stands for Domain Name System. It is a service on the top of the Internet Protocol. The DNS is used to resolve the name entered at browser to IP and vesa visa. DNS is used because user requires meaningful name to browse the internet instead of browsing a website by entering non-meaningful IP address. (Brendan, Webopedia 2009)

Describe the TCP protocol. How is it related to the IP protocol?

TCP stands for Transmission Control Protocol. It is a protocol on transport layer. The TCP is connection-oriented and reliable protocol to make the completeness of data transfer.

A three way handshake and virtual connection is made before transmission. With it packet structure, the lost of packets by lost or error in connection can be detectd by its sequence number and request number. The corruption of the packet also detected with the checksum of the segment in TCP packet (Hollinger, 2001).


Figure 1: TCP segment structure (Hollinger, 2001)

What do you know about building e-business application as an Intranet, Extranet, Web portal, B2B, B2C or Virtual Private Network (VPN)? Find some examples on the web.

Intranet is a network can be accessed by authorized personnel within an organization only such as employees. With the use networking technologies such as TCP/IP, the user shares the current informaiton such as calendars, sending internal emails and even access the employee contact information. (Randolph)


Figure 2. Intranet (Randolph)

Extranet is intranet network that mapped to the internet or specificed private network. (Wikipedia)

FedEx
http://customcritical.fedex.com/us/owneroperator/signin.shtml

Web portal is a managed online system providing different kind of service via single point of access. It usually manage the information into customable channels for users to subscribe.

HKU SPACE
http://soul.hkuspace.org/

CSU
http://my.csu.edu.au/

According to the wikipedia, B2B is Business-to-Business that involve transactions between manufacturer and a wholesaler or between a wholesaler and a retailer. B2C is defined as Business to Customer that usually involve single transaction between them.

Vitual Private Network uses the public network for transferring information with encryption for security purposes.

What role can VPN play in business-to-business e-commerce?

Vitual Private Network play the role for security in business-to-business in e-commerce. Since it uses encryption such as IPsec, hashing techniques, DES and AES for validation and data transfer, the security of the information is enchanced.

Furthermore, there is a tunnel mode in VPN that allows to form a connection like a leased line in the internet between them, the capturing of the data stream from someone else is minimized. (Wikipedia)


Reference:
Webopedia (2009), IP address, Retrieve 25 March 2009 from http://www.webopedia.com/TERM/I/IP_address.html

Brendan M.G. (2009), What is IP or Internet Protocol?, Retrieved 25 March 2009, from http://www.wisegeek.com/what-is-ip-or-internet-protocol.htm

Hollinger D. (2001), Internet Protocol: The IP in TCP/IP
Retrieved 29 March 2009 from http://www.cs.rpi.edu/~hollingd/javanetprog/notes/tcpip/tcpip.ppt

Wikipedia (n.d.), Virtual private network, Retrieved 30 March 2009 from http://en.wikipedia.org/wiki/VPN

Randolph B. (2004), Intranet v/s E-commerce sites, Retrieved 30 March 2009 from www.ischool.utexas.edu/~i385grb/Intranet_vs_E-commerce.ppt

Wikipedia (n.d.), Extranet, Retrieved 30 March 2009 from http://en.wikipedia.org/wiki/Extranet

SearchEnterpriseWAN.com (4 March 2009), extranet, Retrieved 1 April 2009 from http://searchenterprisewan.techtarget.com/sDefinition/0,,sid200_gci212089,00.html

Indiana University (2 March 2009), What is a web portal?, Retrieved 1 April 2009 from http://kb.iu.edu/data/ajbd.html

webopedia.com (7 June 2006), intranet, Retrieved 1 April 2009 from http://www.webopedia.com/TERM/I/intranet.html

Dennis P. G. (n.d.), Finding Your Way Around E-commerce, Retrieved 1 April 2009 from http://www.intranetjournal.com/features/Ecommercetut.html

Sunday, March 22, 2009

Exercise 3: Finding some common ground

Steps involved with the Rapid Evolutionary Prototypng model


Figure 1: Steps involved in Evolutionary Prototyping model. Retrieved 21 March 2009 from http://www.wittmannclan.de/ptr/cs/slcycles.html

In developing web application, the requirements of each module within the web application may be different and may be unclear. The evolutionary prototyping model, divide the application into modules for development. Within the model, the prototype is coded. When there are changes with the requirements, codes are modified or added.

Each module produces its prototype with its development cycle to meet the requirements for next phrase. Those including analysis of the requirements, design, implementation and test phrases.

As a result, each module contains a prototype for their requirements. Each prototype is refined during the cycle. The project is completed with joining the prototype into a single web application. (Clan, 2009)

Clan (2009) suggested the approach should be used on small projects rather than large projects. It is because the maintenance work is difficult for large projects.




How is it related to agile development?



Figure 2: Agile Model Driven Development Life cycle Retrieved 24 March 2009 from http://www.agilemodeling.com/essays/amdd.htm

Both Rapid Evolutionary Prototyping and Agile Development sharing the same characteristics.


  • Identify the basic requirements at initial phrase
  • Frequently change of the requirements or requirements is unclear.
  • Requiring customer involvement including face-to-face communication as technical team for the successful of the product.
  • Activities are broken down into individual module for development.
  • Features can be add or change during the development.
  • Each module development has its own development cycle.
  • Modules combined into a single application

The different between them:

  • The Agile development focus on the modeling the system but not coding on system.
  • Evolutionary Prototyping model focus on coding for user requirements not modeling the system.



Reference:
Clan, W. (2009), Software Life-cycles, Retrieved 22 March 2009 from http://www.wittmannclan.de/ptr/cs/slcycles.html

Wikipedia (2009), Agile web development, Retrieve 22 March 2009 from http://en.wikipedia.org/wiki/Agile_web_development

Scott W. A.,(2007), Agile Modeling: Effective Practices for Extreme Programming and the Unified Process, John Wiley & Sons

Friday, March 20, 2009

Exercise 2: Technology and the evolution of business options

Online Shopping

YESASIA
http://www.yesasia.com/global/en/home.html

HMV
http://hmv.com/

BizRate
http://www.bizrate.co.uk/

OO Online Bargain Megastore
http://www.oo.com.au/

dstore
http://dstore.com.au/


Electronic Payment

PayPal
https://www.paypal.com/

Asia Pay
http://www.asiapay.com.hk/

Pay Dollar
http://www.paydollar.com/

Worldpay
http://www.worldpay.com/

NetPayments
http://www.netpayments.co.uk/

Database access

ZOHO Creator
http://creator.zoho.com/

dabble db
http://dabbledb.com/

Hong Kong Public Library Catalog
http://libcat.hkpl.gov.hk/

The University of Hong Kong Libraries
http://lib.hku.hk/

WAP sites for mobile phone

Mobile Yahoo!
mobile.yahoo.com

Hong Kong Observatory WAP site
wap.hko.gov.hk

XE
http://wap.xe.com

MSN WAP site
http://mobile.msn.com

Google WAP site
http://wap.google.com

Reference:
Scottish Enterprise. Business Link.(2007), Trade Online Project, Retrieved 18 March 2009 from http://www.electronic-payments.co.uk