Web Class Final
Web Class Final
Course Design of
"Web Project Practice"
(2020/2021 Week 1-18 First Semester of School Year)
指导教师:庄巧莉 肖荣
1 / 38
School of Information Science and Technology
学号:2017529627007
2 / 38
School of Information Science and Technology
Contents
1. Project Overview........................................................4
1.1 Project Team and Task Assignment Record.................................4
1.2 Mission Completion.....................................................................4
1.3 Project Background and Objectives.............................................4
1.4 Introduction to Development Technology Stack and Tools.........5
2. Summary Analysis......................................................9
2.1 Software Architecture Design......................................................9
2.2 Detailed Description of Functions..............................................11
2.3 Use Case Diagram......................................................................13
2.4 Class Diagram and Sequence Diagram......................................14
3.Database Design........................................................16
3.1 Entity Relationship Diagram......................................................16
3.2 Database Modeling.....................................................................16
3.3 Database Table Structure............................................................17
4.Function Realization.................................................19
4.1 Function module.........................................................................19
4.1.1 Module Operation Instructions................................................23
4.1.2 Key code for Interface Implementation...................................25
4.1.3 Background Business Logic Code..........................................28
4.2 Project Security Strategy............................................................34
5. Project Deployment..................................................35
5.1 Deployment Architecture Diagram............................................35
5.2 Deployment Process...................................................................35
6.Experiences................................................................37
6.1 Project Harvest...........................................................................37
6.2 The Solved Problems and the Description of the Solution
Process..............................................................................................37
6.3 The Next Improvement Direction..............................................37
7.Conclusion.......................Error! Bookmark not defined.
3 / 38
1. Project Overview
I declare that I have worked on my project titled "Muzuro Ecommerce System” by myself. As the
author of the project, I declare that the project does not break copyrights of any third person.
Muzuro Ecommerce System is a website which allow user to purchase the products that they
want and allow user to put products in shopping cart at the same time allow user send
complains or problems if the have though the contact page .The system also allow the user to
check all the details of the products or any categories then at same time allow admin to add
new category , delete categories , add products , delete products ,see orders ,slides and last but
not least delete or add users into the system.
4 / 38
Returning to different parts of the site after adding an item to the shopping cart.
Easy scanning and selecting items in a list.
Effective categorical organization of products.
Simple navigation from home page to information and order links for specific
products.
Obvious shopping links or buttons.
Minimal and effective security notifications or messages.
The consistent layout of product information.
Web Development is a dynamic field with many technologies which often changes in
accordance with industry demands thus leading to random changes. In this project I had to use
technology which I’m most familiar with, so they was question of first frontend technologies,
backend technology, servers then last but no least the payment gateway system in question.
Below is list of the technologies I used.
XAMPP technologies
1.4.1 XAMPP
XAMMP is a free and open-source cross platform web server solution stack package
developed by Apache Friends, consisting mainly of the Apache HTTP Server, MariaDB
database and interpreters for scripts written in the PHP and Perl programming language.
(“X.A.M.P.P” stands X – An ideographic letter referring to cross-platform, A – Apache or its
expanded form Apache HTTP Server, M -MariaDB formerly MySQL, P -PHP and P -Perl).
Since most actual web server to a live server possible. When we are talking about web-based
e-commerce, web platforms, online shopping carts, frameworks those are all will definitely
deal and placed on operating systems.
1.4.2 Apache
Apache is an open-source software web server application which invented by Robert McCool
at 1995. As of February 1, 2014 Apache, was estimated to serve 61.3% of World Wide Web
usage.
Most popular web servers. 1 February 2014
Because:
5 / 38
It is cheap
It is efficient
It is open source-based web server, which can easily integrate with all server-side
programming lineages PHP/Python/Perl
It is well-documented
1.4.3 MySQL
MySQL has been available for the public at 1996 but has a development background going
back to 1979. Michael Widenius is a co-founder of MySQL. Name of this new invention he
called with his daughter’s name My. As of July 2013 MySQL, is a second world’s most widely
used RDBMS and it has also won Choice Award from the Linux Journal Readers’ on a number
of occasions.
The letter “P” refers three main server-side programming languages in the world which are
starts with the same letters PHP, Python, Perl. In the following chapters I will explain about
PHP with more details.
Number one web server side programming language in the world obviously is PHP, if we look
for the history of PHP we will find information that “PHP is created at 1995” but it is not
correct PHP is actually the continues product of PHP/FI (also called version PHP1) which is
created in 1994 by Rasmus Lerdorf, 4 months later at 1995 Rasmus improved and added more
functionality to PHP1 which he named after PHP2 and shared it with other developers to
improve the future of the language, from this point PHP became very popular and most used
server side scripting language.
6 / 38
Danish, Greenlandic Programmer Rasmus Lerdorf (citizen of the Canada) is the author of the
PHP, he wrote early versions of PHP1, and PHP2.
First version of PHP/FI Code, also called PHP1
At the early life of the PHP was simple CGI binaries which is written in the C programming
language. Lerdorf wrote this interface just to calculate visitors to his online resume (Personal
Home Page), and to define receiving traffic foe his home page. He named that scripts as a
"Personal Home Page Tools," or also called “PHP Tools” after a while, day by day more
functionality was asked and desired by his friends, colleagues and other firms who were using
those scripts for their web sites, and he added more and more functionalities to his scripts.
Until that time websites “world” were just simple static HTML web sites, which means user
could not interact with it. This new model was capable as well as database interaction and
more, providing a framework upon which users could develop simple dynamic web
applications such as personal dynamic home pages, storing online resumes and guestbook web
sites. In June of 1995, Lerdorf worked very hard on his scripts and he released the source code
for PHP Tools to the public, after this release developers and users allowed to use it as they
want. It gave to everybody enjoy with it, with fixing bugs, and improving it is futures.
1.4.5 Bootstrap 4
Bootstrap is a free front-end framework for faster and easier web development. Bootstrap
includes HTML and CSS based design templates for typography, forms, buttons, tables,
navigation, modals, image carousels and many other, as well as optional JavaScript plugins.
Bootstrap also gives you the ability to easily create responsive designs.
Responsive web design is about creating web sites which automatically adjust themselves to
look good on all devices, from small phones to large desktops.
Advantages of Bootstrap:
7 / 38
Easy to use: - Anybody with just basic knowledge of HTML and CSS can start using
Bootstrap.
Responsive features: Bootstrap's responsive CSS adjusts to phones, tablets, and
desktops.
Mobile-first approach: n Bootstrap, mobile-first styles are part of the core framework
Browser compatibility: Bootstrap 4 is compatible with all modern browsers (Chrome,
Firefox, Internet Explorer 10+, Edge, Safari, and Opera).
Payflow Payment Gateway: A payment gateway links your website to your processing
network and merchant account. Like most gateways, Payflow Payment Gateway handles all
major credit and debit cards. You will open the door to over 169 million active PayPal users
who look for and use this fast, easy, and secure way to pay.
Payflow Gateway is PayPal's secure and open payment gateway. Using the Payflow Gateway
APIs, merchants can process debit and credit card payments, PayPal, PayPal Credit®,
authorizations, captures, and credit voids. PayPal Payments Pro internally utilizes Payflow
Gateway and its API, providing the same features. PayPal Payments Pro merchants use PayPal
as their credit card processor, while Payflow Gateway merchants can choose to process their
online store payments with any major payment processor, bank, or card association. Merchants
who want total control over the checkout experience can host their own checkout pages and
send transactions to PayPal using the open Payflow Gateway API or choose to have PayPal
host the checkout pages and manage security for sales and authorizations.
2. Summary Analysis
From the programmer point of view best practices to create scalable, reusable, easy
maintainable information system is of course object-oriented methodology. In the early life of
OOP programming languages invented designing patterns but there was something needed to
use this approach after all MVC came as one of the main design patterns.
It is important to remember, however, that design patterns do not guarantee success. You can
8 / 38
only determine whether a pattern is applicable by carefully reading its description, and only
after you’ve applied it in your own work can you determine whether it has helped. One of
these patterns is Model-View-Controller (MVC). The programming language Smalltalk first
defined the MVC concept it in the 1970’s. Since that time, the MVC design idiom has become
commonplace, especially in object-oriented systems.
MVC stands for the M is a model, the V is a view, and the C is a controller. It means
manipulating ICT systems by three basic different approaches, model, view, controller
approach is also known as a design pattern, a description of a reusable solution to a recurring
problem given a particular context. MVC exist so that the challenges faced when designing
large - saleable applications may be approached in a consistent manner. MVC makes
developers, engenders life’s easy MVC will give us solution of the problem that how to best
separate the user interface of a program (the view), the business and utility classes that
actually do the complex thinking (the model), and its inner processing and decision making
(the controller) in such a way that they represent three distinct, separable components.
To illustrate more on the above ideology, I will show below which part response for what in
M.E.S (Muzuro Ecommerce System).
MVC (Model View Controller)
2.1.1 .1 Model
9 / 38
The above picture contain all my function which deals with Database that I used which is
MySQL.
2.1.1 .2 View
The picture above shows my View part of my system which deals with showing UI
representation of system.
2.1.1 .3 Controller
10 / 38
This show the functions which do most of the controlling of system especially the admin side
of the system .
Under this section I will be talking mainly of the backend or management algorithms or
functions of what’s going on in code and what it is supposed to do and I will talk about 5 that I
think are important.
This function first check number of products in cart using variable called $_SESSION which
first verify the user if it’s the same user or different user then if its same user then takes all id
and names of products which user have selected before. Then it’s going to check in MySQL
database in table products in there if there still enough product quantity for user to purchase if
not then the system is going to send message to user that the product user trying to purchase is
out of stock and is unavailable. This function is also responsible for show the product title,
product image, product price and ability to call a function which delete the product from
shopping cart and it is also responsible for send data about products to PayPal Gateway.
2.2.2function show_paypal ()
This function is the one which show payment button which named “BuyNow” which connect
to PayPal Gateway using the API so to be able to do the above function it makes use of
variable called $_SESSION, item quantity and call the function called isset () to check if there
is any data in cart.
2.2.3function process_transaction ()
This function is one which get data from PayPal Gateway then insert it into database table
called orders. The data that the function will receive will be like order amount, order
transaction number, order status, order currency.
2.2.4function add_category ()
This function is the one responsible with adding data about categories from admin side that’s
11 / 38
the one receives data like title and id is auto increment which means it automatic input itself.
2.2.5function add_product ()
This function is the one responsible with adding data about products from admin side that’s the
one receives data like title, category id, price, quantity, description, short description and last
but not least image which is moved from temporary location to uploads in root or project so
that it will be easy to read or fast then reload when it takes place. All the above data will be
insert into database in table called products.
12 / 38
2.3.2 Lesser Detailed Muzuro Ecommerce System Case Study
13 / 38
Here above is an example of UML class diagram which shows a domain model for Muzuro
Ecommerce System (online shopping). The purpose of the diagram is to introduce some
common terms, "dictionary" for online shopping(ecommerce) - Customer, Web User,
Account, Shopping Cart, Product, Order, Payment, etc. and relationships between. It could be
used as a common ground between business analysts and software developers. Each customer
has unique id and is linked to exactly one account. Account owns shopping cart and orders.
Customer could register as a web user to be able to buy items online. Customer is not required
to be a web user because purchases could also be made by phone or by ordering from
catalogues. Web user has login name which also serves as unique id. Web user could be in
several states - new, active, temporary blocked, or banned, and be linked to a shopping cart.
Shopping cart belongs to account. Account owns customer orders. Customer may have no
orders. Customer orders are sorted and unique. Each order could refer to several payments,
possibly none. Every payment has unique id and is related to exactly one account. Each order
has current order status. Both order and shopping cart have line items linked to a specific
product. Each line item is related to exactly one product. A product could be associated to
many line items or no item at all.
14 / 38
15 / 38
3.Database Design
16 / 38
3.3 Database Table Structure
1. Categories
2. Orders
3. Products
17 / 38
4. Reports
5. Slides
6. Users
18 / 38
4.Function Realization
19 / 38
4.1.4 Admin Page
20 / 38
4.1.6 Payment Page
21 / 38
4.1.8 Contact Page
22 / 38
4.2.1 Module Operation Instructions
4.2.1.1function cart () {
$total = 0;
$item_quantity = 0;
$item_name=1;
$item_number=1;
$amount=1;
$quantity=1;
foreach ($_SESSION as $name => $value) {
if($value > 0 ) {
if(substr($name, 0, 8 ) == "product_") {
$length = strlen($name);
$id = substr($name, 8 , $length);
$query = query("SELECT * FROM products WHERE product_id = " . escape_string($id). "
");
confirm($query);
while($row = fetch_array($query)) {
$sub = $row['product_price']*$value;
$item_quantity +=$value;
$product_photo = display_images($row['product_image']);
$product = <<<DELIMETER
<tr>
<td>{$row['product_title']}<br>
<img width='100' src = '../kresources/{$product_photo}'>
</td>
<td>¥{$row['product_price']}</td>
<td>{$value}</td>
<td>¥{$sub}</td>
<td><a class='btn btn-warning' href="..\kresources\cart.php?
remove={$row['product_id']}"><span class='glyphicon glyphicon-minus'></span></a> <a
class='btn btn-success' href=" ..\kresources\cart.php?add={$row['product_id']}"><span
class='glyphicon glyphicon-plus'></span></a>
<a class='btn btn-danger' href=" ..\kresources\cart.php?delete={$row['product_id']}"><span
class='glyphicon glyphicon-remove'></span></a></td>
</tr>
DELIMETER;
echo $product;
$item_name++;
$item_number++;
$amount++;
$quantity++;
}
$_SESSION['item_total'] = $total += $sub;
$_SESSION['item_quantity'] = $item_quantity;
23 / 38
}
}
}
}
24 / 38
}
$total += $sub;
echo $item_quantity;
}
}
}
session_destroy();
}else{
redirect("index.php");
}
}
Home Page
4.1.3.1 Header (header.php)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Shopping website developed in Dec 2020">
<meta name="author" content="Ashley Tendai Muzuro">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
25 / 38
<?php require_once('..\kresources\functions.php'); ?>
<div class="row">
<!-- was the product code but taken to function code-->
<?php get_product();?>
</div><!-- row end here-->
4.1.3.3 Side Navigation (side_nav.php)
<div class="col-md-3">
<p class="lead">Muzuro Ecommerce</p>
<div class="list-group">
<?php
// <--Category -->
get_categories();
?>
</div>
</div>
4.1.3.4 Slide (slider.php)
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0"
class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
<li data-target="#carousel-example-generic" data-slide-to="3"></li>
<li data-target="#carousel-example-generic" data-slide-to="4"></li>
<li data-target="#carousel-example-generic" data-slide-to="5"></li>
<li data-target="#carousel-example-generic" data-slide-to="6"></li>
<li data-target="#carousel-example-generic" data-slide-to="7"></li>
<li data-target="#carousel-example-generic" data-slide-to="8"></li>
</ol>
<div class="carousel-inner">
<?php get_active_slide();?>
<?php get_slides();?>
</div>
<a class="left carousel-control" href="#carousel-example-generic" data-
slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" data-
slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
</div>
4.1.3.5 Footer (footer.php)
<div class="container">
<hr>
26 / 38
</div>
</div>
</footer>
</div>
<!-- /.container -->
</body>
</html>
Under this section I’m going to talk about what happen once the user clicked the “BuyNow” in
Shopping Cart Page and how data is transferred from Muzuro Ecommerce System to PayPal
Gateway and back to M.E.S then send to orders tables in databases and which data involved.
Shopping Cart
Once user click on “BuyNow” this is what happen and whats behind the system.
27 / 38
Usually when using PayPal Gateway there many options when you create the BuyNow button
below are options and the detail I will explain the one I used later.
Create all your payment buttons using the Create a PayPal payment button page on the PayPal
website. All buttons created using this tool are secure by default, so there is no further security
action required.
(ii) PayPal Payments Standard Button Manager API Overview
Use the Button Manager API to dynamically create secure buttons. Note that you must be
comfortable programming in languages such as Java and PHP to use the Button Manager API.
(iii) Using EWP to Protect Manually Created Payment Buttons
Manually create payment buttons, and then manually encrypt them using the Encrypted
Website Payments (EWP) command line encryption utility. Note that you should only use this
method if your implementation will not allow you to use the Create a PayPal payment button
page.
(iv) Blocking Unprotected and Non-encrypted Website Payments
Edit your PayPal account profile to block unprotected and non-encrypted buttons. This adds
security to your system by blocking payments made from unexpected sources.
The EWP feature relies on standard public key encryption for protection. With public and
private keys, you can manually or programmatically encrypt payment button code to hide the
payment details before the buttons are displayed on your website. The table below illustrates
the sequence of actions that occur with payment buttons protected by using EWP.
Generate a public key for the website, upload it to PayPal, and download the PayPal
public certificate to the website.
Note: Do this action only once, when you first integrate PayPal Payments Standard
with your website.
28 / 38
Encrypt the payment button code by using the PayPal public key and then signing the
encrypted code with the website's private key.
Publish the signed, encrypted HTML code for the payment button to the website.
Click the published PayPal payment button.
PayPal checks the authenticity of the data by using the website's public key, which was
previously uploaded to PayPal.
PayPal decrypts the protected button code by using the PayPal private key.
PayPal redirects the payer's browser to the appropriate PayPal checkout experience, as
specified in the HTML variables of the decrypted button code.
Because manually created payment buttons are not saved on the PayPal website, you should
use EWP to encrypt the button code before placing the code on your webpage. The following
steps describe that process:
PayPal uses only X.509 public certificates, not public keys. A public key can be used for
decryption but contains no information identifying who provided the key. A public certificate
includes a public key along with information about the key, such as when the key expires and
who owns the key. PayPal accepts public certificates in OpenSSL PEM format from any
established certificate authority, such as VeriSign.
You can generate your own private key and public certificate using open-source software such
as OpenSSL.
4.1.4.3 Generating Your Private Key Using OpenSSL
Using the openssl program, enter the following command to generate your private key. The
command generates a 1024-bit ASRSA private key that is stored in the file my-prvkey.pem:
29 / 38
Log in to your PayPal business account at www.paypal.com.
Click the settings icon at the top of your PayPal account page and then click Profile
and settings.
Click My selling tools on the left side of the page, then at the bottom of the page, under
the More selling tools heading, click the Encrypted payment settings link. The Website
Payment Certificates page opens.
Scroll down the page to the Your Public Certificates section, and click the Add button
at the bottom of the page. The Add Certificate page opens.
Click the Browse button, and select the public certificate that you want to upload to
PayPal from your local computer.
Click the Add button. After your public certificate uploads successfully, it appears in
the Your Public Certificates section of the Website Payment Certificates page.
Store the certificate ID that PayPal assigned to your public certificate in a secure
place. You need the certificate ID that PayPal assigned to encrypt your payment
buttons by using the Encrypted Website Payments software provided by PayPal.
4.1.4.6 Downloading the PayPal Public Certificate From the PayPal Website
To download the PayPal public certificate:
Click My selling tools on the left side of the page, then at the bottom of the page, under
the More selling tools heading, click the Encrypted payment settings link. The Website
Payment Certificates page opens.
Scroll down the page to the PayPal Public Certificates section.
Click the Download button, and save the file in a secure location on your web server
which can be accessed from your website code.
After all this configuration of the information above now I put this details on M.E.S BuyNow.
30 / 38
After then button clicken then this form will appear from Paypal Website.
31 / 38
After this happen this form show with details from PayPal Website.
32 / 38
4.5 Project Security Strategy
4.5.1 Encryption
I make use of Encryption especially on “BuyNow” cause its very important it involves the user
money and products to I really make secure I have describe the process below above.
Use of Encryption on My BuyNow Button (Public Key and Private Key with program
OpenSSL
4.5.2 SQL Injection
In in my project a create a function which deal with this called escape_string() below is the
function and were its applied in my system.
The Function
The Application
The above is my login function which allow the user to enter into the admin page which
allows to control the whole system.
33 / 38
5. Project Deployment
While it would seem that moving to the cloud is a technology exercise, the reality is that the
core business case should be understood as to the potential benefits of cloud computing. This
is the first step because there is no need to continue if we can’t make a business case. Things
to consider include the value of shifting risk to the cloud computing provider, the value of on-
demand scaling (which has a high value in the world of ecommerce), and the value of
outsourcing versus in-sourcing.
5.2.2 Step 2: Understand your existing data, services, processes, and applications.
You start with what you have, and cloud computing is no exception. You need to have a data-
level, service-level, and process-level understanding of your existing problem domain, also
34 / 38
how everything is bundled into applications. I covered this in detail in my book, but the short
answer is to break your existing system or systems down to a functional primitive of any
architectural components, or data, services, and processes, with the intention being to
assemble them as components that reside in the cloud and on-premise.
Once you understand what you need, it’s time to see where you’re going. Selecting a cloud
computing provider, or, in many cases, several, is much like selecting other on-premise
technologies. You line up your requirements on one side, and look at the features and functions
of the providers on the other. Also, make sure to consider the soft issues such as viability in the
marketplace over time, as well as security, governance, points-of-presence near your
customers, and ongoing costs.
In this step I migrate the right architectural assets to the cloud, including transferring and
translating the data for the new environment, as well as localizing the applications, services,
and processes. Migration takes a great deal of planning to pull off successfully the first time.
Once M.E.S(Muzuro Ecommerce System) system is on the cloud computing platform, it’s
time to deploy it or turn it into a production system. Typically, this means some additional
coding and changes to the core data, as well as standing up core security and governance
systems. Moreover, you must do initial integration testing, and create any links back to on-
premise systems that need to communicate with the newly deployed cloud computing systems.
Hopefully, everything works correctly on new cloud computing provider. Now I must verify
that through testing. I need to approach this a few ways, including functional testing, or how
my ecommerce system works in production, as well as performance testing, testing elasticity
of scaling, security and penetration testing. In a nutshell, after all the tests has taken place and
then system is ready for running.
6.Experiences
To conclude this master art, I want to start by the mistakes and errors I did during the process
of making this system. I made a lot of errors, but I managed to grasp a lot from those mistakes
35 / 38
for instance the paypal gateway gave me a lot of problems but in turn I understand how
payment gateway works and securely encrypting my information over the internet. Secondly, I
had some problems with Bootstrap because I had forgotten some classes which were vital so I
had to go back and study them again so that I can implement but as this project concludes I
would like to say it I reap many benefits such as deep understanding of Web Development in
world application using frontend. I improved the Bootstrap then in backend improve level
understanding. I made errors too in PHP that I had to research on internet everyday but at the
end of day was worth the effort in the end when I look at what produces.
6.2 The Solved Problems and the Description of the Solution Process
Solution
This error I was not able to correct it due to deadline approaching but it does not affect the
execution of the system and functionally ,the program execute smoothly .
6.3.1Project Limitations
There are some limitations for the current system to which solutions can be provided as a
future development:
The system is not configured for multi-users at this time. The concept of the
transaction can be used to achieve this.
The Website is not accessible to everyone. It can be deployed on a web server so that
everybody who is connected to the Internet can use it.
Credit Card validation is not done. Third-party proprietary software can be used for
validation checks.
The Administrator of the web site can be given more functionality, like looking at a
specific customer’s profile, the books that have to be reordered, etc.
36 / 38
Multiple Shopping carts can be allowed.
More beautiful UI can be implemented which makes use of more icons and beautiful
notifications which can improve user friendliness to users and appealing to eye sight.
In house creation of customers account rather than use of 3 rd party system and increase
in security thus use of encryption of data to avoid unnecessary leaking of important
customer data.
Microservice framework application
37 / 38
38 / 38