internet technology and its applications

30
Internet Technology & its Applications Prof. Ami Tusharkant Choksi CKPCET, Surat.

Upload: amichoksi

Post on 26-May-2015

5.047 views

Category:

Technology


1 download

DESCRIPTION

A subject named "Internet Technology and its Applications" subject's introduction taught as part of B.E.IV (Computer), 8th semester students, VNSGU, Surat, Gujarat State, India.

TRANSCRIPT

Page 1: Internet Technology and its Applications

Internet Technology & its Applications

Prof. Ami Tusharkant ChoksiCKPCET, Surat.

Page 2: Internet Technology and its Applications

What is Internet Technology?

Technology with internet can provide applications, information for internet users.

First thing come to our minds with internet is web. i.e. www (world wide web)

Page 3: Internet Technology and its Applications

Applications integration of e-business models with front and

back office development of an intranet for your employees development of an extranet for your customers development of a web shop implementation of content management

systems e-mail marketing implementation of online payment systems

Page 4: Internet Technology and its Applications

History of World Wide Web[1]

“A global hypertext space is created in which any network-accessible information could be referred to by a single Universal Document Identifier which was later called WorldWideWeb, a point and click hypertext editor which ran on the NeXT machine”. - Tim Berners-Lee

Page 5: Internet Technology and its Applications

Requirements To run WWW Programs

HTML (HyperText Markup Language) URL (Universal Resource Locator) HTTP (Hyper Text Transfer Protocol) Web Server (Apache, Tomcat, GlassFish,

WebLogic, etc.) Web application programming languages (Pre

Hypertext Processor, Java Servlet, Java Server Pages, Common Gateway Interface/perl, Active Server Pages, JScipt/JavaScript, VBScript, eXtensible Markup Language)

Page 6: Internet Technology and its Applications

What's server side and client side progg. Languages?

Programs which runs on server is called server side progg.

Programs which runs on client is called client side progg.

Page 7: Internet Technology and its Applications

Server Side Progg. vs. Client Side Progg.

Server Side Progg. Programs which runs on

server Compiler/Interpreter for

programs needed at client

PHP, JSP, ASP, Java Servlet, CGI/perl etc.

Slower Applications:

Authentication, Authorization

Client Side Progg. Programs which runs on

client Compiler/Interpreter for

programs needed at client

JavaScript, Jscript, Vbscript, HTML, XML

Faster Applications: Validation

of forms done

Page 8: Internet Technology and its Applications

Pre Hypertext Processor

Opensource product

Form handling, file processing, and database access

Server side scripting language

PHP processor has two modes: copy (XHTML)

interpret (PHP)

Purely Interpreted

PHP can be used as

Server-side scripting

Command line scripting

Writing desktop applications

Page 9: Internet Technology and its Applications

Simple PHP Program (first.php)

<html>

<body>

<?php

echo “hi and welcome to the world of PHP”;

phpinfo();

?>

</body>

</html>

Page 10: Internet Technology and its Applications

Configure Apache For PHP

Page 11: Internet Technology and its Applications

/etc/httpd/conf/httpd.conf#Use for PHP 5.x:

LoadModule php5_module modules/libphp5.so

AddHandler php-script php

# Add index.php to your DirectoryIndex line:

DirectoryIndex index.html index.php

AddType text/html php

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

Add input/output filters (older versions of Apache, in new versions following code will give error of “an unknown filter was not added: PHP” )

<Files *.php>

SetOutputFilter PHP

SetInputFilter PHP

LimitRequestBody 9524288</Files>

Page 12: Internet Technology and its Applications

/etc/httpd/conf/httpd.conf If with user's home directory we want to

access

<IfModule mod_userdir.c>

#UserDir disabled

# To enable requests to /~user/ to serve the user's public_html

# directory, remove the "UserDir disabled" line above, and uncomment the following line instead: UserDir public_html

</IfModule>

Page 13: Internet Technology and its Applications

/etc/httpd/conf/httpd.conf<Directory /home/*/public_html>

AllowOverride FileInfo AuthConfig Limit

Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec

<Limit GET POST OPTIONS>

Order allow,deny

Allow from all

</Limit>

<LimitExcept GET POST OPTIONS>

Order deny,allow

Deny from all

</LimitExcept>

</Directory>

Page 14: Internet Technology and its Applications

Deploy program on webserver Restart apache web server

/etc/rc.d/init.d/httpd restart

OR Service httpd restart

Login as ami(user)

mkdir public_html

Put first.php in /home/ami/public_html dir

chmod -R o+rx /home/ami/*

chmod o+rx /home/ami

chmod o+rx /home

Check in browser

http://localhost/~ami/first.php

Page 15: Internet Technology and its Applications

If u have root previllages

• In /etc/httpd/conf/httpd.conf check for DocumentRoot

• Generally DocumentRoot is /var/www/html

• Put the first.php file in /var/www/html dir

• Set permission of first.php as o+rx

• Run in browser as http://localhost/first.php

Page 16: Internet Technology and its Applications

Comments in PHP

// this is a comment # shell script like comment /* C and java-like comments */

Page 17: Internet Technology and its Applications

Primitives, Operations, and Expressions

- No type declarations of variable

- Variable can be used as $var

- An unassigned (unbound) variable has the value, NULL

- The unset function sets a variable to NULL

- The IsSet function is used to determine whether a variable is NULL

- error_reporting(15); - prevents PHP from using unbound variables

- list predefined variables, including the environment variables of the host OS with phpinfo() in a script

Page 18: Internet Technology and its Applications

There are eight primitive types:

- Four scalar types: Boolean, integer, double, and string

- Two compound types: array and object

- Two special types: resource and NULL

- Integer & double are like those of other languages

- Strings

- Characters are single bytes

- String literals use single or double quotes

Page 19: Internet Technology and its Applications

- Single-quoted string literals (as in Perl)

- Embedded variables are NOT interpolated

- Embedded escape sequences are NOT recognized

- Double-quoted string literals (as in Perl)

- Embedded variables ARE interpolated

- Boolean - values are true and false (case insensitive)

- 0 and "" and "0" are false; others are true

Page 20: Internet Technology and its Applications

Operators

As in 'C' language e.g.+, -, *, /, % String Functions strlen, strcmp, strpos, substr, as in C

chop – remove whitespace from the right end

trim – remove whitespace from both ends

ltrim – remove whitespace from the left end

strtolower, strtoupper

Page 21: Internet Technology and its Applications

Type Conversion

$a = (int)$b; intval($total) settype($total, "integer") The type of a variable can be determined

with gettype or is_type

gettype($total) - it may return"unknown"

is_integer($total) – a predicate function

- echo/print/prinf used for print

Page 22: Internet Technology and its Applications

Control StatementsControl Expressions

- Relational operators - same as JavaScript,

(including === and !==)

- Boolean operators - same as Perl (two sets, &&

and and, etc.)

- Selection statements

- if, if-else, elseif

- switch - as in C

- The switch expression type must be integer,

double, or string

- while - just like C

- do-while - just like C

- for - just like C

Page 23: Internet Technology and its Applications

-foreach (array_expression as $value)

statement

foreach (array_expression as $key => $value)

statement

- break - in any for, foreach, while, do-while, or

switch

- continue - in any loop

- Alternative compound delimiters – more readability

if(...):

...

endif;

Page 24: Internet Technology and its Applications

Arrays An array in PHP is an ordered map. A map is a type that associates values to keys. list (vector), hash table (an implementation of a

map), dictionary, collection, stack, queue,etc. $arr = array(1, 2, 3, 4, 5);//simple list Can be accessed with foreach foreach ($arr as $i){

echo $i; }

Page 25: Internet Technology and its Applications

$arr = array(5 => 1, 12 => 2);//hash list

foreach ($arr as $key => $value) {

$colors[$key] = strtoupper($value);

} Sorting an array

sort($arr);

print_r($arr);

Page 26: Internet Technology and its Applications

Sorting Arrays

rsort - To sort the values of an array into reverse order

- ksort - To sort the elements of an array by the keys, maintaining the key/value relationships

e.g.,

$list("Fred" => 17, "Mary" => 21, "Bob" => 49, "Jill" => 28);

ksort($list);

// $list is now ("Bob" => 49, "Fred" => 17, "Jill" => 28, "Mary" => 21)

- krsort

- To sort the elements of an array by the keys into reverse order

Page 27: Internet Technology and its Applications

User Defined Functions

Syntactic form:

function function_name(formal_parameters) {

… }

- General Characteristics

- Functions need not be defined before they are called (in PHP 3, they must)

- Function overloading is not supported

- If you try to redefine a function, it is an error

- Functions can have a variable number of parameters

- Default parameter values are supported

- Function definitions can be nested

- Function names are NOT case sensitive

- The return function is used to return a value;

If there is no return, there is no returned value

Page 28: Internet Technology and its Applications

Example

<?php

$sum=add(15,20);

echo "sum : $sum <br>\n";

function add($no1,$no2)

{

return ($no1+$no2);

}

?>

Page 29: Internet Technology and its Applications

Form Handling

$_GET and $_POST variables $_GET[“varname”]; $_POST[“varname”];

Page 30: Internet Technology and its Applications

References[1] Tim Berners-Lee, “The World Wide Web: A very

short personal history”, http://www.w3.org/People/Berners-Lee/ShortHistory.html

[2] PHP manual, http://php.net/manual/en/index.php

[3] http://tinman.cs.gsu.edu/~raj/4998/sp06/mysql-php/w3_c12.ppt