Part I. Web Technologies for Interactive Multimedia

Similar documents
Part I. Web Technologies for Interactive Multimedia

Web Scripting using PHP

Web Scripting using PHP

Global Servers. The new masters

CERTIFICATE IN WEB PROGRAMMING

PHP Personal Home Page PHP: Hypertext Preprocessor (Lecture 35-37)

PHP Hypertext Preprocessor

Web technologies. Web. basic components. embellishments in browser. DOM (document object model)

// Introducing PHP. Overview of Dynamic Sites with PHP and Top 5 Best Practices. WebTechNY September 10 th, 2008

CSCB20 Week 8. Introduction to Database and Web Application Programming. Anna Bretscher* Winter 2017

Lecture 12. PHP. cp476 PHP

An Introduction to JavaScript & Bootstrap Basic concept used in responsive website development Form Validation Creating templates

Hands-On Perl Scripting and CGI Programming

All India Council For Research & Training

What is PHP? [1] Figure 1 [1]

Database Systems Fundamentals

PHP: Hypertext Preprocessor. A tutorial Introduction

Web Application Development (WAD) V th Sem BBAITM(Unit-1) By: Binit Patel

COMP284 Scripting Languages Lecture 9: PHP (Part 1) Handouts

INTERNET PROGRAMMING. Software Engineering Branch / 4 th Class Computer Engineering Department University of Technology

Quiz 1 Review Session. November 17th, 2014

Get in Touch Module 1 - Core PHP XHTML

Web Engineering (Lecture 08) WAMP

Javascript, Java, Flash, Silverlight, HTML5 (animation, audio/video, ) Ajax (asynchronous Javascript and XML)

CSCB20 Week 8. Introduction to Database and Web Application Programming. Anna Bretscher* Winter 2016

Static Webpage Development

Programming the World Wide Web by Robert W. Sebesta

Lecture 7 PHP Basics. Web Engineering CC 552

Ampliación de Bases de Datos

Web development using PHP & MySQL with HTML5, CSS, JavaScript

PHP Online Training. PHP Online TrainingCourse Duration - 45 Days. Call us: HTML

Course Topics. The Three-Tier Architecture. Example 1: Airline reservations. IT360: Applied Database Systems. Introduction to PHP

PHP 5 Introduction. What You Should Already Know. What is PHP? What is a PHP File? What Can PHP Do? Why PHP?

COMS 469: Interactive Media II

Govt. of Karnataka, Department of Technical Education Diploma in Computer Science & Engineering. Fifth Semester. Subject: Web Programming

PHP 1. Introduction Temasek Polytechnic

Introduction to PHP. Handling Html Form With Php. Decisions and loop. Function. String. Array

Outline of Lecture 5. Course Content. Objectives of Lecture 6 CGI and HTML Forms

PHP: The Basics CISC 282. October 18, Approach Thus Far

Review. Fundamentals of Website Development. Web Extensions Server side & Where is your JOB? The Department of Computer Science 11/30/2015

This course is designed for web developers that want to learn HTML5, CSS3, JavaScript and jquery.

COMP284 Scripting Languages Lecture 14: JavaScript (Part 1) Handouts

Java Applets, etc. Instructor: Dmitri A. Gusev. Fall Lecture 25, December 5, CS 502: Computers and Communications Technology

The PHP language. Teaching you everything about PHP? Not exactly Goal: teach you how to interact with a database via web

(Frequently Asked Questions)

JavaScript: Introduction, Types

PHP & My SQL Duration-4-6 Months

Programming: C ++ Programming : Programming Language For Beginners: LEARN IN A DAY! (Swift, Apps, Javascript, PHP, Python, Sql, HTML) By Os Swift

Shankersinh Vaghela Bapu Institue of Technology

HTTP. Web. Web Web web

Web Development Course (PHP-MYSQL-HTML5.0)

Selenium Testing Course Content

CSC Web Programming. Introduction to JavaScript

Chapter 5. Names, Bindings, and Scopes

Chapter 27. HTTP and WWW

PHP Hypertext Preprocessor: Tools for Webpage Management. Michael Watson ICTN

JavaScript CS 4640 Programming Languages for Web Applications

PHP INTERVIEW QUESTION-ANSWERS

DATABASE SYSTEMS. Introduction to web programming. Database Systems Course, 2016

PHP. MIT 6.470, IAP 2010 Yafim Landa

Agenda. 1. Brief History of PHP. 2. Getting started. 3. Examples

B. V. Patel Institute of BMC & IT 2014

Inf 202 Introduction to Data and Databases (Spring 2010)

Course Curriculum Accord info Matrix Pvt.Ltd Page 1 of 7

Databases on the web

EasyChair Preprint. Introduction to Development of Software Support for Training and Testing IT Administrators

Web Programming Paper Solution (Chapter wise)

Web Engineering (CC 552)

Introduction to Programming Using Java (98-388)

C++ (Non for C Programmer) (BT307) 40 Hours

Programming the Web 06CS73 INTRODUCTION AND OVERVIEW. Dr. Kavi Mahesh, PESIT, Bangalore. Textbook: Programming the World Wide Web

Web Standards Mastering HTML5, CSS3, and XML

JavaScript CS 4640 Programming Languages for Web Applications

Outline. Introduction Concepts and terminology The case for static typing. Implementing a static type system Basic typing relations Adding context

Server side basics CS380

Setting Up a Development Server What Is a WAMP, MAMP, or LAMP? Installing a WAMP on Windows Testing the InstallationAlternative WAMPs Installing a

Princess Nourah bint Abdulrahman University. Computer Sciences Department

1.1 A Brief Intro to the Internet

Course Topics. IT360: Applied Database Systems. Introduction to PHP

Notes. Submit homework on Blackboard The first homework deadline is the end of Sunday, Feb 11 th. Final slides have 'Spring 2018' in chapter title

Table of Contents WWW. WWW history (2) WWW history (1) WWW history. Basic concepts. World Wide Web Aka The Internet. Client side.

Application Development in JAVA. Data Types, Variable, Comments & Operators. Part I: Core Java (J2SE) Getting Started

PHP and MySQL for Dynamic Web Sites. Intro Ed Crowley

CORE PHP CURRICULUM. Introductory Session Web Architecture Overview of PHP Platform Origins of PHP in the open source community

1.1 A Brief Intro to the Internet

VTU Question Bank. UNIT 1 Introduction to WWW, XHTML


Short Notes of CS201

JAVA. 1. Introduction to JAVA

CS201 - Introduction to Programming Glossary By

3. WWW and HTTP. Fig.3.1 Architecture of WWW

CS50 Quiz Review. November 13, 2017

Introduction of PHP Created By: Umar Farooque Khan

Core PHP. PHP output mechanism. Introducing. Language basics. Installing & Configuring PHP. Introducing of PHP keywords. Operators & expressions

SSC - Web applications and development Introduction and Java Servlet (I)

Web Programming HTML CSS JavaScript Step by step Exercises Hans-Petter Halvorsen

Introduction to Python. Didzis Gosko

Copyright 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 11 Introduction to PHP

Fachgebiet Technische Informatik, Joachim Zumbrägel

Web System and Technologies (Objective + Subjective)

Transcription:

Multimedia im Netz Wintersemester 2012/2013 Part I Web Technologies for Interactive Multimedia 1

Chapter 2: Interactive Web Applications 2.1! Interactivity and Multimedia in the WWW architecture 2.2! Server-Side Scripting (Example PHP, Part I) 2.3! Interactivity and Multimedia for Web Browsers 2.4! Interactive Server-Side Scripting (Example PHP, Part II) 2.5! Interactive Client-Side Scripting (Example JavaScript) 2.6! Data Storage in Web Applications! (Example Database Access in PHP) 2.7! Asynchronous Interactivity in the Web (Example AJAX) 2

Dynamic Web Contents Content shown to user in browser is dependent on some external variables Examples of external variables: Date and time Contents of an information archive (e.g. recent news) Actions of the user» Pointing to elements» Clicking at a certain position» Filling out forms Wide-spread applications: E-Commerce Interpersonal communication media (forums, discussion boards) Mass media (news and other information services) 3

Server-Side vs. Client-Side Realisation Browser Request Response Web- Server Browser Request Response Web- Server Script Client-side realisation: Browser contains execution engine for scripts Web server does not need to execute scripts Script ist sent to client as part of server response Example: JavaScript Server-side realisation: Web server contains execution engine for scripts Browser does not need to execute scripts Script is executed on server and computes response to client Example: PHP 4

Server Scripts vs. Client Scripts Client-Side Scripts (e.g. JavaScript) Fast reaction times good for fluid interaction Works also without network connectivity Independent of server software Computation of page contents dependent on external variables Server-Side Scripts (e.g. PHP) Data storage on server good for accessing media archives Access to central resources (e.g. for request processing) Independent of browser software 5

Common Gateway Interface (CGI) A request can identify an executable command on the server Command is executed Parameters are passed to it via environment variables (e.g. QUERY_STRING) Informal standard, by a developer community in 1993 Current standard (1.1) is documented at NCSA (http://hoohoo.ncsa.illinois.edu/cgi/) IETF RFC 3875 CGI programs can be written in any executable language: Programming languages (e.g. C/C++, Java) Scripting languages (e.g. Unix shells, Perl, TCL) Typical locations on server file system: /cgi-bin /cgi-src 6

Principles of Writing CGI Code Passing parameters to the CGI program: http://www.example.com/cgi-bin/example.cgi?paraminfo Program example.cgi is executed String paraminfo is made accessible for the program in the environment variable QUERYSTRING Passing information to the browser: The CGI program has to write the data in a form displayable by the browser Always the first line is a MIME type specification, e.g.: Content-type: text/html Example for a very simple CGI program:! #!/bin/sh echo "Content-Type: text/plain" echo "" echo "Hello, world." 7

Drawbacks of CGI High danger of security problems: Injection of malicious script code (through program errors) Calling a CGI command is expensive: Creating a new process (in Unix) Sometimes on demand compilation Generally not suitable to high load situations Alternatives to CGI: SCGI (Simple CGI) FastCGI (single persistent process to handle queries) WSGI (Web Server Gateway Interface) for Python Microsoft Internet Server Application Programming Interface (IISAPI) Server modules» E.g. script language modules for Apache 8

Modern Web Architectures for Interactivity Web server software add-ons Interfaces to common scripting and programming languages e.g. Perl, Ruby, Java Web server software integrated with specific execution environments ( Application Server ) Highly optimized for good throughput Complex, many configuration options e.g. Java Enterprise Edition, Microsoft.NET framework Scripting languages specifically designed for Web application development e.g. PHP see later 9

Media Support Functions of Client Only Client Server Web Browser Network Media rendering: Recognition of media file types» MIME registry of browser Local media playing software» Plugins or separate programs Interactivity: Local interactions» Highlighting, dynamic menus etc. 10

Media Support Functions by Server Only Client Server Web Browser Network Media rendering: Storage of media files and meta-information Indexing and querying Interactivity: Interactions with server-side effect» E.g. database updates (registration, buying,...) Interactions with global effect for all users» E.g. adding a comment, uploading a video 11

Media Support Functions by Client & Server Client Server Web Browser Network Media streaming: Playback of incomplete content in client Playout in defined order from server Synchronization, rate control, buffering Flow control (stop, start, pause) Adaptation to network conditions Interactivity: Near real-time interactions» E.g. status notifications, data ticker 12

Chapter 2: Interactive Web Applications 2.1! Interactivity and Multimedia in the WWW architecture 2.2! Server-Side Scripting (Example PHP, Part I) 2.3! Interactivity and Multimedia for Web Browsers 2.4! Interactive Server-Side Scripting (Example PHP, Part II) 2.5! Interactive Client-Side Scripting (Example JavaScript) 2.6! Data Storage in Web Applications 2.7! Asynchronous Interactivity in the Web (Example AJAX) Literature:! A. Trachtenberg, D. Sklar: PHP Cookbook, O Reilly 2006!! R. Lerdorf, K. Tatroe, P. MacIntyre: Programming PHP, 2nd. ed.,! O'Reilly 2006 13

Server-Side Script Language PHP (Only an example for a server-side script language!) PHP: Personal Home Page Toolkit» 1995, Rasmus Lerdorf» 2003, new by Zeev Suraski, Andi Gutmans PHP Hypertext Preprocessor (recursive acronym, backronym) Current version: 5.4.7 (September 2012) [version 6 has been stopped] OpenSource project: see www.php.net Can be used and modified freely (PHP license) Syntax loosely oriented towards C Variations of possible syntax Extensive function library being extended by community 14

Prerequisites for Using PHP in Practice Always (even if using just one computer) Installation of a Web server» OpenSource: Apache» Microsoft Internet Information Server Invocation of PHP always indirectly by loading pages from server (http://...)» Loading from local computer: http://localhost/... Installation of PHP software as plug-in for used Web server Very often also installation of a data base system (e.g. MySQL) Frequently used acronyms for specific configurations: LAMP: Linux, Apache, MySQL, PHP WIMP: Windows, Internet Information Server, MySQL, PHP MOXAMP: MacOS X, Apache, MySQL, PHP 15

Activation of PHP Module in Apache Example (MacOS 10.8): Apache + PHP module are pre-installed Apache server needs to be started... Configuration needs to be updated (remove a comment sign) /etc/apache2/httpd.conf: # This is the main Apache HTTP server configuration file. It contains the # configuration directives that give the server its instructions. # See <URL:http://httpd.apache.org/docs/2.2> for detailed information.... LoadModule bonjour_module libexec/apache2/mod_bonjour.so LoadModule php5_module libexec/apache2/libphp5.so #LoadModule fastcgi_module libexec/apache2/mod_fastcgi.so 16

Hello World in PHP <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional// EN "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <title>hello World with PHP</title> </head> <body> <h1> <?php echo "Hello World!";?> </h1> </body> </html> File hello.php in Web server directory 17

Embedding of PHP into HTML XML style (used here): Like Processing Instructions in XML <?php PHP Text?> SGML style: Widely used in older scripts Not really recommendable: PHP language not specified <? PHP Text?> HTML style: Using HTML tag: <script language="php"> PHP Text </script> 18

PHP Syntax (1) Inheritance from shell scripts Variables start with "$" Some UNIX commands part of the language, e.g.:! echo "Hello"; Control statements exist in different versions, e.g.: if (bedingung1) anw1 elseif (bedingung2) anw2 else anw3; if (bedingung1): elseif (bedingung2): else: endif; anwfolge1 anwfolge2 anwfolge3 19

PHP Syntax (2) Various comment styles: One-line comment, C style: echo "Hello"; // Hello World One-line comment, Perl style / Unix shell style: echo "Hello"; # Hello World "One line" ends also at end of PHP block Multi-line comment, C-style: echo "Hello"; /* Comment spreads over multiple lines */ Do not create nested C-style comments! Instruction must always be terminated with ";" Exception: end of PHP block contains implicit ";" 20

PHP Type System Scalar types: boolean, integer, float (aka double), string Compound types: array, object Special types: resource, NULL Resource type: refers to external resource, like a file "The type of a variable is not usually set by the programmer; rather, it is decided at runtime by PHP depending on the context in which that variable is used."!! (PHP Reference Manual) 21

Arrays in PHP (1) An array in PHP is actually an ordered map Associates values to keys Keys can be integer or string (even mixed in same array) Multi-dimensional arrays (arrays of arrays) are supported Multiple use of the array data structure for array, list, hash table, dictionary, stack, queue, Creating arrays (examples): <?php $arr = array("foo" => "bar", 12 => true); echo $arr["foo"]; // bar echo $arr[12]; // 1?> <?php $arr = array("somearray" => array(6 => 5, 13 => 9, "a" => 42)); echo $arr["somearray"][6]; // 5 echo $arr["somearray"][13]; // 9 echo $arr["somearray"]["a"]; // 42?> 22

Arrays in PHP (2) Arrays with strictly numerical keys Implicit position numbers as keys $array = array( 7, 8, 0, 156, -10); // this is the same as array(0 => 7, 1 => 8,...) Arrays as collections $colors = array('red', 'blue', 'green', 'yellow'); foreach ($colors as $color) { } echo "Do you like $color?\n"; Assignment operations on arrays always mean copying of values! 23

Object-Orientation in PHP <?php class SimpleClass { // property declaration Property access with "->" operator Visibilities: public, private, protected public $var = 'a default value'; } // method declaration public function displayvar() { echo $this->var; } $instance = new SimpleClass(); $instance->var = 'property value'; $instance->displayvar(); 24

Further Object-Oriented Concepts in PHP Static class properties and methods "static" keyword Class Inheritance: "extends" keyword in class definition Class Abstraction: "abstract" keyword in class definition Scope Resolution operator ("::"): Access to static, constant or overridden properties or methods of a class <?php class MyClass { const CONST_VALUE = 'A constant value'; } $classname = 'MyClass'; echo $classname::const_value; // As of PHP 5.3.0?> In combination with "self" and "parent" keywords (denoting classes): Possibility to access overridden version of a method (cf. "super" in Java) 25

Example: Fibonacci Function in PHP (Version 1) <body>... <h2> <?php function fib($n){ if ($n==0) return 0; else if ($n==1) return 1; else return fib($n-1)+fib($n-2); }; echo "fib(3) = ", fib(3), "<br>"; echo "fib(8) = ", fib(8), "<br>";?> </h2> </body> </html> fibonacci1.php 26