Saturday, May 29, 2010

Exercise_PHP MySQL Connection

PHP MySQL Connect to a Database

Before we can access data in a database, we need to create a connection to the database.
In PHP, this is done with the mysql_connect() function.
Syntax
mysql_connect(servername,username,password);
Example:

In the following example we store the connection in a variable ($con) for later use in the script. The "die" part will be executed if the connection fails:

Closing a Connection

The connection will be closed automatically when the script ends. To close the connection before, use the mysql_close() function:




Exercise_Week 10_b

COM and Distributed COM

Component Object Model (COM): The Component Object Model (COM) is a software architecture that allows applications to be built from binary software components. COM is the underlying architecture that forms the foundation for higher-level software services, like those provided by OLE. OLE services span various aspects of commonly needed system functionality, including compound documents, custom controls, inter application scripting, data transfer, and other software interactions.

Distributed COM (DCOM): Microsoft® Distributed COM (DCOM) extends the Component Object Model (COM) to support communication among objects on different computers—on a LAN, a WAN, or even the Internet. With DCOM, an application can be distributed at locations that make the most sense to customer and to the application.
Because DCOM is a seamless evolution of COM, the world's leading component technology, an organization can take advantage of existing investment in COM-based applications, components, tools, and knowledge to move into the world of standards-based distributed computing. As organization do so, DCOM handles low-level details of network protocols so organization can focus on real business: providing great solutions to customers.

Reference:

  • Kindel, C. The Rules of the Component Object Model, Microsoft Development Network Library
  • Microsoft and Digital Equipment Corporation (1996b), Distributed Component Object Model Specification (Draft Version 0.9) Microsoft and Digital Equipment Corporation.

Exercise_Week 10_a

Parallel Processing, Semaphore, Microsoft .Net Framework, Microsoft .Net, E-commerce and Mobile Commerce

Parallel Processing: Parallel Processing is simultaneous use of more than one computer or processor to solve a problem. The processors may communicate in order to be able to cooperate in solving a problem or they may run completely independently, possibly under the control of another processor which distributes work to the others and collects results from them.

Semaphore: A semaphore is an integer counter associated with a thread wait queue. Two atomic operations are available on semaphores: P (or pass) and V (or free). The P operation decrements the counter, and blocks the thread if the counter has reached a negative value. The V operation increments the counter and wakes up a thread, if any, in the semaphore wait queue.

Microsoft .Net Framework: The Microsoft .NET Framework is a software component which can be added to the Microsoft Windows operating system. It provides a large body of pre-coded solutions to common program requirements, and manages the execution of programs written specifically for the framework. The .NET Framework is a key Microsoft offering, and is intended to be used by most new applications created for the Windows platform.

Microsoft .Net: Microsoft .Net is an umbrella term that applies to a collection of products and technologies from Microsoft. All have in common a dependence on the Microsoft .NET Framework, a component of the Windows operating system.

E-commerce: E-commerce (electronic-commerce) refers to business over the Internet. Web sites such as Amazon.com, Buy.com, and eBay are all e-commerce sites. The two major forms of e-commerce are Business-to-Consumer (B2C) and Business-to-Business (B2B). While companies like Amazon.com cater mostly to consumers, other companies provide goods and services exclusively to other businesses. The terms "e-business" and "e-tailing" are often used synonymously with e-commerce.

Mobile Commerce: Mobile Commerce describes business processes which are integrated in a mobile device. Mobile commerce is exactly the same as e-commerce except that the access mechanism is via a wireless phone or terminal rather than the fixed telephone network. The security aspect of transactions is addressed by the encryption inherent in the GSM specification. Internet access is being addressed by initiatives such as the Wireless Application Protocol (WAP) which provides an easy-to-use system for Internet access from mobile terminals.

Reference:

  • Klenke, R.H.; Williams, R.D.; Aylor, J.H., “Parallel-processing techniques for automatic test pattern generation”, IEEE Computer, Volume 25, Issue 1, Jan. 1992 Page(s):71 – 84
  • Rosen, Anita. 2000. The E-commerce Question and Answer Book: A Survival Guide for Business Managers. American Management Association
  • Lamont, Douglas. 2001. Conquering the Wireless World: The Age of m-Commerce. United Kingdom: Capstone Publishing Inc.
  • Young Patrick, Thomas Theys 1999. Capital Market Revolution: The Future of Markets in an Online World. Great Britain: Pearson Education Limited.

Friday, May 28, 2010

Exercise_Week 9

Designing distributed systems

A distributed system is a collection of independent computers that appear to its users as a single coherent system.
Characteristics of distributed system

  • Multiple, independent processing units
  • Processors communicate via a hardware interconnect
  • Processing unit failures are independent
  • Manage resource sharing
  • State is shared among processors

A distributed system is a collection of independent computers that are used jointly to perform a single task or to provide a single service.
Examples of distributed systems
Probably the simplest and most well known example of a distributed system is the collection of Web servers—or more precisely, servers implementing the HTTP protocol—that jointly provide the distributed database of hypertext and multimedia documents that we know as the World-Wide Web. Other examples include the computers of a local network that provide a uniform view of a distributed file system and the collection of computers on the Internet that implement the Domain Name Service (DNS).
Why do we use distributed systems?
The alternative to using a distributed system is to have a huge centralized system, such as a mainframe. For many applications there are a number of economic and technical reasons that make distributed systems much more attractive than their centralized counterparts.
Cost: Better price/performance as long as commodity hardware is used for the component computers.
Performance: By using the combined processing and storage capacity of many nodes, performance levels can be reached that are beyond the range of centralized machines.
Scalability: Resources such as processing and storage capacity can be increased incrementally.
Reliability: By having redundant components the impact of hardware and software faults on users can be reduced.
Inherent distribution: Some applications, such as email and the Web (where users are spread out over the whole world), are naturally distributed. This includes cases where users are geographically dispersed as well as when single resources (e.g., printers, data) need to be shared.

Reference:

  • B. Clifford Neuman. Scale in distributed systems. In T. Casavant and M. Singhal, Readings in Distributed Computing Systems, pages 463–489, IEEE Computer Society Press, Los Alamitos, CA, USA
  • Andrew S. Tanenbaum and Maarten van Steen. Distributed Systems: Principles and Paradigms, Prentice Hall, 2nd edition, 2007

Thursday, May 27, 2010

Exercise_Week 8

Concurrency and transactions

Transaction is an action or series of actions, carried out by user or application, which accesses or changes contents of database.

Concurrent execution of user programs is essential for good database management system (DBMS) performance.

Because disk accesses are frequent, and relatively slow, it is important to keep the CPU humming by working on several user programs concurrently.

A user’s program may carry out many operations on the data retrieved from the database, but the DBMS is only concerned about what data is read/write from/to the database.

A transaction is the DBMS abstract view of a user program: a sequence of reads and writes.

When multiple users access a database simultaneously, their data operations have to be coordinated in order to prevent incorrect results and to preserve the consistency of the shared data. This activity is called concurrency control and should provide each concurrent user with the illusion that he is referencing a dedicated database. The classical transaction concept defines a transaction as the unit of concurrency control, that is, the DBMS has to guarantee isolated execution for an entire transaction. This implies that its results as derived in a multi-programming environment should be the same as if obtained in a serial execution schedule. Other important transaction properties are atomicity, consistency, and durability. In a DBMS, the component responsible for achieving these properties is transaction management which includes concurrency control as a major function.

Concurrency control and recovery are among the most important functions provided by a DBMS.

Users do not need to worry about concurrency.

System automatically inserts lock/unlock requests and schedules actions of different Xacts in such a way as to ensure that the resulting execution is equivalent to executing the Xacts one after the other in an order.

Reference:

  • Beeri, C., Bernstein, E.A., and Goodman, N., A model for concurrency in nested transaction systems, Journal oftheACM, 36(1):230-269.
  • Bernstein, P.A. and Goodman, N. Concurrency control in distributed database systems. ACM Computing Surveys, 13(2):185-221.

  • Bernstein, E.A., Hadzilacos, N., and Goodman, N. Concurrency Control and Recovery in Database Systems, Addison-Wesley: Reading, Pennsylvania.

Wednesday, May 26, 2010

Exercise_Week 7

Internet Security

Security has become one of the primary concerns when an organization connects its private network to the Internet. Regardless of the business, an increasing number of users on private networks are demanding access to Internet services such as the World Wide Web (WWW), Internet mail, Telnet, and File Transfer Protocol (FTP). In addition, corporations want to offer WWW home pages and FTP servers for public access on the Internet. Network administrators have increasing concerns about the security of their networks when they expose their organization’s private data and networking infrastructure to Internet crackers. To provide the required level of protection, an organization needs a security policy to prevent unauthorized users from accessing resources on the private network and to protect against the unauthorized export of private information. Even if an organization is not connected to the Internet, it may still want to establish an internal security policy to manage user access to portions of the network and protect sensitive or secret information.

Internet Firewalls

An Internet firewall is a system or group of systems that enforces a security policy between an organization’s network and the Internet. The firewall determines which inside services may be accessed from the outside, which outsiders are permitted access to the permitted inside services, and which outside services may be accessed by insiders. For a firewall to be effective all traffic to and from the Internet must pass through the firewall, where it can be inspected. The firewall must permit only authorized traffic to pass, and the firewall itself must be immune to penetration. Unfortunately, a firewall system cannot offer any protection once an attacker has gotten through or around the firewall. It is important to note that an Internet firewall is not just a router, a bastion host, or a combination of devices that provides security for a network. The firewall is part of an overall security policy that creates a perimeter defense designed to protect the information resources of the organization. This security policy must include published security guidelines to inform users of their responsibilities; corporate policies defining network access, service access, local and remote user authentication, dial-in and dial-out, disk and data encryption, and virus protection measures; and employee training. All potential points of network attack must be protected with the same level of network security. Setting up an Internet firewall without a comprehensive security policy is like placing a steel door on a tent.

Benefits of an Internet Firewall

Internet firewalls manage access between the Internet and an organization’s private network

Without a firewall, each host system on the private network is exposed to attacks from other hosts on the Internet.

Internet firewalls allow the network administrator to define a centralized “choke point” that keeps unauthorized users such as hackers, crackers, vandals, and spies out of the protected network; prohibits potentially vulnerable services from entering or leaving the protected network; and provides protection from various types of routing attacks. An Internet firewall simplifies security management, since network security is consolidated on the firewall systems rather than being distributed to every host in the entire private network.

Reference:

  • Building Internet Firewalls D. Brent Chapman and Elizabeth Zwicky. O’Reilly & Associates

  • Firewalls and Internet Security: Repelling the Wily Hacker Bill Cheswick and Steve Bellovin. Addison-Wesley


Tuesday, May 25, 2010

Exercise_Week 6

Distributed Objects and CORBA

The term distributed objects, describes objects which reside in separate address spaces and methods of which can be subject of remote method calls (a remote call is issued in an address space separate to the address space where the target object resides). By convention, the code issuing the call is referred to as the client; the target object is referred to as the server object (or simply remote object); the set of methods which implements one of the server object’s interfaces is sometimes designated as a service that this object provides. Similarly, the process in which the server object is located is referred to as a server. (Orfali, Harkey and Edwards, Wiley Computer Publishing Group)
CORBA
CORBA stands for Common Object Request Broker Architecture, is the result of the work done by major actors of the hardware and software industry to set up a communication framework. The goal is to facilitate the development of distributed applications over a heterogeneous network. In a distributed environment, clients are talking to objects. The services that can be delivered to a client by an object are described in an interface. The means of communication are handled by an Object Request Broker (ORB). The idea behind CORBA is to provide an intermediary layer that handles access requests on data. It frees the developer from most of the portability issues. It enables the development of distributed objects. (Jon Siegel, Wiley Computer Publishing Group)
Distributed objects in CORBA
Basic principles
1. Request & response
In CORBA, a client issues a request to execute a method of an object implementation. There is no constraint imposed on the location of the client and the requested object implementation (remote object); they can share an address space, can be located in separate address spaces on the same node, or can be located on separate nodes. A server (process) can contain implementation of several objects or a single object, or even provide an implementation of one particular method only. However, typically, a multithreaded server encapsulates implementations of multiple objects.
2. Remote reference
Remote references are called Object References and the target of an Object Reference must be an object that supports the CORBA::Object IDL interface (such objects are called CORBA objects).
3. IDL Interface
CORBA specifies the CORBA IDL Language and its mapping to several programming languages (e.g., C++, Java, and Smalltalk). The IDL language provides means for interface definitions; there are no constructs related to object implementation (object state definitions have been proposed recently by OMG).
4. Proxy: local representative
Using the Broker Pattern terminology, the client-side proxy code is called IDL stub; the server-side proxy code is referred to as IDL skeleton. However, in CORBA, the concept "proxy" is used to denote an object created on the client side which contains the IDL stub plus provides some other functionality, e.g. support for dynamic invocation.

Reference:

  • Robert Orfali, Dan Harkey, and Jery Edwards. The Essential Distributed Objects Survival Guide. Wiley Computer Publishing Group
  • Stal, M. Worldwide CORBA: Distributed Objects and the Net, Object magazine
  • Szyperski,C.: Component Software, Beyond Object-Oriented Programming. Addison Wesley
  • Jon Siegel. CORBA, Fundamentals and Programming. Wiley Computer Publishing Group.

Sunday, May 23, 2010

Workshop 10

Server Side Form Validation

An important aspect of creating Web Forms pages for user input is to be able to check that the information users enter is valid.

Functionality: Workshop 10 is CSU Registration Form - PHP program that grants an easy-to-use but powerful way to check for errors and, if necessary, display messages to the user.
When the user submits a form to the server, PHP code is invoked to review the user's input.
If an error has occurred in any of the input controls, the page itself is set to an invalid state (validation failed) and user is redirected back to the form page with displayed error messages.
If validation passed, user’s registration details specified on form processing page are invoked. Thus, this program doesn't change HTML forms behavior except it always redirects user to the form page until user enters fully valid data.

Test Code

Saturday, May 22, 2010

Workshop 9

Decimal to Binary and Binary to Decimal Conversion

This program converts decimal value to binary value, and vice-versa.
Functionality: This program asks user to enter valid value in binary or decimal input box.
The validations are as follows:
Binary Input Box:

* The binary input box should not be left blank for the purpose of decimal conversion.
* User can not enter decimal value or any character value in binary input box. User need to enter only binary number that is made of 0s and 1s.
Decimal Input Box:

* The decimal input box should not be left blank for the purpose of binary conversion.
* User can not enter any character value in decimal input box.
This program validates submitted value at Server Side. If user submits invalid value then the program will display error message in Red color. This is possible because of Server Side validation script.

Test Code

Friday, May 21, 2010

Workshop 8

PHP If...Else Statements

Conditional statements are used to perform different actions based on different conditions.
The if statement is used to execute some code only if a specified condition is true.
Syntax:
if (condition) code to be executed if condition is true;
Functionality: This program asks user to input temperature. This program converts temperature from Celsius to Fahrenheit and vice-versa.
Two radio buttons have been provided for selection. They are 1. Convert temperature from Celsius to Fahrenheit and 2. Convert temperature from Fahrenheit to Celsius.

Test Code

Thursday, May 20, 2010

Workshop 7

AJAX Tool Tip and PHP Form Reading

This workshop demonstrates how to use PHP forms. Forms are a special component which allows site visitors to supply information on another web page or server.
AJAX: Asynchronous JavaScript and XML (AJAX) have been used to display tool tip for text box. Whenever user places a cursor in any of the three text boxes, program will display a corresponding tool tip message. Web server might be some where in United States, however using AJAX this program is able to retrieve data from the server asynchronously in the background without refreshing the web page. Data is retrieved using the XMLHttpRequest object. This object has been used to send HTTP or HTTPS requests directly to a web server and load the server response data directly back into the script.
Functionality: This program asks user to input his name, birth year and favorite color. JavaScript validation has been used to validate the input values. Finally, this program calculates user's age and display the text - name and age in user's favorite color.

Test Code

Wednesday, May 19, 2010

Workshop 6

while Loop in PHP

The meaning of a while statement is simple. It tells PHP to execute the nested statement(s) repeatedly, as long as the while expression evaluates to TRUE. The value of the expression is checked each time at the beginning of the loop, so even if this value changes during the execution of the nested statement(s), execution will not stop until the end of the iteration (each time PHP runs the statements in the loop is one iteration). Sometimes, if the while expression evaluates to FALSE from the very beginning, the nested statement(s) won't even be run once. We can group multiple statements within the same while loop by surrounding a group of statements with curly braces.

Syntax:


Functionality: Workshop 6 program asks user to input a number. A JavaScript validation has been used to validate the numerical value. Then program prints Table using PHP while loop.

Test Code

Tuesday, May 18, 2010

Elevator Pitch 2

Elevator Pitch

Here is Elevator Pitch for Assignment 2.
CORBA stands for Common Object Request Broker Architecture. CORBA is an industry standard developed by The Object Management Group to support distributed objects programming. CORBA is just a specification for creating and using distributed objects; CORBA is not a programming language.
The CORBA architecture is based on the object model. This model is derived from the abstract core object model defined by the OMG in the Object Management Architecture Guide
The model is abstract in the sense that it is not directly realized by any particular technology; this allows applications to be built in a standard manner using basic building blocks such as objects. Therefore, a CORBA-based system is a collection of objects that isolates the clients from the servers by a well-defined encapsulating interface. It is important to note that CORBA objects differ from typical programming objects in three ways:
• CORBA objects can run on any platform.
• CORBA objects can be located anywhere on the network.

• CORBA objects can be written in any language that has IDL mapping.