Docstoc

apt

Document Sample
apt Powered By Docstoc
					                University of Malta




             Assigned Practical Task


A Real Time Application Integration Solution


            Lecturer: Mr. T. Spiteri Staines
           Observer: Profs. A. Leone Ganado




Pulis Matthew
B.Sc. Business and Computing
May 2005
                                               0
Table of Contents
INTRODUCTION.............................................................................................................. 4

   THE CURRENT SYSTEM .............................................................................................................4

THE USE OF ERP ............................................................................................................. 5

   WHAT IS AN EIS? ...................................................................................................................5
   WHAT IS AN ERP? ..................................................................................................................5
   WHY AN ERP? .......................................................................................................................5
   THE PROBLEMS ASSOCIATED WITH AN ERP ...................................................................................6

UNDERSTANDING THE REQUIREMENTS OF THE BUSINESS .......................................... 8

   THE BUSINESS DOMAIN............................................................................................................8
   ERP INTEGRATION PLANNING ....................................................................................................9
       Analysing the Departments ..............................................................................................9
       Preparing the Approach ................................................................................................. 10
       Implementing the Design .............................................................................................. 12

UML MODELLING THE SYSTEM ..................................................................................... 13

   WHAT IS UML? ................................................................................................................... 13
   WHAT TOOLS DOES UML OFFER? .............................................................................................. 13
   AVAILABLE MODELS FOR THE SYSTEM ........................................................................................ 14
   THE CLASS DIAGRAM ............................................................................................................. 15
       Definition and Purpose of Class Diagram ........................................................................ 15
       Use of Class Diagram in this system ............................................................................... 15
       Class Diagram ............................................................................................................... 16
   THE USE-CASE DIAGRAM ........................................................................................................ 17
       Definition and Purpose of Use-Case Diagrams ................................................................. 17
       Use of Use Case Diagram in this system ......................................................................... 17
       Use-Case Diagrams ....................................................................................................... 18
       Definition and Purpose of Sequence Diagram .................................................................. 23
       Use of Sequence Diagram in this system ........................................................................ 24
       Sequence Diagram ........................................................................................................ 25
   STATE CHART DIAGRAMS ........................................................................................................ 30
       Definition and Purpose of State Diagram ........................................................................ 30
       State Diagram............................................................................................................... 31

                                                                                                                                     1
   ACTIVITY DIAGRAM ............................................................................................................... 38
       Definition and Purpose of Activity Diagram ..................................................................... 38
       Activity Diagram............................................................................................................ 39
   COMPONENT AND DEPLOYMENT DIAGRAMS.................................................................................. 51
       Definition and Purpose of Component and Deployment Diagram ...................................... 51
       Use of both Component and Deployment Diagrams in this system ................................... 51
       Component and Deployment Diagram ............................................................................ 52
   REASON FOR NOT USING OTHER DIAGRAMS ................................................................................. 53
       Object Diagram ............................................................................................................. 53
       Collaboration Diagram ................................................................................................... 53

MODELLING USING OTHER DIAGRAMS ....................................................................... 54

   THE ENTITY RELATIONSHIP DIAGRAM ........................................................................................ 54
       Definition and Purpose of E-R Diagram ........................................................................... 54
       Use of Entity-Relationship Diagrams in this system .......................................................... 54
       Entity-Relationship Diagram ........................................................................................... 55

REAL TIME ANALYSIS ................................................................................................... 58

   DEFINITION OF REAL TIME ANALYSIS......................................................................................... 58
   IMPLEMENTING REAL TIME SITUATIONS IN THIS SYSTEM ................................................................. 58

ARCHITECTURE, TECHNOLOGIES AND TOOLS ............................................................. 59

   THE INTERNAL NETWORK ....................................................................................................... 59
   THE NETWORKING TOPOLOGY.................................................................................................. 60
       The Main Network ......................................................................................................... 61
       The Protected Network .................................................................................................. 62
       The Backup System ....................................................................................................... 63
       The Routing .................................................................................................................. 64
   TECHNOLOGIES USED ............................................................................................................ 65
       MySQL DBMS ................................................................................................................ 65
       PHP Scripting Technology .............................................................................................. 65
   TOOLS USED ....................................................................................................................... 66

PROTOTYPE .................................................................................................................. 67

   USER REGISTRATION AND MANAGEMENT MODULE ......................................................................... 67




                                                                                                                                      2
   STILL SCREENS .................................................................................................................... 70
   DATABASE DESIGN ................................................................................................................ 76
      Reason for including the design as well .......................................................................... 76
      The Backup Script written in .CGI .................................................................................. 76
      SQL Script for Database ................................................................................................ 77

CONCLUSION ..............................................................................................................100

   PROJECT OVERVIEW ............................................................................................................ 100
   FUTURE ENHANCEMENTS ...................................................................................................... 100
   NEXT PHASE ...................................................................................................................... 100

REFERENCES ...............................................................................................................101

DIGITAL MEDIA ..........................................................................................................102




                                                                                                                                      3
Introduction

The Current System

The aim of this system analysis and design is to computerize a helicopter company
system. In the current system, there is some kind of computerization but the
departments are working in shadow from each other. The website department, which
has been created so as to cover this project, will be responsible for the day to day
running of the website. Thus the other departments have to ask the website team so as
to have access to the database. Where the system was working quite well, it was
decided that the system will be kept as is, and the new ERP just interface with the other
system.


In other words, the design of this system is to unite all the systems together, allowing
for online booking and also allowing the company managers of each department to have
access for reports, which reports can compare data from different departments where
before such thing could not have happened unless in a Managers Meeting.




                                                                                       4
The Use of ERP

What is an EIS?

The applications that comprise an enterprise's existing system for handling company-
wide information. Examples of EISs include: an ERP system, a mainframe transaction
processing system, and a legacy database system. 1 More or less any kind of computing
system that is of "enterprise class". This means typically offering high quality of service,
dealing with large volumes of data - capable of supporting some large organization ("an
enterprise").


An Enterprise Information System would typically be operated by professional system
administrators and be deployed on dedicated servers. It would typically offer network
connectivity and provide services that supported the operations carried out by the
enterprise. 2

What is an ERP?

ERP (Enterprise Resource Planning) is an industry term for the broad set of activities
supported by multi-module application software that help a manufacturer or other
business manage the important parts of its business, including product planning, parts
purchasing, maintaining inventories, interacting with suppliers, providing customer
service, and tracking orders. ERP can also include application modules for the finance
and human resources aspects of a business. Typically, an ERP system uses or is
integrated with a relational database system. 3

Why an ERP?

ERP's best hope for demonstrating value is as a sort of battering ram for improving the
way the company takes a customer order and processes it into an invoice and revenue—
otherwise known as the order fulfillment process. That is why ERP is often referred to as




1
    IBM IIS Glossary : http://publib.boulder.ibm.com/infocenter/adiehelp/topic/com.ibm.wsinted.glossary.doc/topics/glossary.html
2
    Wikepedia Enterprise Information System : http://en.wikipedia.org/wiki/Enterprise_Information_System
3   Masters ITM Club (Glossary of Common IT Terms) : http://www.sauder.ubc.ca/cgs/itm/itm_glossary.html#E

                                                                                                                                   5
back-office software. On the other hand, the system which will be designed in this
assignment handles front selling (booking of flights).


People in these different departments all see the same information and can update it.
When one department finishes with the order it is automatically routed via the ERP
system to the next department. ERP can be helpful also to the other major business
processes, such as employee benefits or financial reporting.


With ERP, the office employees will be taking decisions based on the data the ERP is
presenting them. Is it still worth while for the firm to keep allowing credit terms to this
tour-operator? How is the other operator going with sales? Are the sales department
working well?, thus are seats being sold more often? The Operations department is it
catering for new flights in peak seasons? These are decisions that office employees,
hereinafter will be referred as the Web Team, have never had to make before, and the
answers affect the customer and every other department in the company. But it's not
just the Web Team representatives who have to change their duty. People in the
Operations Department who used to keep records of the Flights in their own software
now need to put that information online. If they don't, the customer-part-website, who
will be representing the sales department will tell the customers that flights do not exists
or also that flights are fully-booked. Accountability, responsibility and communication
have never been tested like this before. 4

The Problems associated with an ERP

People don't like to change, and ERP asks them to change how they do their jobs. That
is why the value of ERP is so hard to pin down. The software is less important than the
changes companies make in the ways they do business. If the ERP is used to improve
the ways the firm takes bookings, organizes flights, and process bookings, the firm will
ripe value from the software. If the firm just installs the software without changing the
ways people do their jobs, the management will not see any value at all—indeed, the
new software could slow the firm down by simply replacing the old software that
everyone knew with new software that no one does.

4
    Adapted from Enterprise Resource Planning Research Centre : http://www.cio.com/research/erp/edit/erpbasics.html#erp_improve

                                                                                                                                  6
It's critical for the company to figure out if their ways of doing business will fit within the
ERP package. In this analysis the software was planned to fit the process so as to
facilitate the burden of change. Basically the departments will continue doing their
routines, just that data has to be inputted onto another software. Until the software has
been finished from the implementation stage, when every module is finished, the
particular departments can start using it. However this can introduce dangerous bugs
into the system, thus it is suggested that every data is entered twice, both in the old
proprietary software and onto the new system so as to check system performance.
Upgrading the software and/or adding new modules in the proposed system will not be
that hard since the system can be changed quite easily. One must remember that the
system design will be around the main Database server and interface will almost be
using PHP technology. This will enhance the software in the fact that by combining
HTML and PHP one can create web pages which can interact with the system quite
easily. A problem which will be troublesome is the backing up of the database server
since all the ERP data will be warehoused on this server


Needless to say, the move to ERP is a project of breathtaking scope. In addition to
budgeting for software costs, financial executives should plan to cover consulting,
process rework, integration testing and a long laundry list of other expenses before the
benefits of ERP start to manifest themselves. Underestimating the price of teaching
users their new job processes can lead to a rude shock down the line, and so can failure
to consider data warehouse integration requirements and the cost of extra software to
duplicate the old report formats. A few oversights in the budgeting and planning stage
can send ERP costs spiralling out of control faster than oversights in planning almost any
other information system undertaking.




                                                                                             7
Understanding the Requirements of the Business

The Business Domain

HeliMalta is the leading national helicopter and international helicopter airline and has
been operating for these 8 years. Since it’s beginning the company has decided to
account for online bookings of flights thus launching the website around 7 years ago.
From its start, this site has been hugely successful and its usage jumped 291 per cent
between 1999 and 2005. Having seen this high increase in usage, the management
decided that it is best in Business terms to re-implement the system focusing everything
on the database and all departments sit on a round table passing data to the centre.
Another reason which brought forward the idea of re-implement the system is due that
although data is being recorded from the website, it still needs re-entering of data from
the office staff on the proprietary software, thus increasing time and allowing for
mistakes.


The huge increase in demand for the HeliMalta Web site prompted the airline to develop
their fourth generation portal. The new design needed to
Provide flexibility to meet new business needs
Boost revenues
Reduce costs
Support advanced customer relationship management (CRM) initiatives


The aim of this study is to research the industry trends, analyse the business processes
and to design and execute plans based on HeliMalta’s business strategy.


Tasked also with the integration of the multiple systems for this advanced portal, it will
be needed a robust and extensible middleware solution. This solution had to be:
   Powerful
   Reliable – HeliMalta opted for 98% availability threshold
   Connect to the present software which cannot be changed.
   Scalable - HeliMalta anticipated major increases in business through the new portal

                                                                                          8
ERP Integration Planning

The system will be regarded as the main system to which the firm will adapt too. As
explained earlier, effort has been done to project the system around the particular roles
of each department but in some cases, so as to keep system stability and data validated
in the database, it has been noted that some departments need to alter their day-to-day
running procedures.



Analysing the Departments

The current firm has the following departments each with a separate system. Following
will be a list of the current departments which to-date strive for business excellence in
obscurity of other departments.
Sales Department: This department takes care of sales of tickets. Into this domain
falls the Tour Operators Department which takes care of the Tour Operators. It is up to
the Sales department to chase creditors if bookings have not been made or else that the
flights are not being filled up. This department needs to be the front end of the
company when a client phones for customer support. It is also this department’s role to
drop bookings if a customer asks for and it’s also up to this department to reschedule a
booking.
Marketing Department: This department is responsible for the image of the firm to
its surroundings. It is this department responsibility to build trust of the clients to flight
with this company. Such department needs to keep an eye on the whole system from
Top Down view so as to check that all the employees of HeliMalta are making their
utmost effort of depicting the firm as a very serious one. This department is responsible
to media coverage and also to answer any comments, especially attacking ones from the
media. Another task of this department is publicity and advertising. A main task included
in this department portfolio is the Web Site. Care has to be taken that the web site is
easily navigateable, whilst keeping user interface and accessibility at a high rank.
Another task of this Department is to use the website as a showcase of the flights which
the company does, and assign special schemes to different age groups.


                                                                                            9
Human Resources Department: This department is responsible for the employees of
the firm. The wage increases and other adjustment will be only issued at the
discreteness of this department. Wages have also to be accepted from this Manager’s
department. Another task of this department is to keep an updated database list of the
employees working with the firm. Apart from the financial side of this department,
another task is the user morale task. This department is in charge of keeping its
employees with a smile on their job, take care of those employees of have accidents on
work, take care to provide healthy environment and last but not lease offer immediate
support in any circumstance where the employee has some troubles in his duties.
Operations Department: This department is in charge of taking care of organising
flights and must work hand in hand with the sales department. Flight scheduling, thus
booking helipads, scheduling helicopters to flights and making sure that all helicopters
are serviced before departure. Another duty of this department is to work hand in hand
with the Human Resources Department and organise the crew for the flights. According
to information gathered from this department, the crew scheduled is of the form of 3
pilots and 2 Helpers, who in laymen’s words are the normal Steward – Hostess
combination. From this group the reserve pilot and helper will get a normal wage but
will not be covered of extra bonuses.
Finance Department:        The Finance department, like in every firm is the department
which takes care that expenses don’t run beyond income. This department is also in
charge of keeping the cash flow in the business and that the firm is always able to meet
liabilities.

Preparing the Approach

An outline has been prepared so as to know to which running software the new system
has to connect to. Such reports need to be highly free from any bugs since the other
systems will be depending on this ERP.



Helipad Booking Software (HeliBOOK)
This system is the current system used by HeliMalta so as to book a slot for the HeliPad
at the International Airports. Since there are different helipads and each heliport uses its
own system for booking, it is quite useless for the firm to tender the system to be re-
                                                                                         10
implemented. Thus the new ERP needs to be connected to this booking scheme. After a
Helipad booking is confirmed from the HeliBOOK system, thus receiving the confirmation
from the HeliPort of both arrival and departure locations, can the new flight be entered.
Thus this implementation has to be done only by the Web Staff. During training period,
such explanation need to be delivered to the staff so as to learn and understand the
high importance of first waiting the confirmation from both Heliports before creating the
flight on the ERP System.



Accounting Software (SunSystems)
This financial and business world-leading software has proved to create a sophisticated
analytical model of the existing enterprise. The firm has described this process as “With
SunSystems you will have the visibility and insight you need to make key business
decisions and best position your organisation in relation to your dynamic business
environment.”

Human Resource Management (HRB)

In today's highly competitive and volatile business environment many aspect of
the company's activities need to be reviewed. Such factors as the increase in
labor efficiency, cost efficiency and the speed of making management decisions
come to the forefront. This system is a new system which has been just installed.
More efficient maintenance of company personnel information in a logically
structured and in a readily accessible manner to easily analyse and plan HR
expenses and to discover new opportunities for increasing cost efficiency.
Analyzing the system one can deduce that by direct entry of the on-flight crew, a
lot of the burden of the HRM system will be removed. Thus, the headache to find
the schedules and flights of all the crew can be ignored now since data can now
be collected from the roots, thus from the ERP system and passed in bulk to the
HRM so as to calculate wages. Depending on what job each person worked as
the HRM needs to calculate only the wage and issue the pay slip. By this system,
multiple classification of business processes in the field of Human Resource
Management. Elimination of multiple entries, optimization of daily operations of
                                                                              11
employees working at different departments and minimization of routine
transactions that allow the releasing of personnel engaged in those routine
activities and using the resources more efficiently to maximize cost reduction.

Implementing the Design

In this section one can analyse how the data will be passed from the main hub of data
to the other running software which the system is enjoying at the moment.

Accounting Software (SunSystems)
The financial orientated reports which will be prepared from the website can be
downloaded on the disc in a .txt format so as that the office staff just needs to update
the Accounting software using the xml update from the Database. The text file will have
a string of data in the format of row1.colum1, row1.column2, row2.column1 and so on.
Such process can be automated in the future but till yet the firm has said that it is better
for the employees to do it themselves so as to have a feel of what is going on.

Human Resource Management (HRB)
The report from this system which will cover this department will be prepared in a .xml
format. Since this software is built on .NET technology, xml will be read without any
problems. What will be needed from the office staff is to request a report every month
before the process of compiling the wages starts. With the xml file, the report will be in
a column form like the printout which the user can verify on screen.


Both reports will be using SQL constructs so as to reflect the data stored in the
database, and there will be no need for the user to compare them to the details on the
screen, since data will be echoed for both reports from the database. Although in the
prototype it will not be implemented, the design will include a Printer-Friendly format of
the report viewed on the screen, and another link which asks for a backup file, which
will be the file which the other systems will use.




                                                                                         12
UML modelling the System

What is UML?

Unified Modelling Language is the industry-standard language for the specification,
visualization, construction, and documentation of the components of software systems.
UML helps to simplify the process of software design, making a model for construction
with a number of different views. 5 To organize program code more efficiently
programmers often create "objects" that are sets of structured data within programs.
UML, which has been standardized by the Object Management Group (OMG), was
designed for this purpose. The language has gained enough support that it has become
a standard language for visualizing and constructing software programs. 6



What tools does UML offer?

The OMG's Unified Modeling Language™ (UML®) helps you specify, visualize, and
document models of software systems, including their structure and design, in a way
that meets all of these requirements. (You can use UML for business modeling and
modeling of other non-software systems too.) Using any one of the large number of
UML-based tools on the market, you can analyze your future application's requirements
and design a solution that meets them, representing the results using UML's twelve
standard diagram types.


You can model just about any type of application, running on any type and combination
of hardware, operating system, programming language, and network, in UML. Its
flexibility lets you model distributed applications that use just about any middleware.
Built upon the MOF™ meta-model which defines class and operation as fundamental
concepts, it's a natural fit for object-oriented languages and environments such as C++,
Java, and the recent C#, but you can use it to model non-OO applications as well in, for
example, Fortran, VB, or COBOL. UML Profiles (that is, subsets of UML tailored for


5
    Network Design and Management : http://authors.phptr.com/morris/glossary.html
6
    What is UML? http://www.netchico.com/support/glossary/u.html

                                                                                     13
specific purposes) help you model Transactional, Real-time, and Fault-Tolerant systems
in a natural way. In this system design, UML is going to be used as well and the
implementation will be done using PHP. Although PHP does support Classes, it is not
very widely used as such, and the market is waiting for PHP 5 so as to start making full
                             7
use of OO coding.

Available Models for the System

The heart of object-oriented problem solving is the construction of a model. The model
abstracts the essential details of the underlying problem from its usually complicated
real world. Several modelling tools are wrapped under the heading of the UML. 8


At the centre of the UML are its nine kinds of modelling diagrams, which we describe
here.
      Class diagrams
      Object diagrams
      Use case diagrams
      Sequence diagrams
      Collaboration diagrams
      State chart diagrams
      Activity diagrams
      Component diagrams
      Deployment diagrams




7
    Adapted from Introduction to UML: http://www.omg.org/gettingstarted/what_is_uml.htm
8
    Adapted from Practical UML™: A Hands-On Introduction for Developers http://bdn.borland.com/article/0,1410,31863,00.html

                                                                                                                              14
The Class Diagram

Definition and Purpose of Class Diagram

A Class diagram gives an overview of a system by showing its classes and the
relationships among them. Class diagrams are static -- they display what interacts but
not what happens when they do interact. 9 It identifies classes, relationships, and
                                                                                               10
responsibilities for the entities abstracted in the problem solution.


UML class diagrams are the mainstay of object-oriented analysis and design. UML 2 class
diagrams show the classes of the system, their interrelationships (including inheritance,
aggregation, and association), and the operations and attributes of the classes. Class
diagrams are used for a wide variety of purposes, including both conceptual/domain
                                                             11
modelling and detailed design modelling.




Use of Class Diagram in this system

In our system, one notes that the database tables are treated as classes. Since PHP’s
support for Classes is still very immature, the system is regarded as one whole class.
The classes depicted in the class diagram following is treating the tables in the database
as data repository thus treating the data how it is being interacted from one table to
another. Such diagram has been designed upon the guidance of UML certified tutorial of
Borland.com9 and taking close look at the article “Can I use class diagrams to model the
logical database design? “ 12.




9
     Borland Definition of Class Diagram : http://bdn.borland.com/article/0,1410,31863,00.html
10
     Glossary of OO/MDA terms : http://pathfinderpeople.blogs.com/hslahman/2004/06/glossary_of_oom.html
11
     Conceptual Modelling : http://www.agilemodeling.com/artifacts/classDiagram.htm
12
     JGuru.com : http://www.jguru.com/faq/view.jsp?EID=439975

                                                                                                          15
Class Diagram




                16
The Use-Case Diagram

Definition and Purpose of Use-Case Diagrams

Use case diagrams describe what a system does from the standpoint of an external observer. The
emphasis is on what a system does rather than how. Use case diagrams are closely connected to
scenarios. A scenario is an example of what happens when someone interacts with the system.13
The Use Case model is about describing what our system will do at a high-level and with a user
focus for the purpose of scoping the project and giving the application some structure. The Use
Cases are the unit of estimation and also the smallest unit of delivery. Each increment that is
planned and delivered is described in terms of the Use Cases that will be delivered in that
increment.


Use Cases are not a functional decomposition model. Use Cases are not intended to capture all of
the system requirements. Use Cases do not capture HOW the system will do anything - nor do
they capture anything the actor does that does not involve the system. All of these things are
better modelled using other modelling techniques that were developed for those purposes. The
Object Model to capture the static structure of the system and the composition of the classes. 14




Use of Use Case Diagram in this system


In this system one can note that the use-cases are split into various departments according to
how data is going to be used by whom. Such use-cases will help to give a clearer view about the
system from a top-down view where each department is split from the rest of the project and a
study is performed upon.




13
     Borland Definition of Use-Case Diagram : http://bdn.borland.com/article/0,1410,31863,00.html
14 Adapted from Why do we develop the Use Case model? : http://www.zoo.co.uk/~z0001039/PracGuides/pg_use_cases.htm




                                                                                                                     17
Use-Case Diagrams

Marketing Department

This use-case examines the Marketing Department. This department is going to focus on the
users who will make use of the system. Thus this department will be taking care of the user
registering / logging system.




                                                                                        18
Sales Department
This department’s duty will be that of taking care of the sales of the tickets. Besides the actual
sale on the site, thus the need to provide an error-free and secure environment for payment,
need to provide also a mechanism to counter for bookings dropping and also edits of bookings.
Printing of tickets is also another responsibility of this department.




                                                                                               19
Human-Resources Department
This department is going to take care of all the operations related to the crew. Thus addition /
deletion of crew members are going to happen here. Crew scheduling is also the responsibility of
this department.




                                                                                             20
The Operations Department
This department will take care of all the operations related to the helicopters. Thus the main
responsibilities will be flight scheduling, maintenance scheduling and also helipad bookings. This
department is in charge of making sure that every helicopter is in the best state to make the
flight, make sure that the flights are to the enjoyment of the customers and that everything runs
smoothly.




                                                                                               21
Business Relationship Department

This department will be taking care of the tour operators. The duty of this department is to
keep records of all the tour operators and make sure that no operator creates employees
more than allowed so as to keep system stability.




                                                                                         22
Sequence Diagram

Definition and Purpose of Sequence Diagram

A sequence diagram is an interaction diagram that details how operations are carried out -- what
messages are sent and when. Sequence diagrams are organized according to time. The time
progresses as you go down the page. The objects involved in the operation are listed from left to
right according to when they take part in the message sequence. 15


UML sequence diagrams model the flow of logic within your system in a visual manner, enabling
you both to document and validate your logic, and are commonly used for both analysis and
design purposes. Sequence diagrams are the most popular UML artefact for dynamic modelling,
which focuses on identifying the behaviour within your system.


Sequence diagrams are typically used to model:
Usage scenarios. A usage scenario is a description of a potential way your system is used. The
logic of a usage scenario may be part of a use case, perhaps an alternate course. It may also be
one entire pass through a use case, such as the logic described by the basic course of action or a
portion of the basic course of action, plus one or more alternate scenarios. The logic of a usage
scenario may also be a pass through the logic contained in several use cases.
The logic of methods.                  Sequence diagrams can be used to explore the logic of a complex
operation, function, or procedure. One way to think of sequence diagrams, particularly highly
detailed diagrams, is as visual object code.


The logic of services. A service is effectively a high-level method, often one that can be invoked
by a wide variety of clients.                    This includes web-services as well as business transactions
implemented by a variety of technologies. 16




15
     Borland Definition of Sequence Diagram : http://bdn.borland.com/article/0,1410,31863,00.html
16
     Adapted from UML 2 Sequence Diagrams : http://www.agilemodeling.com/artifacts/sequenceDiagram.htm

                                                                                                         23
Use of Sequence Diagram in this system

A lot of the implementation of this system will be using the form subscription method of
$PHP_SELF. Thus in notions when there is a sequence diagram of interaction between the user
and the system, it is regarded that the system is the PHP page where although it is just physically
one page (one .php) it can have many iterations due to re-loading the self page to itself. In
development stages one must remember the incursion of the HTTP_SESSION_VARS the
delegation of methods can be made easier. Another change that will be done during
implementation is where in depicted sequence charts there are other intermediaries between the
user and the system. Such intermediaries will be implemented in a separate .php file so as to
increase readability and debugging steps. These will be implemented using the include() function
of PHP, where a file can be included and the PHP parser will view the code as part of the caller.
One could regard the system as can be regarded by the parser, as one whole code, but I decided
to choose this method of design so as when it comes to implementation it will be easier to code
and debug small parts of the more complex systems.




                                                                                                24
Sequence Diagram

Create Booking




                   25
Create Flight




                26
Checking Unpaid Booking




                          27
Database Backup




                  28
Scheduled Backup




                   29
State Chart Diagrams

Definition and Purpose of State Diagram

Objects have behaviours and state. The state of an object depends on its current activity or
condition. A state chart diagram shows the possible states of the object and the transitions that
cause a change in state. 17


Some objects do and know more things, or at least more complicated things, than other objects.
Some objects are incredibly complicated, so complex that developers can have difficulty
understanding them.


UML state diagrams depict the various states that an object may be in and the transitions
between those states. A state represents a stage in the behaviour pattern of an object, and like
UML activity diagrams it is possible to have initial states and final states. An initial state, also
called a creation state, is the one that an object is in when it is first created, whereas a final state
is one in which no transitions lead out of. A transition is a progression from one state to another
and will be triggered by an event that is either internal or external to the object. 18




17
     Borland definition of State Chart : http://bdn.borland.com/article/0,1410,31863,00.html
18
     Adapted from UML 2 State Machine Diagrams : http://www.agilemodeling.com/artifacts/stateMachineDiagram.htm

                                                                                                                  30
State Diagram

User Login




                31
Creating Booking




                   32
Edit Booking




               33
User Registration




                    34
Register new Tour Operator




                             35
Create Helicopter Maintenance




                                36
Register New Flight




                      37
Activity Diagram

Definition and Purpose of Activity Diagram

An activity diagram is essentially a fancy flowchart. Activity diagrams and state chart diagrams
are related. While a state chart diagram focuses attention on an object undergoing a process (or
on a process as an object), an activity diagram focuses on the flow of activities involved in a
single process. The activity diagram shows the how those activities depend on one another. 19


Thus, UML activity diagrams are typically used for business process modelling, for modelling the
logic captured by a single use case or usage scenario, or for modelling the detailed logic of a
business rule. Although UML activity diagrams could potentially model the internal logic of a
complex operation it would be far better to simply rewrite the operation so that it is simple
enough that you don’t require an activity diagram. In many ways UML activity diagrams are the
object-oriented equivalent of flow charts and data flow diagrams (DFDs) from structured
development. 20




19
     Borland.com definition of Activity diagram : http://bdn.borland.com/article/0,1410,31863,00.html
20
     Adapted from UML 2 Activity Diagrams : http://www.agilemodeling.com/artifacts/activityDiagram.htm

                                                                                                         38
Activity Diagram

Create Booking




                   39
Insert Booking




                 40
Register User




                41
Register Tour Operator




                         42
Tour Operator Register New Employee




                                      43
Create Helicopter Maintenance




                                44
Assign Scheme




                45
Insert Flight




                46
47
Assign Crew to flight




                        48
Request a Report




                   49
50
Com ponent and Deploym ent Diagram s

Definition and Purpose of Component and Deployment Diagram

A component is a code module. Component diagrams are physical analogies of class diagram.
Deployment diagrams show the physical configurations of software and hardware. 21


Component-based development (CBD) and object-oriented development go hand-in-hand, and it
is generally recognized that object technology is the preferred foundation from which to build
components. Component diagrams are typically used as an architecture-level artefact, either to
model the business software architecture, the technical software architecture, or more often than
not both of these architectural aspects.                           Physical architecture issues, in particular hardware
issues, are better addressed via UML deployment diagrams or network diagrams.


The initial architectural modelling efforts during the first cycle should focus on identifying the
initial architectural landscape for your system. UML component diagrams are great for doing this
as they enable you to model the high-level software components, and more importantly the
interfaces to those components.



Use of both Component and Deployment Diagrams in this system

It was decided to combine these 2 diagrams in 1 so one can understand which component run on
which node. Thus the system developer can understand more easily where to have the files and
from where to call them. Another Important use of such combine is that one can better plan his
hardware for the jobs requested by the components which will reside on the system. Going with
this reason is the system awareness of components. Thus if a bug is found the System Engineers
can easily track down to the component and fix the bug in the least time possible. Using such
method another advantage can be attained. By referring to this diagram one can easily
understand the Component-Interface communication details, thus can implement better how the
components of the system interacts with each other. 22


21
              Borland.com            definition         of         Component             and            Deployment   Diagrams    :
http://bdn.borland.com/article/0,1410,31863,00.html#component-and-deployment-diagrans
22
     Combining the two Diagrams(Slide 9) : http://taurus.polito.it/~lioy/01adw/5-uml-physical-asd.pdf

                                                                                                                                51
Component and Deployment Diagram




                                   52
R eason for not using Other Diagram s

Object Diagram

Since an object diagram shows how specific instances of a class are linked to each other at
runtime, at any moment in time it consists of the same elements as a class diagram; in other
words, it contains classes and links showing the relationships. However, there is one minor
difference. The class diagram shows a class with attributes and methods declared. However, in an
object diagram, these attributes and method parameters are allocated values. 23 Thus, since in the
Class diagrams, as explained earlier, in Use of Class Diagram in this system, the classes are
nothing more than data repository, there is nothing much to add and useful for an Object
diagram to be designed.




Collaboration Diagram

The Collaboration Diagram in this system was not used for the simple reason that all components,
thus .php pages in the system will be treated by the php parser as one component. Thus even if
they will be different physical files, when using the include() method, the parser virtually inserts
the code of one file to the calling file. Thus the whole scope of Collaboration diagram, which is
conveying the same information as sequence diagrams, but the focus is on object roles instead of
the times that messages are sent. 24 Therefore having all roles of objects treated as self-iterative
is no use in creating a good and understandable Collaboration diagram.




23
     Elements of an Object Diagram : http://www.developer.com/design/article.php/2223551
24
     Borland.com definition of Collaboration Diagram : http://bdn.borland.com/article/0,1410,31863,00.html#collaboration-diagrams

                                                                                                                                    53
Modelling using other diagrams

The Entity Relationship Diagram

Definition and Purpose of E-R Diagram

An entity-relationship (ER) diagram is a specialized graphic that illustrates the interrelationships
between entities in a database. 25 Thus it can be said that the E-R data model views the real world
as a set of basic objects (entities) and relationships among these objects. It is intended primarily
for the DB design process by allowing the specification of an enterprise scheme. This represents
the overall logical structure of the DB. 26 An E-R diagram at best can only be considered a static
picture of the "structure" of a database. Nothing is revealed regarding the flow of data, or
anything else that relates to how the data changes. However, exploring an entity relationship
                                                                                                  27
diagram is often a first step in understanding a databases design.



Use of Entity-Relationship Diagrams in this system

Entity Relationship Diagrams are a major data modelling tool and will help organize the data in
this project into entities and define the relationships between the entities. This process has
proved to enable the analyst to produce a good database structure so that the data can be stored
and retrieved in a most efficient manner. Since I am treating the classes as data repository, in
other words as tables, it is in the best of practices that an E-R Diagram is included. Using this
diagram one can understand better the database which will be considered as the driving feature
of this ERP.




25
     “Entity-Relationship Diagram” : http://databases.about.com/cs/specificproducts/g/er.htm
26
     The Entity-Relationship Model : http://www.cs.sfu.ca/CC/354/zaiane/material/notes/Chapter2/node1.html
27
     Understanding Entity Relationship Diagrams : http://folkworm.ceri.memphis.edu/ew/SCHEMA_DOC/comparison/erd.htm

                                                                                                                      54
Entity-Relationship Diagram




                              55
56
57
Real Time Analysis

Definition of Real Time Analysis

The web definition of Real Time Analysis can be said to be: A transmission or data processing
mode in which the data is entered in an interactive session where an application can respond fast
enough to affect later data input. 28 Thus it can be defined as the capture, processing, and
presentation of data at the time the data is originated. Real time can also refer to events
simulated by a computer at the same speed that they would occur in real life.

Implementing Real Time Situations in this system

The system is planned to be built so as to respond to input immediately. When the user requests
data, a select query is promptly fired at the Database asking for information. Speeds are a must
in such a system. It is well known that a user tends to leave the site if the page doesn’t load fast.
Another well known fact is that users are less ready to wait for data to load and this would mean
data querying needs to be as fast as possible. Hence, the system will be designed using PHP and
MySql. MySQL database provides excellent speed and flexibility for web applications. It is also the
database of choice when using PHP - with a huge amount of built-in flexibility. 29




28
     About Speed and Protocols : http://www.quadron.com/speed/speed.html
29
     Why another language like PHP? : http://www.jatech.ca/php_mysql.shtml

                                                                                                  58
Architecture, Technologies and Tools

The Internal Network

In the following diagram one can note that the network is split up into 2 main sub-networks. The
Main Network will be the network which can be accessed from outside. Thus this network will
host the Web-Server and also the Mail Server. Therefore the Database Server will not have
foreign access, just local. This way the DBMS will also be protected from flooding or other DDoS
attacks.




                                                                                             59
The Networking Topology




                          60
The Main Network

This split and division in the network is a security measure to protect the database. Since we will
store very sensitive data especially data on our customers and data which can’t be accessed by
the franchise companies we must take a lot of care for the database. Since the Web Server will
be visible to the Internet it will be very vulnerable to suffer attacks. Although the firewall
implemented is a high end firewall we still cannot rest our mind at peace that we will have a
secure system. To minimise risks I suggest that we implement the Web Server in a demilitarized
zone (DMZ in short). Another risk magnet is the SMTP server, the server we need to use to send
emails and its brother the POP3 server, the server which we use to receive emails. The three
server needs to be protected, thus they will be in a sub network which sits between a trusted
internal network, i.e. the private LAN and the external network, i.e. the Internet. To secure the
network, we are not going to stop only by installing and configuring the firewall. The servers
themselves have bugs which can be exploited as can be seen in this paper - Flat vs. Segmented
DMZ's. “It's a common myth in the business world that placing a firewall in your DMZ is the be all
and end all for security. I often see wide open holes that would not prevent attacks. The
importance of segmentation is to be able isolate your network to the point where it could be far
more easily to identify an attack.” 30 Implementing a second server with tied security will involve
more costs, but this is just for security. This forum thread is headed Co-locating application and
database servers and is found at TheServerSide.com, where server administrators discuss their
experiences. With application servers we understand our HTTPd, SMTP and POP3. By Co-locating
we understand having a lot of servers sharing the same CPU. We are going to implement the
WebServer in a flat DMZ since as one can read from here: “however, it may not be possible to
affect other systems outside of that flat DMZ boundary, given one could host several applications
in different DMZ's but within each application the servers are not segmented.” 31 The advantage
here is that the compromiser can’t access the database with ease since he has to access outside
this sub-network and there is a high possibility that the firewall will stop him. This is the system
we propose for the Application Servers:




30
     Flat vs Segmented DMZ's http://honor.trusecure.com/pipermail/firewall-wizards/2002-November/013508.html
31
     Flat vs Segmented DMZ's http://honor.trusecure.com/pipermail/firewall-wizards/2002-November/013508.html

                                                                                                               61
Main Office Server (WEB Application Server) - SC733T-450 32
CPU: 2.8GHz Xeon 512KB L2 Integrated
RAM: 2*1024 333 MHz SDRam (ECC)
Network: eth0 (connected to Router), eth1 (connected to Router – idle)
Storage: 2 * 16 GB Raptor SATA Discs (mirrored, Hot Swappable)
PSU: 450W
OS: SuSE Linux 9.0
HTTPd: Apache 2.0 Web Server, PHP 5.01, Java Tomcat, Perl 5.86
Additional Software: PhpMyAdmin

Main Office Server (Mail Application Server) - SC733T-450 33
CPU: 2.8GHz Xeon 512KB L2 Integrated
RAM: 2*1024 333 MHz SDRam (ECC)
Network: eth0 (connected to Router), eth1 (connected to Router – idle)
Storage: 2 * 16 GB Raptor SATA Discs (mirrored, Hot Swappable)
PSU: 450W
OS: SuSE Linux 9.0
Emaild: sendmail, XInet.d : pop3, Cron Daemon

The Protected Network


It has been seen how the SuperMicro motherboard performed during online benchmarks and we
deem that it can serve its duties for the upcoming years. I tend to agree with this review at Tom’s
Hardware.net a must read when it comes to Hardware. “With its unbeaten feature set,
Supermicro's X6DA8-G2 is definitely meant for professional usage and therefore eclipses all other
boards that we tested. It's a unique combination of eight controllable fans, LSI RAID Zero option,
Dual Gigabit LAN, IPMI option, SM bus PSU monitoring and the theoretical possibility of extending
the memory up to 16 GB. While this board is the most expensive out of the bunch, it truly
                                                                                              34
deserves our recommendation thanks to its flawless performance. “                                  Although the motherboard

32
     SuperMicro SC733T-450 http://www.supermicro.com/products/system/tower/7033/SYS-7033A-T.cfm
33
     SuperMicro SC733T-450 http://www.supermicro.com/products/system/tower/7033/SYS-7033A-T.cfm
34
     Quote Extracted from: http://www.tomshardware.com/motherboard/20041111/index.html

                                                                                                                        62
we plan to install is the SC743T-R760 it is not very different to the one reviewed over there. All of
the features are found in our model, and one must add that our models can hospitate a newer
revision of the Xeon64 CPU Nonocona version. Following its performance I suggest we install this
motherboard and install high banks of memory due to the process it will face. Caching is very
important in DBMS management so we need to let our system work as efficiently as possible. In
my opinion this is the best setup for the main server:



Database Server (Active) - SC743T-R760 35
CPU: 2* 3.0GHz Xeon (Nocona) 1MB L2 Integrated
RAM: 4*1024 333 MHz SDRam (ECC)
Network: eth0 (connected to Router), eth1 (connected to Router – redundant connection)
Storage: 2 * 74 GB Raptor SATA Discs (mirrored, Hot Swappable)
PSU: 760W
OS: Red Hat Linux ES
DBMS: MySQL 4.51



The Backup System

One can identify the addition of the Redundant Server. Having such a system can’t go without
having proper backups. We need a serious Redundancy/Fail-over system. We suggest having
another powerful server which acts as a backup for both the systems. All the three servers will
have their own backups for the hard discs since we will be mirroring the discs while operation so
if one disc fails we have immediately a backup disk available. The Raptor Discs with their extra
speed (calculated in RPM), enhance the throughput. Now the backup server will serve exactly as
if the firm has another server running exactly at the same time of the proper servers. We can
regard this server as our last hope to keep the customers and the office employees working
without disturbing their every-day business. We will deploy a mechanism that when a system
fails, be it the Main Server, be it the Database Server or the Web Server, this new server will
enter into operation. It must be said that this system can’t remain in operation for long periods of
time since we will be exposing our servers to attacks and even exploits of data, so this will be just


35
     SuperMicro SC743T-R760 http://www.supermicro.com/products/system/4U/7044/SYS-7044H-TR.cfm?PID=TWR

                                                                                                         63
a temporarily measure until we fix the system downtime. Since this server needs to operate
almost like the main server if the DBMS fails, it is very similar to the other specifications. Another
operation required by the redundant server is the backups on Tapes. Having such an elaborate
system we cannot cope without backing our data. I suggest at 4.30 am every day we keep a
backup (after the 3am cron job of backing up the database). I also suggest that we can make use
of 15day backup so we can re-use tapes so as to minimize costs. Another measure is that every 2
days we take the backup to another location so as to follow the proper ways of backing
mentioned in this paper 36. Beside, according to another review, SuperMicro server systems are
                                                                              37
“the sole supplier of new 64-bit Xeon SATA servers”                                . This is the system I propose:




Main Office Server (Redundant) - SC743T-650 38
CPU: 2* 2.8GHz Xeon (Nocona) 1MB L2 Integrated
RAM: 4*1024 333 MHz SDRam (ECC)
Network: eth0 (connected to Router), eth1 (connected to Router – idle)
Storage: 2 * 74 GB Raptor SATA Discs (mirrored, Hot Swappable) for DataBase Server
                 2 * 16 GB Raptor SATA Discs (mirrored, Hot Swappable) for Web Server
                 2 * 16 GB Raptor SATA Discs (mirrored, Hot Swappable) for Mail Server
PSU: 650W
Additional Devices: Tape Backup Device
OS: Red Hat Linux ES
DBMS: MySQL 4.51
HTTPd: Apache 2.0 Web Server, Java Tomcat, Perl 5.86, PHP 5.01, Cron Daemon
E-Mail: sendmail, XInet.d : pop3
Additional Software: PhpMyAdmin

The Routing

The biggest headache in a network is definitely the routing. We need to route all the data from
one server to another in the fastest time possible, without data loss and in the securest

36
     Why even the best Backups Fail? Checklist for Success http://mailman.mit.edu/pipermail/kerberos/2002-September/001664.html
37
     LinuxElectrons Review on SuperMicro Boards http://www.linuxelectrons.com/article.php/20050125075542883
38 SuperMicro SC743T-650 http://www.supermicro.com/products/system/4U/7044/SYS-7044H-T.cfm?PID=TWR

                                                                                                                                  64
environment possible. As we included in the first report on our system, we still keep faith to the
Cisco 2600 Router. “These new models deliver extended performance, higher density, enhanced
security performance, and increased concurrent application support to meet the growing
demands of branch offices.” 39, is exactly what we need. We suggest another re-investment in
another of these modules and place it in the same cabinet where there is the other one.



Technologies Used

Following are the technologies used in the prototyping phase. Both the scripting language and the
DBMS used are Open Source and can be downloaded for free from the internet, thus reducing the
total cost of development.



MySQL DBMS

The MySQL database server embodies an ingenious software architecture that maximises speed
and customisability. With its Extensive reuse of pieces of code within the MySQL software and an
ambition to produce minimalist but functionally rich features have resulted in a database
management system unmatched in speed, compactness, stability and ease of deployment. With
MySQL, the unique separation of the core server from the storage engine makes it possible to run
MySQL under strict transaction control or with ultra fast transaction less disk access. 40



PHP Scripting Technology

PHP is an open source Web development language. Along with the Apache Web Server and Linux
Operating System, PHP is among the most widely deployed and used pieces of open source
software. PHP, according to NetCraft, has surpassed Microsoft ASP, making it the most popular
Web development language and is being utilized on over 15 million Websites today. 41 PHP is not
a strictly-typed language which makes it similar to ASP's VBScript/JScript and vastly different from




39 Cisco Product Information : http://www.cisco.com/en/US/products/hw/routers/ps259/
40
     Marketing Campaign of MySQL.com : www.mysql.com
41
     Extract from Why choose PHP? : http://www.zend.com/solutions/why-php.php

                                                                                                 65
Java strictly-typed approach. This in some cases is quite beneficial and in other situations may be
an impediment. 42


PHP has built-in support for session handling, cookie handling and form handling, and this
functionality has been made more secure and improved in the 4.1 release.



Tools Used

Cron Daemon
Cron is the name of program that enables unix users to execute commands or scripts (groups of
commands) automatically at a specified time/date. In this system it will be used to run both the
database backup at 3am (have prototype script for this) and Backing up the whole system on
tapes at 4.30am.



SmartDraw
SmartDraw was used to design the UML Diagrams, the ERD and also the Network Design.
Although Visio is a powerful product, it is best suited to technical experts. SmartDraw provides
ample drawing power while remaining easy enough for anyone to use. SmartDraw Is More
Versatile than Visio: SmartDraw includes more than 60,000 ready-made symbols and templates
                                                                                          43
that cover a much broader array of diagram types than Visio.




42
     What makes PHP special? : http://www.paragoncorporation.com/ArticleDetail.aspx?ArticleID=10
43
     Choosing SmartDraw over Visio : http://www.corporateangels.com/smartdraw-7-vs-visio.html

                                                                                                   66
Prototype

User R egistration and M anagem ent M odule
This module is fully functional module. This has been designed using PHP, as stated before.
Although the future system will be coded using Sessions, this module lacks support of sessions.
No themes and GUI has been coded for this prototype since the main aim was to show how the
PHP will interact with the Database. Another idea of this module was to depict the interface of the
different components of the system. Since with this module, a Forgotten Password and a Login
Panel have been implemented, one can see that data can be correctly manipulated from the .php
pages to the Database. Another aim for this prototyping module is to test the interface with the
Mail Server. Since both the User Creation and the Forgotten Password needs the support of the
mail() function of PHP. The User Registration module has fully working these functions:
      Image Code Verification
      Making sure username is unique
      Suggesting new username based first on Country then on Date of Birth
      Password comparing
      Password hashing in the database
      Password generating for forgotten password
      User login
      Loading Control Panel with options depending on Admin level
Improvements on this module would be enabling the account activation using the E-mail link
which is already sent in the email but generating an HTTP[‘SESSION’] so as to handle such
requests. Another necessary improvement would be to validate data fields since they are not
validated. Data in the Database is validated using the data types but such validation should take
place in the user page too. Graphical enhancements is a vital must.




                                                                                                67
User Creation Screen




                       68
User Logged-in Screen




Forgotten Password Screen




                            69
Still Screens


This type of protocol is to show how the important parts of the system will be visible to their
particular user. Once again no attention to user-interface and eye-catching themes has been
taken care of. Since it is a prototype I worked at keeping everything as simple as possible so as
the web-designer can be left free to enhance on the methods. These screens of each section are
very important since such HTML code will be inserted between the SQL queries which will be
written after the design process. One can notice that such screenshots have something in
common. These are the fields value. The values of each form field are already filled with data,
which data is using the PHP echo method to echo results from the database. Such echoes will
remain there even in the implementation stage since it is the best way to represent data to the
user from PHP arrays. As one can see in the uploaded online version each .htm page has different
screens in it. This is on purpose. As explained earlier, PHP code will be entered between the
screens and the particular screen is loaded depends on the IF statement.




                                                                                              70
User Edit Profile Screen




                           71
Create a Flight




                  72
Request a Report




                   73
Create Tour Operator




                       74
Search for a Flight




                      75
Database Design



Reason for including the design as well

Following is a printout of the Database design SQL format. Such a design includes the
implementation of Indices, Constraints and also has a very small data entry which was used
during prototype testing and table initialising. This printout shows that the database is not in
prototype stage but is in finished stage. This is due to the fact that all of the system is built
around this database. If data has to be altered, then simple SQL constructs executed directly on
the database will ALTER the tables.



The Backup Script written in .CGI

After the printout one could see that another script follows. This script is an enhancement of the
CGI script found on The World Community Network 44, an Open-Network web page. I removed
the support for the script to run from the web thus making it more secure. I decided to use a pre-
written code since this is a Prototype and the main aim is to have a working test of the system.
Besides, I made use of an Open Source project thus code regeneration is allowed by the licence.
This CGI script will be run by a cron job at 3am every day. The Backup Script will email the
admin and ftp the backup to the backup server as well. After the CGI script including in the
prototype will be the cron config for running the script.




44
     MySQL Backup : http://worldcommunity.com/opensource/utilities/mysql_backup.html

                                                                                               76
SQL Script for Database
-- MySQL-Administrator dump 1.3
--
-- ------------------------------------------------------
-- Server version                4.1.11-nt-max




SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT;
SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS;
SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION;
SET NAMES utf8;


/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=NO_AUTO_VALUE_ON_ZERO */;




CREATE DATABASE /*!32312 IF NOT EXISTS*/ `solutio_apt`;
USE `solutio_apt`;


DROP TABLE IF EXISTS `activity`;
CREATE TABLE `activity` (
 `id` int(10) unsigned NOT NULL auto_increment,
 `description` varchar(45) NOT NULL default '',
 `username` varchar(45) NOT NULL default '',
 PRIMARY KEY (`id`),
 KEY `FK_activity_1` (`username`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `activity` (`id`,`description`,`username`) VALUES
(1,'Login',''),
(2,'Logoff',''),
(3,'Edit Profile',''),
(4,'Edit Password',''),
(5,'Request Forgotten Password',''),
(6,'Search a flight',''),
(7,'Add Booking',''),
(8,'Edit Booking',''),
(9,'Effect Payment',''),
(10,'Close Account',''),
(11,'Add Employee',''),
(12,'Delete Employee',''),
(13,'Register Tour Operator',''),
(14,'Create a Flight',''),
(15,'Schedule Maintenance',''),
(16,'Request Report','');


DROP TABLE IF EXISTS `bookings`;
CREATE TABLE `bookings` (
 `id` int(10) unsigned NOT NULL auto_increment,
 `bookingscount` int(10) unsigned NOT NULL default '0',
 `emptyseats` int(10) unsigned NOT NULL default '0',
 `paid` char(1) NOT NULL default '',
 `scheme` int(10) unsigned NOT NULL default '0',
 `flight` int(10) unsigned NOT NULL default '0',
 `capacity` char(3) NOT NULL default '',
 `price` double NOT NULL default '0',
 `user` varchar(45) NOT NULL default '',


                                                                                      77
 PRIMARY KEY (`id`),
 KEY `FK_bookings_1` (`user`),
 KEY `FK_bookings_2` (`flight`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


DROP TABLE IF EXISTS `bookings_history`;
CREATE TABLE `bookings_history` (
 `id` int(10) unsigned NOT NULL auto_increment,
 `date_of_transaction` datetime NOT NULL default '0000-00-00 00:00:00',
 `type_of_transaction` varchar(45) NOT NULL default '',
 PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


DROP TABLE IF EXISTS `crew`;
CREATE TABLE `crew` (
 `id` int(10) unsigned NOT NULL auto_increment,
 `name` varchar(80) NOT NULL default '',
 `address` varchar(254) NOT NULL default '',
 `tel` varchar(20) default NULL,
 `rank` varchar(10) NOT NULL default '',
 `country` char(2) default NULL,
 `email` varchar(80) NOT NULL default '',
 PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `crew` (`id`,`name`,`address`,`tel`,`rank`,`country`,`email`) VALUES
(2,'Marisa Spiteri','5,\r\nGiovanni Curmi Str\r\nPaola','21668749','Pilot',NULL,''),
(3,'Mark Attard','27, Costantine Str Bkara','21449509','Pilot',NULL,''),
(4,'Christian Calleja','15, Pijunieri Str Fgura','21661838','Helper',NULL,''),
(5,'Maria Debattista','14, Guze Caruana Str Marsa','21478975','Helper',NULL,'');


DROP TABLE IF EXISTS `flight`;
CREATE TABLE `flight` (
 `id` int(10) unsigned NOT NULL auto_increment,
 `estimatedduration` time NOT NULL default '00:00:00',
 `departure_time` datetime NOT NULL default '0000-00-00 00:00:00',
 `helicopter` varchar(5) NOT NULL default '',
 `helipad_dep` int(10) unsigned NOT NULL default '0',
 `helipad_arr` int(10) unsigned NOT NULL default '0',
 PRIMARY KEY (`id`),
 KEY `FK_flight_1` (`helicopter`),
 KEY `FK_flight_2` (`helipad_dep`),
 KEY `FK_flight_3` (`helipad_arr`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `flight` (`id`,`estimatedduration`,`departure_time`,`helicopter`,`helipad_dep`,`helipad_arr`) VALUES
(1,'05:30:00','2005-04-27 17:06:17','001',0,0),
(2,'02:00:00','2005-04-30 06:10:49','001',0,0),
(3,'00:45:00','2005-04-22 11:30:00','003',0,0);


DROP TABLE IF EXISTS `helicopter`;
CREATE TABLE `helicopter` (
 `tag` varchar(5) NOT NULL default '',
 `fullname` varchar(45) NOT NULL default '',
 `capacity` int(10) unsigned NOT NULL default '0',
 PRIMARY KEY (`tag`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `helicopter` (`tag`,`fullname`,`capacity`) VALUES
('001','Shark Tale',15),
('002','Wide Wings',20),
('003','Pointed Arrow',10);


                                                                                                                   78
DROP TABLE IF EXISTS `helicopter_maintenance`;
CREATE TABLE `helicopter_maintenance` (
 `id` int(10) unsigned NOT NULL auto_increment,
 `date` datetime NOT NULL default '0000-00-00 00:00:00',
 `helicopter` varchar(5) NOT NULL default '',
 PRIMARY KEY (`id`),
 KEY `FK_helicopter_maintenance_1` (`helicopter`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `helicopter_maintenance` (`id`,`date`,`helicopter`) VALUES
(1,'2005-05-02 13:00:00','002');


DROP TABLE IF EXISTS `helipad`;
CREATE TABLE `helipad` (
 `id` int(10) unsigned NOT NULL auto_increment,
 `name` varchar(45) NOT NULL default '',
 `sales_office_tel` varchar(20) NOT NULL default '',
 `location` varchar(45) NOT NULL default '',
 PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `helipad` (`id`,`name`,`sales_office_tel`,`location`) VALUES
(1,'Luqa','21678723','Malta'),
(2,'Munxar','21543363','Gozo'),
(3,'Gandalfo','4475341233','Sicily'),
(4,'Hisbar Mario','231147754123','Madrid'),
(5,'Charles de Gaul','8883657112','Paris');


DROP TABLE IF EXISTS `leave`;
CREATE TABLE `leave` (
 `start` date NOT NULL default '0000-00-00',
 `end` date NOT NULL default '0000-00-00',
 `crew_id` int(10) unsigned NOT NULL default '0',
 `id` int(10) unsigned NOT NULL auto_increment,
 PRIMARY KEY (`id`),
 KEY `FK_leave_1` (`crew_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


DROP TABLE IF EXISTS `scheme`;
CREATE TABLE `scheme` (
 `id` int(10) unsigned NOT NULL auto_increment,
 `type` varchar(45) NOT NULL default '',
 `discount` double NOT NULL default '0',
 PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


DROP TABLE IF EXISTS `tour_operator`;
CREATE TABLE `tour_operator` (
 `toid` int(10) unsigned NOT NULL default '0',
 `no_of_users` char(3) NOT NULL default '',
 `shop_name` varchar(45) NOT NULL default '',
 `dateofbirh` date NOT NULL default '0000-00-00',
 `tel` varchar(25) NOT NULL default '',
 `address` varchar(254) NOT NULL default '',
 `country` char(2) NOT NULL default '',
 `email` varchar(80) NOT NULL default '',
 PRIMARY KEY (`toid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='InnoDB free: 4096 kB; (`toid`) REFER `solutio_apt/user`(`id`';
INSERT INTO `tour_operator` (`toid`,`no_of_users`,`shop_name`,`dateofbirh`,`tel`,`address`,`country`,`email`) VALUES
(4,'3','Euro Tours','0000-00-00','','','',''),


                                                                                                                       79
(5,'5','Hamilton','0000-00-00','','','',''),
(12,'2','Tour Test','0000-00-00','','','','');


DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
 `id` int(10) unsigned NOT NULL auto_increment,
 `uname` varchar(45) NOT NULL default '',
 `pass` varchar(45) NOT NULL default '',
 `name` varchar(45) default NULL,
 `address` varchar(254) default NULL,
 `country` char(2) NOT NULL default '',
 `email` varchar(80) NOT NULL default '',
 `tel` varchar(25) default NULL,
 `isodate` date NOT NULL default '0000-00-00',
 `admin` int(3) unsigned default '1',
 PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO `user` (`id`,`uname`,`pass`,`name`,`address`,`country`,`email`,`tel`,`isodate`,`admin`) VALUES
(4,'Saxon','856e2e6321ae54f7fb5da44a157336af','William Martin','8,\r\nCountry Lane\r\nNowhere','UK','highflyer3000@hotmail.com','4984843534','1985-05-25',1),
(5,'twanny','856e2e6321ae54f7fb5da44a157336af','antoine galea','the summit\r\ntriq tumas chetchuti\r\nattard','MT','galeaantoine@msn.com','21415154','1985-08-20',1),
(6,'Dave','856e2e6321ae54f7fb5da44a157336af','David Galea','The Summit\r\ntriq tumas chetchuti\r\nattard','MT','galeadavid@hotmail.com','21415154','1985-12-12',1),
(7,'yancho','856e2e6321ae54f7fb5da44a157336af','Matthew Pulis','28, ThistleGuze Pesci StrIklin','MT','matthew@solutions-lab.net','21435659','1984-07-30',3),
(10,'haNniba1','856e2e6321ae54f7fb5da44a157336af','Patrick Camilleri','St peter\'s flat 1\r\ncardinal \r\nVittoriosa\r\ncsp08','MT','dronetuner@hotmail.com','21807517','1985-03-
27',1),
(11,'Ghox','2cd324f30dc548396570da4e637c53ee','Karel Zahra','skajkfj','AL','k@z.com','1234435','1900-01-01',1),
(12,'tourop','jasdkfjkajdfkasdjkfdjaskj','Hamilton','sadf','MT','gesu@test.com','234232432','0000-00-00',3);
INSERT INTO `user` (`id`,`uname`,`pass`,`name`,`address`,`country`,`email`,`tel`,`isodate`,`admin`) VALUES
(13,'mikebc','50c927e5f17adb9341381991ac2a999f','mike borg cardona','testing street etc','MO','mborgcardona@hotmail.com','123123123','1923-02-24',3),
(14,'yancho2','786ddfa71ec39c7922a06aeb47c5b60c','Matthew Pulis','28asdf','MT','matthew@solutions-lab.net','21435659','1984-07-30',1),
(15,'yancho_MT','786ddfa71ec39c7922a06aeb47c5b60c','Matthew Pulis','','MT','matthew@solutions-lab.net','','1910-10-08',1),
(16,'B0SS','098f6bcd4621d373cade4e832627b4f6','Ben','aaa\r\naa\r\naa\r\naaaa','MT','bengatt@onvol.net','test','1985-01-21',1),
(17,'B0SS_MT','d41d8cd98f00b204e9800998ecf8427e','Ben','aaa\r\naa\r\naa\r\naaaa','MT','bengatt@onvol.net','test','1985-01-21',1);


DROP TABLE IF EXISTS `weblog`;
CREATE TABLE `weblog` (
 `id` int(10) unsigned NOT NULL auto_increment,
 `date` datetime NOT NULL default '0000-00-00 00:00:00',
 `username` char(45) NOT NULL default '',
 `activity_id` int(10) unsigned NOT NULL default '0',
 PRIMARY KEY (`id`),
 KEY `FK_weblog_1` (`activity_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED;
INSERT INTO `weblog` (`id`,`date`,`username`,`activity_id`) VALUES
(1,'2005-04-27 17:59:56','yancho',1),
(2,'2005-04-27 18:00:36','yancho',3);
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT;
SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS;
SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;




                                                                                                                                                                            80
MySQL Backup CGI Script

use DBI;
use POSIX qw(strftime);
use Time::Local;
use Cwd;
use File::Path;




no strict 'refs';


$ftp_backup                         = 'yes';
use Net::FTP;




$email_backup                        = 'yes';
use MIME::Lite;




$web_test_database                      = 'solutio_apt';




@selected_databases                      = qw[solutio_apt];




$process_all_databases                  = 'no';




@skip_databases                        = qw[];




@skip_tables                        = qw[];




$password_location                     = 'cnf';




$login_script_name                     = '';




$chmod_backup_file                    = 'yes';




#..............................................................................
# db host information
# set $db_host to a remote server if you need to access data
# on a different machine.


$db_host                          = 'localhost';




$db_port                          = '3306';




$cnf_file                       = '/cgi-bin/matthew/login.cnf';




                                                                                  81
$cnf_group                        = 'client';




$user                          = 'solutio_mpulis';
$password                         = 'songoku';


# $ENV{'MYSQL_UNIX_PORT'}                       = '/var/lib/mysql/mysql.sock';




$site_name                         = 'Helicopter ERP System';
$subject                        = "MySQL Backup Done for $site_name";




$mysql_backup_dir                      = '/backup/mysql_backup';




# MANDATORY UTILITY PATH SETTINGS
# ..................................


$find_commands                         = 'yes';


if ( $find_commands eq 'no' )
      {
      $mysqlshow_cmd                   = '/usr/bin/mysqlshow';
      $mysqldump_cmd                    = '/usr/bin/mysqldump';
      $nice_cmd                   = '/bin/nice';
      $tar_cmd                    = '/bin/tar';
      $gzip_cmd                   = '/bin/gzip';
      $bzip2_cmd                   = '/usr/bin/bzip2';
      $ls_cmd               = '/bin/ls';


      }


$compress_method                        = '';




$delete_text_files                 = 'yes';




$use_bzip2                        = 'no';


$gzip_args                        = '-9v';




$bzip_args                        = '-9v';




###################################################################################
# OPTIONAL VARIABLES SET UP SECTION
# (You may not need to change the vars below)
###################################################################################


$show_file_list_in_email               = 'no';




$print_stdout                     = 'no';




                                                                                      82
$date_text                        = strftime("%Y-%m-%d_%H.%M.%S", localtime);




$increments_to_save                      = 5;
$seconds_multiplier                    = 86400;
$increment_type                        = "Day(s)";


$seconds_to_save                        = $increments_to_save * $seconds_multiplier;


$space_line                       = " " x 5;


$ftp_host                        = 'apt-backup.solutions-lab.net';
$ftp_port                        = '21';


$ftp_passive                      = '0';


$ftp_user                        = 'mpulis';
$ftp_password                          = 'testpassword';
$ftp_dir                        = '/backup/mysql';


$tar_options                      = '-pv';


if ( $show_file_list_in_email eq 'yes' )
      {
      $tar_options .= ' -v';
      }


# backup file prefix
$file_prefix                    = 'bak.mysql';


# mysqldump variables
# ..................................


$mysql_dump_file_ext                    = 'txt';


$backup_type                           = 'mysqldump';


$backup_field_terminate                 = '|';
$backup_field_enclosed_by = '';
$backup_line_terminate                  = ":!:\n";


$outfile_params                   = qq~ fields terminated by '|' lines terminated by ':!:\n' ~;




###################################################################################
# SCRIPT CODE BELOW
###################################################################################


# web login routine
#..........................................


if ( $password_location eq 'from_web' )
      {
      print "Content-type: text/html\n\n";


      if ( param('w_user') =~ /\w+/ and param('w_password') =~ /\w+/ )
            {
            # test for authorized access


                                                                                                  83
              &connect_to_db($web_test_database);


              # if we get to here, it means that we're authorized
              print qq~<br>
                      <b><font color="blue" size="+1">
                      Running MySQL Backup . . .
                      </font></b>
                      <pre>
                      ~;
              }
       else
              {
              print qq~<br><table width="70%" border="0" align="center" cellpadding="3" cellspacing="3" bgcolor="F0F0F0">
                      <tr><td colspan="2" bgcolor="darkblue">
                      <b><font color="white" size="+1">
                      MySQL Backup Web Login Screen</font></b>
                      <FORM method="post" action="$login_script_name"></td></tr>
                      <tr><td align="right">User Name: </td>
                      <td><input type="text" name="w_user" size="16" maxlength="16"></td></tr>
                      <tr><td align="right">Password: </td>
                      <td><input type="password" name="w_password" size="16" maxlength="16"></td></tr>
                      <tr><td>&nbsp;</td><td><input type="submit" value="Login"></td></tr>
                      <tr><td colspan="2" align="center">
                      Note: The login will not proceed unless you
                      type a value in both fields.</form></td></tr></table>
                      ~;
              exit;
              }
       }
else
       {
       # clear the screen
       if (-e "/dev/tty")
              {
              $clear = `clear;pwd;`;
              print $clear;
              }
       }


# finish setup of email variables
#............................................


if ( $send_method eq 'sendmail' )
       {
       $mailprog_or_smtp_host = $mailprog;
       }
elsif ( $send_method eq 'smtp' )
       {
       $mailprog_or_smtp_host = $smtp_host;
       }
else
       {
       print qq~Error! You haven't setup your email parameters correctly.~;
       exit;
       }


# automatic utility setup
#................................
# CMD_ARRAY NOTE (below):


                                                                                                                            84
# Note that the automatic method of finding the commands that is used here
# creates variables names that match the commands. Since the script uses the
# default variable names listed in the array, you shouldn't edit the array
# unless you also change the var names in the script.


# DON'T EDIT THIS CMD_ARRAY unless you know what you're doing :-).


@cmd_array = qw[mysqlshow mysqldump nice tar gzip bzip2 ls];


if ( $find_commands eq 'yes' )
      {
      foreach $command ( @cmd_array )
            {
            if ( $command eq 'bzip2' and $use_bzip2 ne 'yes' ){next;}


            $cmd_name = $command . '_cmd';
            ($name, $$cmd_name, $rest) = split / /, `whereis $command`, 3;
            chomp $$cmd_name;
            }
      }


# zip variable setup


$gzip_file_type = 'x-gzip';
$bzip_file_type = 'x-bzip2';


$gzip_ext           = '.gz';
$bzip_ext           = '.bz2';


$gzip_type           = 'GZip';
$bzip_type           = 'BZip2';


if ( $use_bzip2 eq 'yes' and $compress_method ne 'z_switch' )
      {
      $gzip_cmd             = $bzip2_cmd;
      $gzip_args           = $bzip_args;
      $gzip_file_type = $bzip_file_type;
      $gzip_ext           = $bzip_ext;
      $gzip_type           = $bzip_type;
      }


# check if each cmd file exists
#...................................


foreach $command ( @cmd_array )
      {
      if ( $command eq 'bzip2' and $use_bzip2 ne 'yes' ){next;}
      $cmd_name = $command . '_cmd';
      unless ( -e $$cmd_name ){&error_message(qq~Error! $$cmd_name wasn't found.~);}
      }


# BEGIN BACKUP PROCESS
#....................................


$body_text = '';


unless ( -e "$mysql_backup_dir" )
      {
     &error_message(qq~Error! $mysql_backup_dir doesn't exist.~);


                                                                                       85
      }


chdir ("$mysql_backup_dir");


# now make a tar sub directory for this backup


$tar_dir = $file_prefix . "." . $date_text;
mkdir $tar_dir, 0777;


# we chmod the directory to 777 since the umask
# may be set differently.
# The directory needs to be set to 777 so that
# mysql can perform a 'select into outfile' in that
# directory (since mysql runs as a different user)


chmod 0777, $tar_dir;


unless ( -e "$mysql_backup_dir/$tar_dir" )
      {
      &error_message(qq~Error! $mysql_backup_dir/$tar_dir wasn't created.~);
      }


chdir ("$tar_dir");


$msg = "\nProcessing Backups Using " . uc($backup_type) .
       " in\n$mysql_backup_dir/$tar_dir\n\n";


if ( $print_stdout eq 'no' )
      {
      $msg .= qq~Screen Output (STDOUT) is turned OFF,
      so you won't see much until the script is done.\n\n
      ~;
      }


# I use print here, instead of &message,
# so that when $print_stdout is set to 'no',
# the script shows that it's working.


print "$msg";


&message('b',"Databases / Tables:\n");


# test and create the initial database array
# first convert the exception database and table arrays
# to hashes for speed searching
#............................................................................


%skip_databases = ();
%skip_tables           = ();


foreach my $database_name ( @skip_databases )
          {
          $skip_databases{$database_name} = $database_name;
          }


foreach my $table_name ( @skip_tables )
          {
          $skip_tables{$table_name} = $table_name;
          }


                                                                                86
# test to see if we should process all databases


if ( $process_all_databases eq 'yes' )
        {
        if ( $password_location eq 'cnf' )
            {
            $cmd = qq~$mysqlshow_cmd --defaults-extra-file=$cnf_file --host=$db_host~;
            }
        else
            {
            $cmd = qq~$mysqlshow_cmd --host=$db_host --user=$user --password=$password~;
            }


        &cmd_length($cmd) if $max_cmd > 0;
        @databases = `$cmd`;
        chomp ( @databases );
        }
else
        {
        @databases = @selected_databases;
        }


# here's where the backup is actually done
#............................................................................


foreach $db_main ( @databases )
        {
        if ( $db_main =~ /Databases/ ) {next;}
        if ( $db_main !~ /\w+/ )                    {next;}
        $db_main =~ s/\|//g;
        $db_main =~ s/\s+//g;


        if ( $process_all_databases eq 'yes' and exists $skip_databases{$db_main} )
                {
                &message('b',"\nSkipping: [$db_main\]\n");
                next;
                }


        # connect to db
        &connect_to_db($db_main);


        &message('b',"\nDatabase: [$db_main\]\n");


        # now grab table names for this databases
        # we use 'show tables' to avoid problems with mysqlshow % with older versions
        # ............................................................................


        $sth = $dbh->prepare("show tables") or &error_message(qq~Error!\n
                                               Can't execute the query: $DBI::errstr~);


        $rv = $sth->execute or &error_message(qq~Error!\n
                               Can't execute the query: $DBI::errstr~);


        while ( ( $table_name ) = $sth->fetchrow_array )
                {
                if ( exists $skip_tables{$table_name} )
                        {
                        &message('b',"\nSkipping: [$table_name\]\n");


                                                                                           87
                        next;
                        }


                if ( $print_stdout eq 'yes' )
                        {
                        print "$space_line table: [$table_name\]\n";
                        }


                if ( $show_file_list_in_email eq 'yes' )
                        {
                        $body_text .= "$space_line table: [$table_name\]\n";
                        }


                # NOW DO THE BACKUP
                #############################################################


                $backup_text = &do_backup($db_main, $table_name);


                if ( $print_stdout eq 'yes' )
                        {
                        print $backup_text;
                        }


                if ( $show_file_list_in_email eq 'yes' )
                        {
                        $body_text .= $backup_text;
                        }
                }


          # disconnect from each database
          &logout;
          }


# now tar and compress
#............................................................................


chdir ("$mysql_backup_dir");


&message('b',qq~\nTarring and Zipping Files (using $gzip_cmd):\n~);


$backup_tar_file             = $mysql_backup_dir . "/" .
                        $file_prefix . "." . $date_text . "_.tar";


$backup_gzip_file             = $backup_tar_file . "$gzip_ext";
$upload_gzip_filename = $file_prefix . "." . $date_text . "_.tar" . "$gzip_ext";


$compress_output = '';


if ( $compress_method eq 'z_switch' )
      {
      # compress with tar z switch
      &message('b',qq~\nNow Compressing with the Tar -z Switch ...\n~);


      $cmd = qq~$nice_cmd $tar_cmd $tar_options -c -z -f $backup_gzip_file $tar_dir~;
      &cmd_length($cmd) if $max_cmd > 0;
      $compress_output = `$cmd`;
      }
elsif ( $compress_method eq 'pipe_method' )
      {


                                                                                        88
       # pipe through gzip or bzip2
       &message('b',qq~\nNow Compressing via a Tar / $gzip_type Pipe ...\n~);


       $cmd = qq~$nice_cmd $tar_cmd $tar_options -c -f - $tar_dir | $gzip_cmd $gzip_args > $backup_gzip_file~;
       &cmd_length($cmd) if $max_cmd > 0;
       $compress_output = `$cmd`;
       }
else
       {
       # use two step method
       &message('b',qq~\nNow Compressing via Tar followed by $gzip_type ...\n~);


       $cmd = qq~$nice_cmd $tar_cmd $tar_options -c -f $backup_tar_file $tar_dir~;
       &cmd_length($cmd) if $max_cmd > 0;
       $compress_output = `$cmd`;


       # delete text files now, to save disk space
       if ( $delete_text_files eq 'yes' )
               {
               &delete_text_files;
               # set delete_text_files to 'no'
               # so that the script doesn't try to do it again, below
               $delete_text_files = 'no';
               }


       &message('b',qq~\nNow Compressing with $gzip_type ...\n~);


       $cmd = qq~$nice_cmd $gzip_cmd $gzip_args $backup_tar_file~;
       &cmd_length($cmd) if $max_cmd > 0;
       $compress_output .= `$cmd`;
       }


&message('b',$compress_output);


if ( $chmod_backup_file eq 'yes' )
           {
           chmod 0600, $backup_gzip_file;
           }


&message('b',"\nCreated Tar $gzip_type File: $backup_gzip_file\n");


# now check option to delete text files
#............................................................................


if ( $delete_text_files eq 'yes' )
       {
       &delete_text_files;
       }
else
       {
       if ( $chmod_backup_file eq 'yes' )
               {
               chmod 0700, $tar_dir;
               }
       else
               {
               chmod 0755, $tar_dir;
               }
       }


                                                                                                                 89
# now clean old files from main dir (gzip files)
# includes old tar_dirs


&clean_old_files("$mysql_backup_dir");


# now do ftp, if option is set


if ( $ftp_backup eq 'yes' )
      {
      # Connect to the server:
      &message('b',"\nConnecting via FTP to $ftp_host\n");


      $ftp = Net::FTP->new("$ftp_host",
                     Timeout => "30",
                     Port   => "$ftp_port",
                     Passive => "$ftp_passive",
                     Debug => "0") or
              &error_message(qq~Error! Net::FTP couldn't connect to $ftp_host : $@\n~);


      # Login with the username and password
      &message('b',"\nLogging in with FTP.\n");


      $ftp->login("$ftp_user", "$ftp_password") or
              &error_message(qq~Error! Net::FTP couldn't login to $ftp_host : $!\n~);


      # set the type to binary
      &message('b',"\nSetting FTP transfer to binary.\n");


      $ftp->binary or
              &error_message(qq~Error! Net::FTP couldn't set the type to binary for $ftp_host : $!\n~);


      # Change to the right directory
      &message('b',"\nChanging to FTP dir: $ftp_dir\n");


      $ftp->cwd("$ftp_dir") or
              &error_message(qq~Error! Net::FTP couldn't change to $ftp_dir at $ftp_host : $!\n~);


      # First check to see if file already exists
      &message('b',"\nChecking to see if file exists already: $backup_gzip_file\n");


      @lines = $ftp->dir("$ftp_dir") or
                &error_message(qq~Error! Net::FTP couldn't get a listing of $ftp_dir at $ftp_host : $!\n~);


      foreach $line ( @lines )
          {
          if ( $line =~ /$upload_gzip_filename/ )
                {
                &error_message(qq~Error! $upload_gzip_filename already exists at $ftp_host : $!\n~);
                }
          }


      # Upload the file
      &message('b',"\nUploading file: $backup_gzip_file\n");


      $ftp->put("$backup_gzip_file","$upload_gzip_filename") or
              &error_message(qq~Error! Net::FTP couldn't upload $backup_gzip_file at $ftp_host : $!\n~);


      # Get file size to see if the file uploaded successfully


                                                                                                              90
        &message('b',"\nChecking File Size of Remote file $upload_gzip_filename at $ftp_host\n");


        $uploaded_size = $ftp->size("$upload_gzip_filename") or
                  &error_message(qq~Error! Net::FTP couldn't get the size of $upload_gzip_filename at $ftp_host : $!\n~);


        $gzip_filesize = -s $backup_gzip_file;
        if ( $gzip_filesize == $uploaded_size )
            {
            &message('b', "\nUploaded File Size ($uploaded_size\) of $upload_gzip_filename (local size: $gzip_filesize) Matched at ftp site: $ftp_host\n");
            }
        else
            {
            &error_message(qq~Error! Uploaded File Size ($uploaded_size\) of $upload_gzip_filename (local size: $gzip_filesize) did NOT match at $ftp_host : $!\n~);
            }


        # Disconnect
        &message('b', $dir_print_text);
        &message('b',"\nDisconnecting from ftp site: $ftp_host\n");


        $ftp->quit() or
                &error_message(qq~Error! Net::FTP couldn't disconnect from $ftp_host : $!\n~);
        }


# now email admin notification of backup, with attached file option
#............................................................................


if ( $email_backup eq 'yes' )
        {
        &message('b', "\nEmailing $gzip_type File.\n");


        MIME::Lite->send("$send_method", "$mailprog_or_smtp_host", Timeout=>60);


        # Create a new multipart message:
        $msg = new MIME::Lite
                    From       =>"$admin_email_from",
                    To        =>"$admin_email_to",
                    Subject =>"$subject",
                    Type       =>"multipart/mixed";


        # Add parts
        attach $msg
                    Type        =>"TEXT",
                    Data        =>"\nTar.$gzip_type File\n[$backup_gzip_file]\nAttached\n$body_text";


        attach $msg
                    Type        =>"$gzip_file_type",
                    Encoding =>"base64",
                    Path       =>"$backup_gzip_file",
                    Filename =>"$upload_gzip_filename";


        $msg->send || die print qq~Error!\n\nError in Mailing Program!~;
        }
else
        {
        # just send notice, without attachment


        if ( $send_method eq 'smtp' )
            {
            # use this for windows machines that don't have sendmail


                                                                                                                                                                       91
            MIME::Lite->send("$send_method", "$mailprog_or_smtp_host", Timeout=>60);


            $msg = new MIME::Lite
                     From      =>"$admin_email_from",
                     To      =>"$admin_email_to",
                     Subject =>"$subject",
                     Type     =>"TEXT",
                     Encoding =>"7bit",
                     Data     =>"$body_text";


            $msg->send || die print qq~Error!\n\nError in Mailing Program!~;
            }
        else
            {
            &mail_to($admin_email_to, $admin_email_from, $subject, $body_text, $admin_email_from);
            }
        }


# I don't use &message here since the email has already gone out,
# and because it's perhaps good to give even minimilistic final output,
# even when $print_stdout is set to 'no'


print "\n\nDone! Exiting from MySQL Backup Script.\n\n";


exit;


###################################################################################
# connect_to_db
sub connect_to_db
{


# &connect_to_db($db_main);


my ($db_main) = @_;


if ( $password_location eq 'from_web' )
    {
    # we assume that the admin user should NOT use a .cnf file, but should
    # be forced to login from a form.


    # we test against 'w_user' and 'w_password' just in case
    # the 'user' and 'password' have been added to the setup section.


    $w_user         = param('w_user');
    $w_password = param('w_password');


    if ( $w_user !~ /\w+/ or $w_password !~ /\w+/ )
            {
            &error_message(qq~Error!<p>The Username and Password can't be
                          blank. Please hit BACK and try again.~);
            }


        $dbh = DBI->connect("DBI:mysql:$db_main:$db_host:$db_port", $w_user, $w_password)
                || &error_message(qq~<p>
                You were unable to connect to the database<br>
                It may be that you typed in your username or password
                incorrectly.<br>
                Please hit BACK and try again.~);


                                                                                                     92
       # we now have to copy the username and password to $user and $password
       # so that mysqlshow and mysqldump will find them


       $user     = $w_user;
       $password = $w_password;
       }


elsif ( $password_location eq 'this_file' )
           {
           $dbh = DBI->connect("DBI:mysql:$db_main:$db_host:$db_port", $user, $password)
                || &error_message(qq~Error!\n
                You were unable to connect to the database.\n
                $DBI::errstr~);
           }


elsif ( $password_location eq 'cnf' )
           {
           $dbh = DBI->connect("DBI:mysql:$db_main:$db_host:$db_port"
                           . ";mysql_read_default_file=$cnf_file"
                           . ";mysql_read_default_group=$cnf_group",
                           $user, $password)
                           || &error_message(qq~Error!\n
                           You were unable to connect to the database.\n
                           $DBI::errstr~);
           }
else
           {
           &error_message(qq~Error!\n
                     ... connecting to the Database.\n
                     You were unable to connect to the database.
                     Please check your setup.
                     ~);


           }


$dbh->{PrintError} = 1;
$dbh->{RaiseError} = 0;


}
###################################################################################
# logout
sub logout
{


warn $DBI::errstr if $DBI::err;
if ( $dbh ){$rcdb = $dbh->disconnect;}


}
###################################################################################
# error_message
sub error_message
{


# &error_message($error_text);


my ($error_text) = @_;


my $subject = "$site_name MySQL Backup Error";


                                                                                           93
print qq~\n$subject\n$error_text\n~;


if ( $send_method eq 'smtp' )
      {
      # use this for windows machines that don't have sendmail


      MIME::Lite->send("$send_method", "$mailprog_or_smtp_host", Timeout=>60);


      $msg = new MIME::Lite
                  From    =>"$admin_email_from",
                  To     =>"$admin_email_to",
                  Subject =>"$subject",
                  Type    =>"TEXT",
                  Encoding =>"7bit",
                  Data    =>"$error_text";


      $msg->send || die print qq~Error!\n\nError in Mailing Program!~;
      }
    else
      {
      &mail_to($admin_email_to, $admin_email_from, $subject, $error_text, $admin_email_from);
      }


exit;


}
###################################################################################
# message
sub message
{


# &message('s/e/b', $message);
# S = stdout
# E = email
# B = both


my ($output_method, $message) = @_;


if ( $print_stdout eq 'yes' )
      {
      if ( $output_method eq 's' or $output_method eq 'b' )
           {
           if ( $password_location eq 'from_web' )
                  {
                  $message_to_web = $message;


                  # $message_to_web =~ s/\n/<br>\n/g;


                  # I've disabled this because I use a <pre> code
                  # prior to the web output.


                  print $message_to_web;
                  }
           else
                  {
                  print $message;
                  }
           }


                                                                                                94
    }


if ( $output_method eq 'e' or $output_method eq 'b' )
    {
    if ( $body_text !~ /\w+/ )
           {
           $body_text = $message;
           }
    else
           {
           $body_text .= $message;
           }
    }


}
###################################################################################
# cmd_length
sub cmd_length
{


# &cmd_length($cmd);


my ($cmd) = @_;


if ( length($cmd) > $max_cmd )
    {
    &error_message(qq~
                   Error:<p>
                   The length of [$cmd\] is longer than $max_cmd\.
                   <p>
                   Check things like the length of the directory name
                   where you store your unix utilities.
                   You might like to shorten it to '/bin'.
                 ~)
    }
}
###################################################################################
# mail_to
sub mail_to
{


# &mail_to($email_to, $email_from, $subject, $mail_body, $reply_to);


my ($email_to, $email_from, $subject, $mail_body, $reply_to) = @_;


if ( $reply_to !~ /\@/ ){$reply_to = $email_from;}


open (MAIL, "|$mailprog") || die print qq~Error!\n\nCan't open $mailprog!~;


print MAIL "To: $email_to\n";
print MAIL "From: $email_from\n";
print MAIL "Subject: $subject\n";
print MAIL "Reply-To: $reply_to\n";
print MAIL "\n";
print MAIL "$mail_body";
print MAIL "\n";
close (MAIL);
}
###################################################################################


                                                                                      95
# do_backup
sub do_backup
{


# &do_backup($db_main, $table_name);


my ($db_main, $table_name) = @_;
my $response_text = '';


my $sth, $rv, $backup_file, $mysqldumpcommand;
my $backup_str, $row_string, $field_value;
my $len_field_terminate;
my @row;


$backup_file = $file_prefix . "." . $date_text . "_" . $db_main . "." . $table_name . "." . $mysql_dump_file_ext;
$full_file = "$mysql_backup_dir/$tar_dir/$backup_file";


if ( $backup_type eq 'mysqldump' )
       {
       if ( $password_location eq 'cnf' )
           {
           system("$mysqldump_cmd",         "--defaults-extra-file=$cnf_file",   "--host=$db_host",   "--quick",   "--add-drop-table",   "-c",   "-l",   "--result-file=$full_file",   "$db_main",
"$table_name");
           }
       else
           {
           system("$mysqldump_cmd", "--host=$db_host", "--user=$user", "--password=$password", "--quick", "--add-drop-table", "-c", "-l", "--result-file=$full_file", "$db_main",
"$table_name");
           }
       }
elsif ( $backup_type eq 'outfile' )
       {
       $backup_str = qq~
                   select * into outfile
                   '$full_file'
                   $outfile_params
                   from $table_name
                   ~;


       $sth = $dbh->do("$backup_str")
                   or &error_message(qq~Error!\n
                   Can't backup data: $DBI::errstr~);


       }
else
       {
       unless ( open(FILE, ">$full_file" ))
               {
               &error_message(qq~Error!\n
               Can't open File $backup_file.~);
               }


       $sth = $dbh->prepare("select * from $table_name")
               or &error_message(qq~Error!\n
               Can't do select for backup: $DBI::errstr~);
       $rv = $sth->execute
               or &error_message(qq~Error!\n
               Can't execute the query: $DBI::errstr~);



                                                                                                                                                                                             96
        while ( @row = $sth->fetchrow_array )
             {
             $row_string = '';


             foreach $field_value (@row)
                   {
                   $row_string .= $backup_field_enclosed_by .
                              $field_value .
                              $backup_field_enclosed_by .
                              $backup_field_terminate;
                   }
             $len_field_terminate = length($backup_field_terminate);
             if ( substr($row_string,-$len_field_terminate,$len_field_terminate) eq $backup_field_terminate)
                   {
                   substr($row_string, -$len_field_terminate,$len_field_terminate) = '';
                   }


             $row_string .= $backup_line_terminate;


             print FILE $row_string;
             }


        close(FILE);
        }


if ( $chmod_backup_file eq 'yes' )
        {
        chmod 0600, $full_file;
        }


$filesize = -s $full_file;
$response_text .= ' ' x 13 . "file: ($filesize bytes) $backup_file\n";


unless ( -e "$full_file" )
    {
    &error_message(qq~Error! "$full_file" wasn't created!~);
    }


return ($response_text);


}
###################################################################################
# delete_text_files
sub delete_text_files
{


&message('b', qq~\nRemoving Directory: $mysql_backup_dir/$tar_dir\n~);


chdir ("$mysql_backup_dir");


# this requires File::Path


$removed_dir = rmtree($tar_dir,0,1);


if ( -e "$tar_dir" )
    {
    &error_message(qq~Error! Tar Dir: $tar_dir wasn't deleted!<br>
                   Output results:<br>
                   $removed_dir


                                                                                                               97
                      ~);
       }
else
       {
       &message('b', "Removed temporary Tar Dir: $mysql_backup_dir/$tar_dir\n");
       }


}
###################################################################################
# clean_old_files
sub clean_old_files
{


# $mysql_backup_dir
# $seconds_to_save = $increments_to_save * $seconds_multiplier;


# call this subroutine with the '$full_dir_name'


my ($full_dir_name) = @_;


unless ( -e $full_dir_name )
       {
       &message('b',"\nCould NOT Clean Old Files - $full_dir_name doesn't exist.\n");
       return;
       }


&message('b',"\nCleaning Old Files\n");


$save_time = time() - $seconds_to_save;
$deleted_files = 0;


&message('b', "\nRemoving Files Older than $increments_to_save $increment_type\n");


opendir (DIRHANDLE, $full_dir_name);


# we use $file_prefix to make it safer; we don't want to delete
# any files except those matching the file spec


@filelist = grep { /^$file_prefix\./ } readdir(DIRHANDLE);


closedir (DIRHANDLE);


@sortlist = sort(@filelist);


my $file_count = @sortlist;
my $file_msg = "File Count in Backup Dir: $file_count \n\n";
&message('b', $file_msg);


# loop through directory
foreach $infile (@sortlist)
           {
           $infile_str = $infile;
           $infile   = "$full_dir_name/$infile";


           ($modtime) = (stat($infile))[9];


           if ( $modtime < $save_time )
                 {
                 # file is older, so delete it


                                                                                        98
            # check if file is a directory
            if ( -d $infile )
                {
                &message('b', "\n - Deleting Tar Subdir: $infile\n");
                $deleted_dir = rmtree($tar_dir,0,1);


                if ( -e "$infile" )
                    {
                    &error_message("\n - Problem Deleting Tar Subdir - $infile_str\.\n");
                    }
                else
                    {
                    $deleted_files++;
                    &message('b', " - Deleted Tar Subdir Correctly - $infile_str\.\n\n");
                    }
                }
            else
                {
                $delete_count = unlink "$infile";


                if ( ! -e $infile )
                        {
                        $deleted_files++;
                        &message('b', "$delete_count File Removed: ($infile_str\)\n");
                        }
                else
                        {
                        &error_message("\nProblem Removing File: $infile_str\n");
                        }
                }
            }
     else
            {
            &message('b', "- Keeping: $infile_str\n");
            }


     } # end of file loop


&message('b', "\nRemoved $deleted_files Files and/or Directories.\n");


}
###################################################################################
# END OF SCRIPT
###################################################################################



Cron Daemon Config
root@solutions # cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=
HOME=/


# run-parts
00 3 * * * root mysql_backup.pl


                                                                                            99
Conclusion

Project Overview

The aim of this project was to set out to provide an upgrade to the current IS being used at
HeliMalta Airlines. Accurate analysis of the situation has proved to deploy an ERP system to fir
these requirements. As guide we used the Unified Modelling so as to have the required tools for
the design. The new system is required to integrate with existent IS systems by generating
reports, whilst keeping the fast flow of data between departments as the main target. Active
feedback from employees, online users and tour operators was essential in developing the plan of
action which was concluded by a prototype, codenamed HeliSite. This prototype as explained
earlier has just 1 module active, so that both the company and the future users can understand
well the projections described in the UML.

Future Enhancements

A few enhancements to the system have been omitted out at the design stage. Since they are not
very important and vital for the new system to work flawlessly for now they have been discarded.
Since all our modules were prioritised, and we had very strict time restrictions, we decided to
focus more time on the actual design of the vital modules of the system rather then focus on the
now mentioned features. Such features have been identified include developing a better front-end
for the website. What we created in the prototype are just HTML forms which show how data is
being gathered and outputted to the user, all of which has to be incorporated into the template
which the website will be folded into. Another enhancement is to include the marketing and
customer-care module where questioners and a live support system for the customers will be
included

Next Phase

After completing the analysis and design the next step is for HeliMalta to analyse the project
designed and refine the modules. This process shouldn’t take long since all the modules were
designed with close reference to the particular department manager. After the approval of the
final design, the prototype can be continuously upgraded so as to reflect more the required
finished product. As soon as the design is approved by the top management of the company, the
only decision left is to who will be commissioned the development of the system.

                                                                                            100
References

Below is the list of the most important references I used to draw this task. Close reference has
been paid to the below mentioned web sites. These 2 websites highly helped me in designing the
UML diagrams with their tutorials. Although these aren’t the only references I used, as one can
see in the footnotes of every page, these are the most notorious ones :


                                         www.UML.org
                                       www.borland.com




                                                                                            101
Digital Media




                102

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:55
posted:6/14/2012
language:
pages:103