CS521 Slides Week (7 To16) Made by MAH JABEEN
CS521 Slides Week (7 To16) Made by MAH JABEEN
TOPIC 55 TO 63
Web Systems and Technologies
• Mouse events
• Keyboard events
• Touch events
• Form events
• Textfield events
WEEK 8
TOPIC 64 TO 72
Only audio/video lectures
Web Systems and Technologies
POST / page 1p /
<htm1 >
HTTP Request Hea der
Request Header Information Keys
• Advanced browser detection, need to get
browscap.ini and configure php.ini
[browscap] to use it
$previousPage =
$ SERVER['HTTP REFERER');
// Check to see referer was
search page
( st r p o s ( S p r e v i ousPage, " s e a r c h . php" )
! = 0)
echo "Ca href='search.php'>Back to
search</a>";
type='submit'>
Handling
< f n r m the File
-
'
'Upload ini PHP
'
oe t hon - ’ pt s t ac t i on -
(cl icn I) < i r Pu I I y pe- ' su bm i I ’ v a \ rl e = "S u Uri I flu e r y “ » ’
< / f a rm>
HTnL <i i '‹ • ' name- ' I '>
npuI
Bi uws ei-
(cl ient)
else .( // no error
ech:o $fileKey . "Uploaded successfully ";
”
.
File Size Restrictions
• Open fopen()
• Read data fgets()
• Close the file fclose()
In-Memory File Access
• file() Reads the entire file and returns an
array, with each array element
corresponding to one line in the file.
• fiIe_get_contents() Reads the entire file
and returns a string variable.
• fiIe_put_contents() Writes the contents of a
string variable out to a file.
Classes and Objects in
PHP
Defining Classes
lnstantiating Objects
• Use the new keyword
$picasso->birthCity = "Malaga",
TOPIC 87
$picasso = new
Artist(“Pablo”,“Picasso”,“Malaga”,“Oct 25,1881”, “Apr 8,1973”);
$dali = new
Artist(“Salvador”,“Dali”,“Figures”,“May 11 1904”, “Jan 23 1989”);
Classes and Objects in PHP
Methods
• Methods define the tasks each instance of a class can perform and are useful since
they associate behavior with objects
class Artist {
// …
public function outputAsTable() {
//…
}
}
$a->outputAsTable()
Web Systems and Technologies
TOPIC 88
TOPIC 89
class Artist {
public static $artistCount = 0;
public static function addArtist() {
self:: $artistCount++;
}
}
Artist::addArtist();
print(Artist::$artistCount);
Classes and Objects in PHP
Class Constants
• Constant Values can be stored more efficiently as
class constants so long as they are not calculated or
updated
Const EARLIEST_DATE =‘January1, 1200’;
• They can be accessed both inside and outside theclass
using self::EARLIEST_DATE in the class and
classReference::EARLIEST_DATE
Web Systems and Technologies
TOPIC 90
How websites
use databases
Databases and Web Development
Database
options
WEEK 11
TOPIC 91 TO 99
SQL,Database,PHP
OR
$result = $pdo->query($sql);
Accessing MySQL in PHP
Processing the Query Results
$sql = “SELECT * FROM Categories ORDER BY CategoryName”;
// run the query
$result = $pdo->query($sql);
// fetch a record from result set into an associative array
while ($row = $result->fetch()) {
// the keys match the field names from the table
echo $row['ID'] . “ - ” . $row['CategoryName'];
echo “<br/>”;
}
Accessing MySQL in PHP
Processing the Query Results
Accessing MySQL in PHP
Freeing Resources and Closing Connection
// close the connection
mysqli_close($connection);
$pdo = null;
Accessing MySQL in PHP
Working with Parameters
$sql = “UPDATE Categories SET CategoryName='Web' WHERE
CategoryName='Business'”;
$count = $pdo->exec($sql);
returns true
returns true
• ini_set('Iog_errors','1');
• It can also be set within the php.ini
file:
• log errors = On
Exceptions
catch (Exception
’
11
Regular Expression Syntax Patterns
• Email Addresses
• FILTER_VALIDATE_IP
• FILTER VALIDATE URL
• FILTER_VALIDATE_REGEXP
Validate Filters
• Validate against a regular expression (FILTER_VALIDATE_REGEXP)
var('12345-1234567-8', FILTER VALIDATE REGEXP,
array("options" array("regexp > "/‟\\d(5)-&1 d 7!-? d4 ")) ;
$cnic";
Sanitize Filters
• Remove or replace specific characters
• FILTER_SANITIZE_ADD_SLASHES
• FILTER_SANITIZE_ ENCODED
• FILTER_SANITIZE_ NUMBER_FLOAT
• FILTER_SANITIZE_ NUMBER_INT
• FILTER_SANITIZE_ SPECIAL_CHARS
• FILTER_SANITIZE_ URL
Types of Input Validation
• Required information
• Correct data type
• Correct format
• Comparison
• Range check
• Custom
Notifying the user
Pop-over
How to Reduce Validation Errors Use Input Masks
Bigger Picture
Request
O
TOrmPu
PHP page validates
passed data y
• Client process
• Can reduce server load
• Can be bypassed
Validation at the PHP Level
• Query Strings
• Cookies
• Sessions
Remember POST andGET
Artist:
T906
Nationality | Spain
Submit
Query string
Slides by Connolly & HDaF, "Fundamentals of Web Development" - 2’* Ed. Pearson Ed. (3018)
Dynamic vs S atic URLs
• Dynamic URLs (i.e., query strings)
• A pretty essential part of web application
development
• Static URLs
• The appearance of search terms within the
URL does seem to improve its relative pösition.
• Another benefit to static URLs is that
users tend to prefer them.
• Can use URL rewriting to make static URLs
be dynamic
URL Rewriting in Apache
Cookies
How Do Cookies Work?
User makes first request to
page in domain sooss 1I a
User makes another request . com .
to page in domain somes1 t e
. cam,
GET SomePagu . \›hp http/ 1.1 gO9t '
WWW.BOITI S1ta . com
Browser reads cookie
values from text flle for
each subsequent request
for Browser
somes i te . cool
Browser
saves cookie
values in text file and
associates them with
domain somesl te . com . HTTP response contains
cookles In header.
HTTP 1. 1 200 0K
Date: Sun , 15 Jan 2017 23 : 59 : 50 GST Server for somes1
te . com
retrieves these cookie
Set -CODk a : r ame=va values from request
Set - Cock a : name2=va I ue2 E•r› res=Sun 22 Jan 2017 ... header and uses them to
Content -Type: taxt / html customize the response.
5IirIes by CDnnolly & I-Ioar, "Fundamentals oT Web Development" - 2'* Ed. Pearson Ed. (7018)
Persistent Cookie Best Practices
• Use cookies for improving user
experience
• User preferences
• User behavior
• The website functionality should not
depend upon cookies
• If using cookies for login information, back it
up with a token on each login, saved on the
server as well
Setting a Cookie
<?php
// add 1 day to the current time
expiry time
$expiryiime time()+60*60*24;
create a persistent cookie
$name "Username";
$value = "Ricardo";
setcookie($name, $value, $expiryTime);
?>
Reading a Cookies
<?php
If (!isset($ COOKIE['Username'] valid cookie found
else
echo ”The username retrieved from the
cookie is:".$ COOKIE['Username' ;
}
?>
Serialization
Introduction
- name: Chicago
- 1a e t h ar\6 : PM C e8 eO - croat edDate : 1B67
- b1 t EDBt a: 0c t obar 25, 1681 - e1 za : a r ray ( 15 . 2)
- b1 t hC1 t y : ha1 aga - ma1ght ' 1g2 ton a
- da8t hDa t e: Apr11 8, 1B73
- wor k 8 : Ar r ay ( <Art s )
• cT-oatodDate : 1837
- e1ze ' array (7. 6 , 3.5)
'Virtue fry fionnnlly 1 I-lull, "f un‹Jan enFals of Web development" 2•* Ed. Pearson Ed. (2018)
Serialization in PHP
Example
class Artist implements Seria izable
public function serialize()
serialize(
array("earliest" >self:: ea ie tDate,
"first" > $this->firstName,
"last"
> $this lastName,
"bdate"
> $this->birthDate,
$this—>deathDate,
"bcity" > $this->birthCity,
"wordr" > $thi ->artworks
class Artist implements Se ializab e
serialization
How Does Session state work?
SlitTes by Com›ully & I-luar, "Fundamentals of Web Development" - 7 * Ed. Pearson Ed, (sofa)
How does it all work
Session Session
Server memory
Slides by Connolly & IJoar, "Fundamentals of Web Development" - 7’* id. Pearson Ed. (low)
Accessing session state
<?php
session start ;
e se
st)
SIi‹1es by Connolly & I-Ioar, “F-undamentals of Web Development" - 2’*Ed. Pearson Ed, (2018)
Checking session existence
<?php
Slitles by Connolly & Hoar, "Fundamentals of Web Development" - 2h*id. Pearson Ed, (2018)
Terminating a session
Threats
Broadly, threats can be categorized using the STRIDE mnemonic
• Spoofing—Theattacker uses someone else's information to access the system.
• Tampering—The attacker modifies some data in nonauthorized ways.
• Repudiation—The attacker removes all trace of their attack, so that they cannot be held
accountable for other damages done.
• Information disclosure—The attacker accesses data they should not be able to.
• Denial of service _The attacker prevents real users from accessing the systems.
• Elevation of privilege _ The attacker increases their privileges on the system
thereby getting access to things they are not authorized to do.
Vulnerabilities
• Vulnerabilities are the security holes in your system. The
top five classes of vulnerability from the Open Web
Application Security Project are:
1. Injection
2. Broken authentication and
session management
3. Cross-site scripting
4. Insecure deserialization
5. Security misconfiguration
Security Policy
• Usage policy defines what systems users are permitted to use, and under what
situations.
• Authentication policy controls how users are grantecl access to the systems.
• Legal policies define a wide range of things including data retention and backup policies as
well as accessibility requirements (like having all public communication well organized for
the blind).
Business Continuity
• Admin Password Management
• Backups and Redundancy
• Geographic Redundancy
• Stage Mock Events
• Auditing
Security by Design
Secure by Design
Ras;ulrameeO
Design
”irnplerrietttstton’
Privacy need5
Threat Testing
assessment
Pair
Security
po mming
Polcy Risk Security unit
assessment tests
Code Penetration
CAATriad reviews testing
Red ndancy Vulnerability
planning Pesos
Defensive
Attack thyse
programming
Test cases
Default
values
Authentication
Authentication Factors
O Client egisteis
c l i e n t \ d , secret
Usei equests login page
Client redirects the user to authentication server with its ‹ Ii»‹ and
‹allba‹t URL
Authorization code
Authorization code, secret
Aaess to en request
The client requests an
access token using
Access token (stored on client) the
O Client egisteis
c1 sent sd , secre t
Usei equests login page
I
O I
I
O Upon a valid login auihenticaiion servei ieiurns aredirect to the
client containing the authorization code.
Authorization code
Authorization code, secret 10
Aaess to en request
I The client requestsan
access tokenusing the
I Access token (stored on client) *’* ’I*! I* ’*'”"
'
UStf W6fltS 6tteSt to '
e h
*’ ’ ’' Access token, resource request
Protected resour‹r
The aaess token obtained eailiei grants accessto the
‹esource from the resource sewer.
Authorization
Authorization defines what rights and privileges a user has once they are
authenticated. Some principles:
• Using a separate database user for read and write privileges on a database.
• Providing each user an account where they can access their own files securely.
• Setting permissions correctly so as to not expose files to unauthorized users.
• Using Unix groups to grant users permission to access certain functionality rather than
grant users admin access.
• Ensuring Apache is not running as the root account (i.e., the account that can
access everythino).
WEEK 14
TOPIC 118 TO 126
Web Systems and Technologies
• 118 Cryptography, Cyphers, Digital Signatures
• 119 HTTPS
• 120 XML overview, XML Parser; XML schema
• 121 XSLT and XPath
• 122 XML Processing; XML in JavaScript; XML in PHP
• 123 JSON
• 124 Overview of Web Services
• 125 Consuming Web Services in PHP
• 126 Creating a Web Service in PHP
Web Systems and Technologies
Cryptography
Cryptography
An Overview
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
Cryptography
Symmetric Encryption
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
Cryptography
Modern Block Ciphers
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
Cryptography
Public Key Cryptography
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
Cryptography
Public Key Cryptography – Diffie Hellman
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
Cryptography
Digital Signatures
• A digital signature is a
mathematically secure way of
validating that a particular digital
document was
• created by the person claiming to
create it (authenticity),
• was not modified in transit
(integrity), and
• cannot be denied (nonrepudiation).
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
Cryptography
Digital Signatures
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
Web Systems and Technologies
HTTPS
Hypertext Transfer Protocol Secure (HTTPS)
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
Hypertext Transfer Protocol Secure (HTTPS)
Secure Handshakes
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
Hypertext Transfer Protocol Secure (HTTPS)
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
Hypertext Transfer Protocol Secure (HTTPS)
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
Hypertext Transfer Protocol Secure (HTTPS)
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
Hypertext Transfer Protocol Secure (HTTPS)
XML Overview
XML Overview
Introduction
• XML is a markup language, but unlike HTML, XML can be used to mark
up any type of data
• One key benefit of XML data is that asplain text, it can be read and
transferred between applications and different operating systems
• XML is used on the web server to communicate asynchronously with
the browser
• Used as a data interchange format for moving information between
systems
XML Overview
• XML Usage
XML Overview
Well-Formed XML
• Element names are composed of any of the valid characters
• Element names can’t start with a number
• There must be a single-root element
• All elements must have a closing element (or
be self-closing)
• Elements must be properly nested
• Elements can contain attributes
• Attribute values must always be within quotes
• Element and attribute names are case sensitive
XML Overview
Well-Formed XML Simplified Example
<?xml version="1.0" encoding="ISO-8859-1"?>
<art>
<painting id="290">
<title>Balcony</title>
<artist>
<name>Manet</name>
<nationality>France</nationality>
</artist>
<year>1868</year>
<medium>Oil on canvas</medium>
</painting>
</art>
XML Overview
Valid XML
</xs:element>
XML Overview
• Example XML Schema
<?xml version="1.0" encoding="ISO-8859-1"?>
<art>
<xs:element type="xs:short" <painting id="290">
<title>Balcony</title>
name="year"/> <artist>
<xs:element type="xs:string" <name>Manet</name>
<nationality>France</nationality>
name="medium"/> </artist>
</xs:sequence> <year>1868</year>
</xs:complexType> <medium>Oil on canvas</medium>
</painting>
</xs:element> </art>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Web Systems and Technologies
Expression Description
nodename All nodes with the name "nodename" painting
/ From root /art/painting
// Anywhere in the document
. Current node
.. Parent node
@ Attribute
[] Predicate
XPath and XSLT
XPath – Examples
<?xml version="1.0" encoding="ISO-8859-1"?>
<art>
<painting id="290">
• /art
<title>Balcony</title> • Selects element "art"
<artist>
<name>Manet</name>
<nationality>France</nationality>
• //year
</artist> • Selects element "year"
<year>1868</year>
<medium>Oil on canvas</medium>
</painting>
• //name/..
</art> • Selects element "artist"
• //painting/@id
• Selects attribute "id" in painting
• //painting[year>1800]
• Selects "painting" elements with
year > 1800
XPath and XSLT
XSLT
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
XPath and XSLT
XSLT – Example
<?xml version="1.0" encoding="UTF-8"?>
XML XSLT <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/art">
<h1>Paintings</h1>
<ul>
XSLT Processor <xsl:for-each select="painting">
<li>
<xsl:value-of select="title"/> by
<xsl:value-of select="artist/name"/>
</li>
</xsl:for-each>
<h1>Paintings</h1> </ul>
<ul> </xsl:template>
<li>Balcony by Manet</li>
</ul>
</xsSldil :essbtyCyonlneolsy&hHeoeat
r ,">Fundamentalsof Web Development" - 2nd Ed. Pearson Ed.
(2018)
Web Systems and Technologies
XML Processing
XML Processing
XML Processing in JavaScript
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
XML Processing
XML Processing in JavaScript
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
XML Processing
XML Processing in jQuery
var art = '<?xml ...';
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
XML Processing
XML Processing in PHP
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
XML Processing
SimpleXML
<?php
$filename = 'art.xml';
if (file_exists($filename)) {
$art = simplexml_load_file($filename);
// access a single element
$painting = $art->painting[0];
echo '<h2>'.$painting->title.'</h2>';
}
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
XML Processing
XPath with SimpleXML
$art = simplexml_load_file($filename);
$titles = $art->xpath('/art/painting/title');
foreach ($titles as $t) {
echo $t . '<br/>';
}
$names = $art->xpath('/art/painting[year>1800]/artist/name');
foreach ($names as $n) {
echo $n . '<br/>';
}
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
Web Systems and Technologies
JSON
JSON
Sample JSON
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
JSON
Using JSON in JavaScript
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
JSON
Using JSON in PHP
<?php
// convert JSON string into PHP object
$text = '{"artist": {
"name":"Manet", "nationality":"France"
}
}';
$anObject = json_decode($text);
// check for parse errors
if (json_last_error() == JSON_ERROR_NONE)
{
echo $anObject->artist->nationality;
}
?>
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
Web Systems and Technologies
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
Overview of Web Services
SOAP
Services
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
Overview of Web Services
REST Services
/authors/1
Get Post
Put Delete
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
Overview of Web Services
Identifying and Authenticating Service Requests
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
Web Systems and Technologies
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
Consuming Web Services in PHP
Consuming a JSON Web Service
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
Consuming Web Services in PHP
Consuming a JSON Web Service
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
Consuming Web Services in PHP
Consuming a JSON Web Service
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
Web Systems and Technologies
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
Creating Web Services
Creating a JSON Web Service
class Country extends DomainObject implements JsonSerializable
{
...
/*
This method is called by the json_encode() function that is part of PHP
*/
public function jsonSerialize() { return
['iso' => $this->ISO, 'name' => $this-
>CountryName, 'value' => $this->CountryName,
'area' => $this->Area, 'population' =>
$this->Population, 'continent' => $this-
>Continent, 'capital' => $this->Capital
]; } }
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
Creating Web Services
Creating a JSON Web Service
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
WEEK 15
TOPIC 127 TO 135
Web Systems and Technologies
Asrc=apivJRh1=eu[5&›-°vO28;=?46?0z=l4
Ils c a1e=2 &s ty’1e= '0,37’L?^. sma ntnaps
Popular frameworks
• Angular
• Ember
• Vue
• React
• Express
JavaScript for Backend Node.js
SIit1es by CDnnDIIy & I3oar, "Fundamental.s of Web Development" - 2'* Ed. Pearson Ed. (2018)
Blocking Thread-based Architecture (Traditional)
Each thread executes the
entirety of the web appII‹ation
npm install
npm install packagename
npm install packagename@version
npm update
npm list
Working with Node.js
// Load the http module to create an HTTP server
var http = require('http');
// Configure HTTP server to respond with Hello World to all requests var server =
http.createServer(function (request, response) {
)};
$ me hc11 o. §s
running
F›rst you have to run the program via node command (You
can stop the program via Ctrl-CQ
• Writing to a file
data is written in the file 'message.txt'
When writing is complete, anonymous function is "called back"
const fs = require('fs')
(e r r) {
fs.writeFile('message.txt'
' Hel l o No rl d ! ' , f u n c t i on
i f (e r r)
consol e . er ro r (e r r) ;
process.exit(1);
consol e . I og ( Nri ti ng i s done .
Introduction
Minimalist web application framework for Node.js
• Handles
• Routes
• Requests/Responses
• Views
Example
express require('express')
app express()
const port 7OOO
app.get('/:me', function(req, re )
res.send('Hello '.req.params.name)
function
console.log( ”http://localhost:”.$(port
Introduction
• Mostly Node.js is used with NoSQL databases like
MongoDB
• Can be used with traditional DBMS like mysql
Example
Var require('mysql');
var sql ='SELECT * FROM books';
});
con.connect(function(err) {
If (err) throw err; console.log("Connected!” ,
con.query(sql, function (err, result
If (err) throw err; console.log("Result:“ + result);
});
});
Introduction
<hr>
Enter you r c i ty : <1nput type="tex t ” nq model = "c i I y ' / >
<p>You entered : t ‹:1 I y ) ) < / p»
</ body>
/html•
A moc1ril+ is an Arig oil ar JS con t‹aiiler fnr the if Ierm t Ann /›an+nIs feed in the ap licaI ion
Nuw lI+is dit’e‹:Iive is spec i I yii›q the rriodu/c' used in the all lice I iun
•html ng app= 'dewo"• va r riyapp = angu1ar . riodul e ( ' demo' , [ ] ) ;
The $ s c‹›t›‹* va i.at›le is pa semi Tinjectert iiltc›)
Th is elt› we n t i s g n i n g IO Add a controller to the modLllL' f1. iOd mgCon I rol Jer fhc controller l›y Anq«I.arJS
;Sfi fi COnI rO/fer IO get iIS rJata
<body ng - con t ro 11or- " "» nyapp , cont ro11er ( @g $t* I ' , f unct 1on ($scope) (
<d1v 1 d= " 868f'ch * » Srive tl\r user's ink bit in ‹ ‹nndel prnt›erty n«+›’i‹•ct search $acope . c1I es = [ (name: ' Ca1gary ' , ' count ry : Canada ' ) ,
C1ty Search : <1nput (name:
type="I ext ” ng - ncde T- seure I› /> The s ‹'‹›t›o vari‹r+ i› v›‹.u i TDFent o , ' count ry : ' Canada ' } ,
• / d1v> (name: Boat on ' , count ry: ' 0n1 ted States ) ,
(name: ' Seat t1 e ' , ' count ry
s t ab 1 e» A directive to loop thruuqh a co\ Iectic›n namecT c I r 1os (whirh is de fir\ed in the controller) Un1ted Stat6B ' ) ,
(name: ATmar a’ , count ry :
<tr ng - Fepeat="c1 t y Jn c t as | H1 t ar sea re I | or do rBy ' nama ' ">
(name: ’Spaln ' } ,
«td» ( c1t , f1n‹re ) ) < / td> q /,// tn nlter lagw Fhis ¢'Ieicc'nt works. In this ' Berca \ ona ' , count ry: ' Spa1n ' ) ] ;
</ body»
The res«It in tf›e browser (notice the sort order)
</ htm1 »
Slides by ConnDIIy & I-Ioar, "Fundamentals of Web Development" - 3ndEd. Pearson Ed. (2018)
Getting Data from a Web Service
$http.get(url).then(function (response)
$scope.countries= response.data
});
});
Web sockets
Introduction
server hLtp.oreaLeServor(app);
cons Server require("socket.io
t (socket)
");
cons console.log('A user connested'),));
new Server(scrver);
t function(message) console.log('Mcssage
from client: '+messago): io.emit('Message received
'+message}),
L : 7 000 ); ))/
Client Side Example (JavaScript)
//receiving message
ol i en L . o u n c e ringe c I un t. i o n ( e ve n L)
conso lo . 1oq (event . ‹data) ;
se connection
Web server Hosting
Hosting Types
• Shared Hosting
• Simple
• Virtualized
• Dedicated
• Collocated
• In-house
• Cloud
WEEK 16
TOPIC 136 TO 144
Web Systems and Technologies
Introduction
• Domain Name System (DNS) is used to resolve an IP
address of a website
• Domain name registrars register website
• GoDaddy
• TuCows
• Network Solutions
Domain and Name Server Administration
DNS
• Registration
• WHOIS
• Use whois command
• Private registration
• Updating name servers
• Takes up to 48 hours
• Check status using dig command
• https://toolbox.googleapps.com/apps/dig
• Reverse DNS
Domain and Name Server Administration
Search Engines
Search Engines
Introduction
• Before the search engines
• Emails, message boards, websites
• Web directories (vlib, yahoo, dmoz)
• Web Crawlers
• Google
Search Engines
Search Engine Overview
• Components of a search engine
• Web Crawler, URL submission, …
• Indexes
• Query Server
Web Systems and Technologies
PageRank
PageRank
• PageRank
• An algorithm for ranking websites
• Models WWW as a graph, example:
HEC MOE • On VU website
<a href=‘https://hec.gov.pk’>HEC</a>
• On QAU website
<a href=‘https://hec.gov.pk’>HEC</a>
QAU VU
• On HEC’s website
<a href=‘https://vu.edu.pk’>VU</a>
<a href=‘https://qau.edu.pk’>QAU</a>
<a href=‘https://mofept.gov.pk’>MOE</a>
PageRank
PageRank
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
PageRank
How PageRank Works
HEC MOE
Iter 0 ¼ ¼ Iter 1 ¼ 1/4
Search Engine
Optimization
Search Engine Optimization
Introduction
• Search Engine Optimization(SEO) is a way
to increase the rank of a website
• White hat SEO
• Black hat SEO
Search Engine Optimization
• Designing URLs
• Descriptive paths and file names
• Website Design
• Layout, readability, JavaScript, structure
• Sitemaps
• Contents
• Original, fresh, UGCs
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2 nd Ed. Pearson Ed.
(2018)
Web Systems and Technologies
• Link spam
• Hidden links, comment spam, link farms, and pyramids, google
bombing
• Google bowling
• Cloaking
• Duplicate Contents
Web Systems and Technologies
Facebook Plugins
• Register as a developer
• Facebook Markup Language(FBML)
• Like and recommend buttons
<div class=“fb-like”
data-href=“https://example.com/page.html”
data-width=“200”
data-layout=“standard” data-action=“like”
data-size=“small”
data-share=“true”>
</div>
• More plugins
https://devolopers.facebook.com/docs/plugins
Online social Networks
Twitter Widgets
• Twitter
• Widgets
• Tweet this button
<a class=“twitter-share-button”
href=https://twitter.com/intent/tweet?text=Hello World!”>Tweet</a>
<script async
src=https://platform.twitter.com/widgets.js charset=“utf-8”></script>
• More widgets
https://publish.twitter.com
Web Systems and Technologies
• Auctions
Slides by Connolly & Hoar, "Fundamentals of Web Development" - 2nd Ed. Pearson Ed.
(2018)
Web Systems and Technologies
Web Analytics
Web Analytics
Introduction
• Web analytics provide us insights about website
usage
• Bandwidth usage
• Referrers
• Popular domains/page
• Search terms used for landing
• User behavior
• Demographics
Web Analytics
Web Metrics
• Page Views
• Unique page views
• Average visit duration
• Bounce rate
Web Analytics
Internal Analytics
• IP address
• User agent analysis
• Frequency analysis
• Can be provided by hosting company
Web Analytics
Third Party Analytics
• Google, Bing, …
• Dashboards
• Flow analysis
• In-page analytics
Web Systems and Technologies
Google Analytics-Demo