UFCEKG-20-2 Data, Schemas & Applications Lecture 4 Server Side Scripting & PHP.

Slides:



Advertisements
Similar presentations
PHP I.
Advertisements

Other Web Application Development Technologies. PHP.
Molecular Biomedical Informatics Web Programming 1.
Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
BY: ALBERTO CABEZAS 4/19/2010. INTRODUCTION: PHP is considered today as one of the most famous scripting languages. PHP is widely used as a general purpose.
Server-Side vs. Client-Side Scripting Languages
Learning Web development. 3(+1) Tier architecture PHP script Remote services Web Server (Apache, IIS) Browser (IE, FireFox, Opera) Desktop (PC or MAC)
B.Sc. Multimedia ComputingMedia Technologies Database Technologies.
Introduction to PHP. PHP Origins Rasmus LerdorfRasmus Lerdorf (born Greenland, ed Canada) PHP originally abbreviation for ‘Personal Home Pages’, now ‘PHP.
Intermediate PHP (1) Data Structures, Functions, Basic OO & Error Handling.
Scripting Languages and PHP. Origins Rasmus Lerdorf ‘Personal Home Pages’. Zeev Surashi and Andi Gutmans Open Source PHP version 4 Full information on.
Java Server Pages Russell Beale. What are Java Server Pages? Separates content from presentation Good to use when lots of HTML to be presented to user,
Guide To UNIX Using Linux Third Edition
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
Web Programming Language Dr. Ken Cosh Week 1 (Introduction)
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Web Programming with PHP (1). -Computer programming (often shortened to programming or coding) is the process of writing, testing, debugging/troubleshooting,
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
Sys Prog & Scripting - HW Univ1 Systems Programming & Scripting Lecture 15: PHP Introduction.
COMP An Introduction to Computer Programming : University of the West Indies COMP6015 An Introduction to Computer Programming Lecture 03.
Introduction to PHP. PHP PHP is the Hypertext Pre-processor –Script language –Embedded into HTML –Runs as Apache module –Can use DB (MySQL, Oracle, Microsoft.
PHP: Hypertext Processor Fred Durao
August Chapter 1 - Essential PHP spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science and Technology.
PHP Overview CS PHP PHP = PHP: Hypertext Preprocessor Server-side scripting language that may be embedded into HTML One goal is to get PHP files.
PHP == ‘ Hypertext Preprocessor ’ Open-source, server-side scripting language Used to generate dynamic web-pages PHP scripts reside between reserved PHP.
Introduction to PHP and Server Side Technology. Slide 2 PHP History Created in 1995 PHP 5.0 is the current version It’s been around since 2004.
Copyright © Curt Hill PhP History and Introduction.
CP3024 Lecture 3 Server Side Facilities. Lecture contents  Server side includes  Common gateway interface (CGI)  PHP Hypertext Preprocessor (PHP) pages.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
ITD 3194 Web Application Development Chapter 4: Web Programming Language.
AIT 616 Fall 2002 PHP. AIT 616 Fall 2002 PHP  Special scripting language used to dynamically generate web documents  Open source – Free!!!  Performs.
Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,
PHP TUTORIAL. HISTORY OF PHP  PHP as it's known today is actually the successor to a product named PHP/FI.  Created in 1994 by Rasmus Lerdorf, the very.
School of Computing and Information Systems CS 371 Web Application Programming PHP - Basics Serving up web pages.
Chapter 17 - Deploying Java Applications on the Web1 Chapter 17 Deploying Java Applications on the Web.
JSP Java Server Pages Softsmith Infotech.
IST 210: PHP BASICS IST 210: Organization of Data IST210 1.
JAVA SERVER PAGES. 2 SERVLETS The purpose of a servlet is to create a Web page in response to a client request Servlets are written in Java, with a little.
November 2003Bent Thomsen - FIT 6-11 IT – som værktøj Bent Thomsen Institut for Datalogi Aalborg Universitet.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Web Pages with Features. Features on Web Pages Interactive Pages –Shows current date, get server’s IP, interactive quizzes Processing Forms –Serach a.
Kingdom of Saudi Arabia Ministry of Higher Education Al-Imam Muhammad Ibn Saud Islamic University College of Computer and Information Sciences Chapter.
A very basic overview of Server-Side Scripting Or what is PHP, Perl, Python, Ruby and what can they do for me?
Variables and ConstantstMyn1 Variables and Constants PHP stands for: ”PHP: Hypertext Preprocessor”, and it is a server-side programming language. Special.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
1 MSCS 237 Overview of web technologies (A specific type of distributed systems)
PHP Open source language for server-side scripting Works well with many databases (e.g., MySQL) Files end in.php,.php3 or.phtml Runs on all major platforms.
Week 4 PHP H ypertext P reprocessor Reference : Official Site :
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
Web111a_chapt08.ppt HTML: Section 8 JavaScript CGI Programs (Server Side programs) Common Gateway Interface Run on server Communicate with user across.
IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.
IT ELECTIVE 2.  Web server Can refer to either the hardware (the computer) or the software (the computer application) that helps to deliver content that.
Martin Kruliš by Martin Kruliš (v1.1)1.
 Previous lessons have focused on client-side scripts  Programs embedded in the page’s HTML code  Can also execute scripts on the server  Server-side.
Module: Software Engineering of Web Applications Chapter 2: Technologies 1.
CS562 Advanced Java and Internet Application Introduction to the Computer Warehouse Web Application. Java Server Pages (JSP) Technology. By Team Alpha.
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
Fall 2004CSI University of Ottawa Introduction to PHP Basic principles and syntax.
1 PHP Intro PHP Introduction After this lecture, you should be able to: Know the fundamental concepts of Web Scripting Languages in general, PHP in particular.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
IST 210: PHP Basics IST 210: Organization of Data IST2101.
A S P. Outline  The introduction of ASP  Why we choose ASP  How ASP works  Basic syntax rule of ASP  ASP’S object model  Limitations of ASP  Summary.
Introduction to PHP. PHP Origins Rasmus LerdorfRasmus Lerdorf (born Greenland, ed Canada) PHP originally abbreviation for ‘Personal Home Pages’, now ‘PHP.
National College of Science & Information Technology.
* Lecture # 7 Instructor: Rida Noor Department of Computer Science
PHP Introduction.
Intro to PHP & Variables
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
Web Programming with PHP (1)
Presentation transcript:

UFCEKG-20-2 Data, Schemas & Applications Lecture 4 Server Side Scripting & PHP

Last week: o encode data for communication o card based o csv o tagged records o Xml o xml vocabularies o xml processing vocabularies o xml namespaces o xml characteristics o rss o rss aggregation

Processing carried out on a web server o SSI - Server-Side Include with some processing o Perl o PHP o Python o ASP (C#, VB, F#..) o JSP o Ruby o XSLT o XQuery o Javascript (with jNode) Server-side languages

We will be studying a number of different languages on this module because o Web development typically uses multiple languages o New languages are appearing all the time o Language design is evolutionary o Comparing the syntax and features of several languages helps to understand computer languages in general e.g. How do different languages handle StringsStrings Multiple languages

Processed by the web server File suffix - shtml.. Include a common file Execute a Unix command or cgi script and include the result SSI (Server Side Includes)

PHP Origins Originally created by Rasmus Lerdorf (born Greenland, educated in Canada) around 1995Rasmus Lerdorf PHP originally abbreviated as ‘Personal Home Pages’, now known as ‘PHP Hypertext Pre-processor’ Other key developers: Zeev Surashi and Andi Gutmans (Israel) responsible for PHP a complete re-write of the original PHP/F1 engine (1997) PHP is Open Source software First version PHP/FI released 1995 PHP 5.0 released July 2004 Current stable version is (as of August 2012) PHP version current at UWE PHP Version 6 due for release since late 2010 but ??

PHP is often used to generate HTML pages with dynamic content. Here it is used like SSI. The markup are one way to delimit PHP code within HTML. Basic Page Basic Page Hello world This page is different every time it is loaded Current date/time is PHP ‘Hello World’ Run

Accessing URI parameters <?php $site = $_REQUEST["site"]; $rawdatafile = $site. "/clientraw.txt"; echo $rawdatafile; ?> o PHP uses C conventions for assignment, statement separators, blocks etc. o PHP provides the parameters from the URI as an array of values. $_REQUEST o arrays can be indexed by position or key value o Variables start with the character $ o To join (concatenate ) strings use the. (dot) operator Run

Form interface A common approach would be to provide an HTML form to allow the user to enter the parameters Form Form Current date Enter the weather site URL Notice that when the url is entered into the form, the browser url-encodes the special characters. Run

This will be constructed along the same lines as a Yahoo pipe, with functions in place of modules Yahoo pipe [Get data] >> [Parse CSV] >> [Compute new data] >> [create RSS] Weather pipe RSS feed Replacement

Handling the proxy server First we need to be able to fetch a data file. Because there is a proxy server at UWE and because we don't want it to cache the data (why?), we need a bit of magic. <?php function uwe_get_file($uri) { // get a file via UWE proxy and stop caching $context = stream_context_create( array('http'=> array('proxy'=>'proxysg.uwe.ac.uk:8080', 'header'=>'Cache-Control: no-cache' ) )); $contents = file_get_contents($uri,false,$context); return $contents; }; This defines a function which has one parameter, a uri and returns the file contents. This is reusable for any file we want to get via HTTP running on a BIT server.

Arrays The index values (keys) in PHP arrays are not restricted to integers. They may also be strings and other kinds of values. Similarly the value stored with a key can be any type of value - an integer, string or another array. key = "http" value = key = "proxy" value = 'proxysg.uwe.ac.uk:80' key = "header" value = 'Cache-Control: no- cache' Arrays are like Dictionaries in Java, hash or associative arrays in Perl.

Convert CSV string to an array of data Now lets call the function to get the remote data file: The current value of $rawdatafile is passed to the function and becomes the value of the parameter $uri inside it. $csv = uwe_get_file($rawdatafile); Now split the string on the space character to get an array of strings which we can access as an array. $data = explode(" ", $csv); Explode is a standard function in PHP - note the weird order of parameters - the separator character first!

Mapping the array indexes We could just refer to the array indexes as defined on the WDL documentation - $data[4] for temperature. A nicer way is to define some names for these numerical indexes define ('WINDSPEED',1); define ('WINDDIRECTION',3); define('TEMPERATURE',4); define('STATION',32); define('TIMEHH',29); define ('TIMEMM',30); define('SUMMARY',49); Now we can use the more readable form $data[TEMPERATURE] - note there is no $ prefix with constants

Generate the RSS Now we can generate the RSS XML. Here we have lots of data to interpolate into the RSS template and use a 'heredoc' with delimiter. Expressions are enclosed in { } print <<<EOT {$data[STATION]} {$site} Weather at {$data[TIMEHH]}:{$data[TIMEMM]} {$data[SUMMARY]}. Wind {$data[WINDSPEED"]} knots from {$data[WINDDIRECTION]} degrees. Temperature {$data[TEMPERATURE]} °C. EOT;

Mainline Finally the main program defines the overall processing using these functions. It is not a true pipeline because each step executes fully and puts its output in a temporary variable. Run Source

Common code The function to get a file via the proxy and will be used in any application which needs to access a web resource from within UWE. Similarly the code to define the structure of the wdl data will be used in any script which access that data. We can put these in two separate files (why two?) and then include them in the source of any program which needs this code with the require() statement: <?php require ("commonlib.php"); require("wdllib.php"); //main... Run Source

o interaction between a client-side form and server-side processing o variables and constants o functions transforming one or more inputs into an output o arrays with string keys as dictionaries or associative arrays o heredocs o setting a media-type o factoring out common code Concepts