alkalmaz s nat vheckenas/okt/webt2-2.pdf · a cgi m !k d se ¥http k r s a webszerverhez ¥get,...

18
CGI programok és az SSI 2 Webtechnológia 1I Alkalmazás natív webes interfésszel Hálózati kommunikációs protokoll/ interfész HTTP Humán interfész böngész!, HTML Nehézségek tartalom - megjelenítés teljesítmény stb. => használjunk önálló webréteget

Upload: others

Post on 24-May-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Alkalmaz s nat vheckenas/okt/webt2-2.pdf · A CGI m !k d se ¥HTTP k r s a webszerverhez ¥GET, POST ¥CGI let ciklus (single request) ¥ j process l trehoz sa a CGI sz m ra ¥a k

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

CGI programokés az SSI

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

2

Webtechnológia 1I

Alkalmazás natív webes interfésszel

• Hálózati kommunikációs protokoll/interfész

• HTTP

• Humán interfész

• böngész!, HTML

• Nehézségek

• tartalom - megjelenítés

• teljesítmény

• stb.

• => használjunk önálló webréteget

Page 2: Alkalmaz s nat vheckenas/okt/webt2-2.pdf · A CGI m !k d se ¥HTTP k r s a webszerverhez ¥GET, POST ¥CGI let ciklus (single request) ¥ j process l trehoz sa a CGI sz m ra ¥a k

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

3

Webtechnológia 1I

CGI

• Interfész specifikáció a webszerver és az általa elindított alkalmazás adat cseréjére

Browser

field Text Field

field Text Field

OK Cancel

Webserver Applicationsubmit form call CGI

CGI's response CGI's response

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

4

Webtechnológia 1I

CGI alkalmazások

• "rlapok (forms) feldolgozása

• interakció

• Gateway funkciók

• webes interfész

• Virtuális dokumentumok

• dinamikus tartalomDatabase

Browser

Browser

field Text Field

field Text Field

OK Cancel

CGI programweb gateway

receive

process

response

SQL

Webserver

result

request

Page 3: Alkalmaz s nat vheckenas/okt/webt2-2.pdf · A CGI m !k d se ¥HTTP k r s a webszerverhez ¥GET, POST ¥CGI let ciklus (single request) ¥ j process l trehoz sa a CGI sz m ra ¥a k

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

5

Webtechnológia 1I

A CGI m!ködése

• HTTP kérés a webszerverhez

• GET, POST

• CGI élet ciklus (single request)

• új process létrehozása a CGI számára

• a kérés paramétereinek elérhet!vé tétele a CGI számára

• szerver és op. rendszer függ!

• stdio, környezeti változók, stb.

• válasz vissza adása

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

6

Webtechnológia 1I

A szerver beállítása

• httpd, Apache

• szerver konfigurációs fájl (/etc/httpd/httpd.conf)

• ScriptAlias /cgi-bin/ "/Library/WebServer/CGI-Executables/"

Page 4: Alkalmaz s nat vheckenas/okt/webt2-2.pdf · A CGI m !k d se ¥HTTP k r s a webszerverhez ¥GET, POST ¥CGI let ciklus (single request) ¥ j process l trehoz sa a CGI sz m ra ¥a k

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

7

Webtechnológia 1I

CGI programozási környezetek

• CGI program ~ CGI script

• A script nyelvek megfelel!ek CGI-k írására

• jó szöveg manipulációs képességek

• együttm#ködés más programokkal

• CGI környezet elérése

• hordozhatóság

• de teljesítménykorlátok

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

8

Webtechnológia 1I

CGI programozási környezetek

• Szokásos CGI környezetek

• Shell scriptek (UNIX)

• Perl (UNIX, Mac OS, Windows)

• C

• AppleScript (Mac OS Classic, WebSTAR)

• Userland Frontier

Page 5: Alkalmaz s nat vheckenas/okt/webt2-2.pdf · A CGI m !k d se ¥HTTP k r s a webszerverhez ¥GET, POST ¥CGI let ciklus (single request) ¥ j process l trehoz sa a CGI sz m ra ¥a k

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

9

Webtechnológia 1I

Példa

#!/usr/bin/perlprint "Content-type: text/html\n\n";print "<HTML><BODY><H1>Hello, World!</H1></BODY><HTML>"

#!/usr/bin/perluse CGI qw(:all); # CGI.pm module is very useful!print header, start_html, h1("Hello, World!"), end_html;

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

10

Webtechnológia 1I

Az interfész

• Környezeti változókEnvironment Variable Description

GATEWAY_INTERFACE The revision of the Common Gateway Interface that the server uses.

SERVER_NAME The server's hostname or IP address.

SERVER_SOFTWARE The name and version of the server software that is answering the client request.

SERVER_PROTOCOL The name and revision of the information protocol the request came in with.

SERVER_PORT The port number of the host on which the server is running.

REQUEST_METHOD The method with which the information request was issued.

PATH_INFO Extra path information passed to a CGI program.

PATH_TRANSLATED The translated version of the path given by the variable PATH_INFO.

SCRIPT_NAME The virtual path (e.g., /cgi-bin/program.pl) of the script being executed.

DOCUMENT_ROOT The directory from which Web documents are served.

QUERY_STRING The query information passed to the program. It is appended to the URL with a "?".

REMOTE_HOST The remote hostname of the user making the request.

REMOTE_ADDR The remote IP address of the user making the request.

AUTH_TYPE The authentication method used to validate a user.

REMOTE_USER The authenticated name of the user.

REMOTE_IDENT The user making the request.

CONTENT_TYPE The MIME type of the query data, such as "text/html".

CONTENT_LENGTH The length of the data (in bytes or the number of characters) passed to the CGI program through standard input.

HTTP_FROM The email address of the user making the request. Most browsers do not support this variable.

HTTP_ACCEPT A list of the MIME types that the client can accept.

HTTP_USER_AGENT The browser the client is using to issue the request.

HTTP_REFERER The URL of the document that the client points to before accessing the CGI program.

Page 6: Alkalmaz s nat vheckenas/okt/webt2-2.pdf · A CGI m !k d se ¥HTTP k r s a webszerverhez ¥GET, POST ¥CGI let ciklus (single request) ¥ j process l trehoz sa a CGI sz m ra ¥a k

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

11

Webtechnológia 1I

Az interfész (folyt.)

• A form információ

• GET

• POST

• URL-encoded

• Content-Type: application/x-www-form-urlencoded

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

12

Webtechnológia 1I

Egy hasznos segédeszköz

• tcpflow

127.000.000.001.49284-127.000.000.001.00080: GET /cgi-bin/mult.cgi?m=5&n=7 HTTP/1.1Host: 127.0.0.1Connection: keep-aliveReferer: http://127.0.0.1/~heckenasttamas/mult.htmlUser-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/125.5.6 (KHTML, like Gecko) Safari/125.12If-Modified-Since: Sat, 26 Feb 2005 10:06:58 GMTAccept: */*Accept-Encoding: gzip, deflate;q=1.0, identity;q=0.5, *;q=0Accept-Language: en, ja;q=0.82, hu;q=0.93, fr;q=0.89, ja-jp;q=0.86, hu-hu;q=0.96, de-de;q=0.79, de;q=0.75, nl-nl;q=0.71, nl;q=0.68, es;q=0.64, it-it;q=0.61, it;q=0.57, sv-se;q=0.54, sv;q=0.50, no-no;q=0.46, no;q=0.43, da-dk;q=0.39, da;q=0.36

127.000.000.001.00080-127.000.000.001.49284: HTTP/1.1 200 OKDate: Sat, 26 Feb 2005 10:11:57 GMTServer: Apache/1.3.33 (Darwin)Keep-Alive: timeout=15, max=100Connection: Keep-AliveTransfer-Encoding: chunkedContent-Type: text/html;charset=iso-8859-1

93<HTML><HEAD><TITLE>Multiplication results</TITLE></HEAD><BODY><H3>Multiplication results</H3><P>The product of 5 and 7 is 35.</BODY></HTML>

0

Page 7: Alkalmaz s nat vheckenas/okt/webt2-2.pdf · A CGI m !k d se ¥HTTP k r s a webszerverhez ¥GET, POST ¥CGI let ciklus (single request) ¥ j process l trehoz sa a CGI sz m ra ¥a k

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

13

Webtechnológia 1I

HTTP kérés feldolgozása

• CGI felismerése

• elérési könyvtár meghatározása

• végrehajtási jog ellen!rzése a könyvtárra

• fájlrendszer végrehajtási jogok ellen!rzése (UNIX)

• környezeti változók beállítása

• process indítás

• CGI program kilépése után a tartalom kiszolgálás, a fejléc mez!k kiegészítése

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

14

Webtechnológia 1I

Egyszer! CGI példa

#!/usr/bin/perlprint "Content-type: text/html", "\n\n";print "<HTML>", "\n";print "<HEAD><TITLE>About this Server</TITLE></HEAD>", "\n";print "<BODY><H1>About this Server</H1>", "\n";print "<HR><PRE>";print "Server Name: ", $ENV{'SERVER_NAME'}, "\n";print "Running on Port: ", $ENV{'SERVER_PORT'}, "\n";print "Server Software: ", $ENV{'SERVER_SOFTWARE'}, "\n";print "Server Protocol: ", $ENV{'SERVER_PROTOCOL'}, "\n";print "CGI Revision: ", $ENV{'GATEWAY_INTERFACE'}, "\n";print "</PRE><HR>", "\n";print "</BODY></HTML>", "\n";

Page 8: Alkalmaz s nat vheckenas/okt/webt2-2.pdf · A CGI m !k d se ¥HTTP k r s a webszerverhez ¥GET, POST ¥CGI let ciklus (single request) ¥ j process l trehoz sa a CGI sz m ra ¥a k

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

15

Webtechnológia 1I

Form adatok feldolgozása

• Query string

• URL (GET)

• QUERY_STRING környezeti vált.

• Üzenet testben (POST)

• stdin

• CONTENT_LENGTH

• REQUEST_METHOD

• parser

• form mez!k

• URL encoded data

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

16

Webtechnológia 1I

URL encodedform data

• key-value pairs

• age=30

• & mez! szeparátor

• speciális karakterek hexa kóddal

• pl. Thanks%20for%20the%20help%21

• space +

Page 9: Alkalmaz s nat vheckenas/okt/webt2-2.pdf · A CGI m !k d se ¥HTTP k r s a webszerverhez ¥GET, POST ¥CGI let ciklus (single request) ¥ j process l trehoz sa a CGI sz m ra ¥a k

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

17

Webtechnológia 1I

Parzolás

• saját parser

• segéd könyvtár

• multi choice lists

@key_value_pairs = split (/&/, $query_string); foreach $key_value (@key_value_pairs) { ($key, $value) = split (/=/, $key_value); $value =~ tr/+/ /; $value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg;

if (defined($FORM_DATA{$key})) { $FORM_DATA{$key} = join ("\0", $FORM_DATA{$key}, $value);

} else { $FORM_DATA{$key} = $value;

}}

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

18

Webtechnológia 1I

Példák

#!/usr/bin/perluse CGI qw(:all); # CGI.pm module is very useful!my $q = new CGI; # create a new CGI objectmy $name = $q->param('name');print header, start_html, h1("Hello, $name!"), end_html;

Page 10: Alkalmaz s nat vheckenas/okt/webt2-2.pdf · A CGI m !k d se ¥HTTP k r s a webszerverhez ¥GET, POST ¥CGI let ciklus (single request) ¥ j process l trehoz sa a CGI sz m ra ¥a k

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

19

Webtechnológia 1I

Példák (folyt.)#!/usr/bin/perluse CGI qw(:all); # CGI.pm module is very useful!my $q = new CGI; # create a new CGI objectmy $name = $q->param('name');if ($name) { print header, start_html, h1("Hello, $name!"), end_html;} else { print header, h1("Enter name:"), start_form, textfield(-name=>"name"), br, submit, br, reset, end_form, end_html;}

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

20

Webtechnológia 1I

A CGI-k válasza

• A CGI által megadható HTTP headerek

Header Description

Content-length The length (in bytes) of the output stream. Implies binary data.

Content-type The MIME content type of the output stream.

ExpiresDate and time when the document is no longer valid and should be reloaded by the browser.

Location Server redirection (cannot be sent as part of a complete header).

Pragma Turns document caching on and off.

Status Status of the request (cannot be sent as part of a complete header).

Refresh Client reloads specified document.

Set-CookieClient stores specified data. Useful for keeping track of data between requests.

Page 11: Alkalmaz s nat vheckenas/okt/webt2-2.pdf · A CGI m !k d se ¥HTTP k r s a webszerverhez ¥GET, POST ¥CGI let ciklus (single request) ¥ j process l trehoz sa a CGI sz m ra ¥a k

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

21

Webtechnológia 1I

Teljes fejléc

• Részleges fejléc

• Teljes fejléc

• nph- prefix

Browser

Browser

field Text Field

field Text Field

OK CancelCGI programWebserver

request

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

22

Webtechnológia 1I

CGI programok C-ben

#include <stdio.h>

#include <stdlib.h>

int main(void)

{

char *data;

long m,n;

printf("%s%c%c\n",

"Content-Type:text/html;charset=iso-8859-1",13,10);

printf("<HTML>\n<HEAD>\n");

printf("<TITLE>Multiplication results</TITLE>\n</HEAD>\n<BODY>\n");

printf("<H3>Multiplication results</H3>\n");

data = getenv("QUERY_STRING");

if(data == NULL)

printf("<P>Error! Error in passing data from form to script.");

else if(sscanf(data,"m=%ld&n=%ld",&m,&n)!=2)

printf("<P>Error! Invalid data. Data must be numeric.");

else

printf("<P>The product of %ld and %ld is %ld.",m,n,m*n);

printf("</BODY>\n</HTML>\n");

return 0;

}

Page 12: Alkalmaz s nat vheckenas/okt/webt2-2.pdf · A CGI m !k d se ¥HTTP k r s a webszerverhez ¥GET, POST ¥CGI let ciklus (single request) ¥ j process l trehoz sa a CGI sz m ra ¥a k

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

23

Webtechnológia 1I

CGI programok C-ben (folyt.)

#include <stdio.h>

#include <stdlib.h>

#define MAXLEN 80

#define EXTRA 5

/* 4 for field name "data", 1 for "=" */

#define MAXINPUT MAXLEN+EXTRA+2

/* 1 for added line break, 1 for trailing NUL */

#define DATAFILE "../data/data.txt"

void unencode(char *src, char *last, char *dest)

{

for(; src != last; src++, dest++)

if(*src == '+')

*dest = ' ';

else if(*src == '%') {

int code;

if(sscanf(src+1, "%2x", &code) != 1) code = '?';

*dest = code;

src +=2; }

else

*dest = *src;

*dest = '\n';

*++dest = '\0';

}

int main(void)

{

char *lenstr;

char input[MAXINPUT], data[MAXINPUT];

long len;

printf("%s%c%c\n",

"Content-Type:text/html;charset=iso-8859-1",13,10);

printf("<HTML>\n<HEAD><TITLE>Response</TITLE>\n</HEAD>\n<BODY>\n");

lenstr = getenv("CONTENT_LENGTH");

if(lenstr == NULL || sscanf(lenstr,"%ld",&len)!=1 || len > MAXLEN)

printf("<P>Error in invocation - wrong FORM probably.");

else {

FILE *f;

fgets(input, len+1, stdin);

unencode(input+EXTRA, input+len, data);

f = fopen(DATAFILE, "a");

if(f == NULL)

printf("<P>Sorry, cannot store your data.");

else

fputs(data, f);

fclose(f);

printf("<P>Thank you! The following contribution of yours has \

been stored:<BR>%s",data);

}

printf("\n</BODY>\n,/HTML>");

return 0;

}

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

24

Webtechnológia 1I

CGI programok C-ben (folyt.)

#include <stdio.h>

#include <stdlib.h>

#define DATAFILE "../data/data.txt"

int main(void)

{

FILE *f = fopen(DATAFILE,"r");

int ch;

if(f == NULL) {

printf("%s%c%c\n",

"Content-Type:text/html;charset=iso-8859-1",13,10);

printf("<HTML>\n<HEAD>\n<TITLE>Failure</TITLE>\n</HEAD>\n");

printf("<BODY>\n<P><EM>Unable to open data file, sorry!</EM></BODY>\n</HTML>"); }

else {

printf("%s%c%c\n",

"Content-Type:text/plain;charset=iso-8859-1",13,10);

while((ch=getc(f)) != EOF)

putchar(ch);

fclose(f); }

return 0;

}

Page 13: Alkalmaz s nat vheckenas/okt/webt2-2.pdf · A CGI m !k d se ¥HTTP k r s a webszerverhez ¥GET, POST ¥CGI let ciklus (single request) ¥ j process l trehoz sa a CGI sz m ra ¥a k

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

25

Webtechnológia 1I

Multimédia tartalom

• CGI visszatérési értéke multimédia tartalom formátum

• segéd könyvtárak

• pl. GD

• küls! alkalmazások

• gnuplot

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

26

Webtechnológia 1I

Példák#!/usr/local/bin/perluse GD;print "Content-type: image/png\n\n"; # create a new image$im = new GD::Image(100,100);# allocate some colors$white = $im->colorAllocate(255,255,255);$black = $im->colorAllocate(0,0,0); $red = $im->colorAllocate(255,0,0); $blue = $im->colorAllocate(0,0,255);# make the background transparent and interlaced$im->transparent($white);$im->interlaced('true');# Put a black frame around the picture$im->rectangle(0,0,99,99,$black);# Draw a blue oval$im->arc(50,50,95,75,0,360,$blue);# And fill it with red$im->fill(50,50,$red);binmode STDOUT;# Convert the image to PNG and print it on standard outputprint $im->png;

Page 14: Alkalmaz s nat vheckenas/okt/webt2-2.pdf · A CGI m !k d se ¥HTTP k r s a webszerverhez ¥GET, POST ¥CGI let ciklus (single request) ¥ j process l trehoz sa a CGI sz m ra ¥a k

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

27

Webtechnológia 1I

Példák (folyt.)

#!/usr/bin/perl$gnuplot = "/usr/local/bin/gnuplot";print "Content-type: image/gif\n\n";open (GNUPLOT, "|$gnuplot");print GNUPLOT <<gnuplot_Commands_Done;set term gifplot sin(x)gnuplot_Commands_Doneclose (GNUPLOT);

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

28

Webtechnológia 1I

AppleScript + WebSTAR

property crlf : (ASCII character 13) & (ASCII character 10)

--this builds the normal HTTP header for regular accessproperty http_10_header : "HTTP/1.0 200 OK" & crlf & "Server: WebSTAR 3" & crlf & ¬

"MIME-Version: 1.0" & crlf & "Content-type: text/html" & crlf & crlf

on handle CGI request path_args ¬searching for http_search_args with posted data post_args using access method method from address client_address from user username

using password password with user info from_user from server server_name via port server_port executing by script_name of content type content_type referred by referer from browser user_agent of action type action using action action_path from client IP address client_ip with full request full_request

--This is WEIRD syntax. What it really means is that you have the variables-- path_args, http_search_args, client_address, username, password, etc. to play with.-- They are all strings.

try --wrap the whole script in an error handlerreturn http_10_header & "<title>Test CGI</title><h2>Test CGI</h2><u>CGI arguments sent:</u>" & ¬

"<br><b>path:</b> " & path_args & ¬"<br><b>search:</b> " & http_search_args & ¬"<br><b>post_args:</b> " & post_args & ¬"<br><b>method:</b> " & method & ¬"<br><b>address:</b> " & client_address & ¬"<br><b>user:</b> " & username & ¬"<br><b>password:</b> " & password & ¬"<br><b>from:</b> " & from_user & ¬"<br><b>server_name:</b> " & server_name & ¬"<br><b>server_port:</b> " & server_port & ¬"<br><b>script_name:</b> " & script_name & ¬"<br><b>referer:</b> " & referer & ¬"<br><b>user agent:</b> " & user_agent & ¬"<br><b>content_type:</b> " & content_type & ¬"<br><b>action:</b> " & action & ¬"<br><b>action_path:</b> " & action_path & ¬"<br><b>client_ip:</b> " & client_ip & ¬"<br><b>full_request:</b><pre> " & full_request & "</pre>" & crlf

on error msg number num --report the error message and number to the WWW clientreturn http_10_header & "Error " & num & ", " & msg

end tryend handle CGI request

Page 15: Alkalmaz s nat vheckenas/okt/webt2-2.pdf · A CGI m !k d se ¥HTTP k r s a webszerverhez ¥GET, POST ¥CGI let ciklus (single request) ¥ j process l trehoz sa a CGI sz m ra ¥a k

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

29

Webtechnológia 1I

UserlandFrontier

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

30

Webtechnológia 1I

SSI

• szerver által kiértékelt html fájl

Browser

Browser

field Text Field

field Text Field

OK Cancel

CGI program

Webserver

request

html w/ssi

SSI processing

virtual include

response

Page 16: Alkalmaz s nat vheckenas/okt/webt2-2.pdf · A CGI m !k d se ¥HTTP k r s a webszerverhez ¥GET, POST ¥CGI let ciklus (single request) ¥ j process l trehoz sa a CGI sz m ra ¥a k

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

31

Webtechnológia 1I

Browser side include

• korai html

• img

• jelenleg

• frame

• iframe

• javasript

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

32

Webtechnológia 1I

Szerver beállítások

• szerver konfigurációs fájl (/etc/httpd/httpd.conf)

• Directory

• Options ..... Includes

• IncludesNoExec

• AddType text/html .shtml

• AddHandler server-parsed .shtml

Page 17: Alkalmaz s nat vheckenas/okt/webt2-2.pdf · A CGI m !k d se ¥HTTP k r s a webszerverhez ¥GET, POST ¥CGI let ciklus (single request) ¥ j process l trehoz sa a CGI sz m ra ¥a k

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

33

Webtechnológia 1I

SSI beágyazások

Command Parameter Description

echo varInserts value of special SSI variables as well as other environment variables

include Inserts text of document into current file

file Pathname relative to current directory

virtual Virtual path to a document on the server

fsize file Inserts the size of a specified file

flastmod fileInserts the last modification date and time for a specified file

execExecutes external programs and inserts output in current document

cmd Any application on the host

cgi CGI program

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

34

Webtechnológia 1I

SSI változók

Environment Variable Description

DOCUMENT_NAME The current file

DOCUMENT_URI Virtual path to the file

QUERY_STRING_UNESCAPEDUndecoded query string with all shell

metacharacters escaped with "\"

DATE_LOCAL Current date and time in the local time zone

DATE_GMT Current date and time in GMT

LAST_MODIFIED Last modification date and time for current file

Page 18: Alkalmaz s nat vheckenas/okt/webt2-2.pdf · A CGI m !k d se ¥HTTP k r s a webszerverhez ¥GET, POST ¥CGI let ciklus (single request) ¥ j process l trehoz sa a CGI sz m ra ¥a k

THEINTERNET,mapped on the opposite page, is a scale-free network in that

some siteS (starbursts and detail above) have a seemingly unlimitednumber of connections to other sites. This map, made on February 6, 2003,

traces the shortest routes from atest WebsinHo about 100,000 others,

using like colors for similar Webaddresses.

a -

Scientistshaverecentlydiscoveredthat variouscomplexsystemshave

antlnderlyihg~..'~tJ;i~e~tu"eg~Ye'l"rne(;lb9.$haredorganili ngprincipies.

Thisinsighthas important impli~ationsfor a hostof

applications,fromdrugdevelopmentto Internetsecurity

BYALBERT-U\SZLOBARABASIANDERICBONABEAU

50 SCIENTIFIC AMERICAN MAY 2003

35

Webtechnológia 1I

Példa

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN"><html>

<head>

<title>SSI test</title></head><body><!--#exec cgi="/cgi-bin/ssitest.cgi"--><!--#echo var="DATE_LOCAL"--><br><!--#include virtual="ssit.txt"-->

</body></html>