Föredrag om dynamisk webbprogrammering
Kulturanatomen 2002-03-04
SSLUG & DF 2002-05-08
Linus Walleij (min 
hemsida).
Lite exempel som visades, exemplen gör inget anspråk på att vara lämpade för skarp drift, endast för test av principerna bakom CGI.
Serverside scripting/programming: samma CGI-script i olika språk
Unix BASH (test.sh):
#!/bin/sh
echo 'Content-type: text/html'
echo
echo '<html>'
echo ' <head>'
echo ' <title>Test Page</title>'
echo ' </head>'
echo ' <body>'
echo ' <h1>It Worked!</h1>'
echo '<p>'
echo $REMOTE_HOST
echo '</p>'
echo ' </body>'
echo '</html>'
Testa programmet
Perl (test.pl):
#!/usr/bin/perl -w
use strict;
print <<EOT;
Content-Type: text/html; charset=iso-8859-1
<html>
<head>
<title>Test Fnord</title>
</head>
<body>
<h1>It Worked!</h1>
<p>
EOT
print "$ENV{REMOTE_HOST}";
print <<EOT;
</p>
</body>
</html>
EOT
C:
int main(int argc,
         char *argv[])
{
  const char *host = (char *) getenv("REMOTE_HOST");
  printf("Content-Type: text/html\n\n");
  printf("<html>\n<head>\n<title>Test Fnord</title>\n</head>\n");
  printf("<body>\n<h1>It Worked!</h1>\n<p>\n");
  printf(host);
  printf("</p>\n</body>\n</html>\n");
}
Kompilera med gcc -o test.cgi test.c
Hypertextpreprocesorer:
Kända som:
- Server Side Includes (SSI)
 
- Cold Fusion
 
- ASP (Active Server Pages)
 
- PHP (Hypertext Preprocessor
 
- JSP (Java Server Pages)
 
- Frontpage Server Extensions
 
Server Side Includes (foo.shtml):
<html>
<head>
<title>Test Fnord</title>
</head>
<body>
<h1>It Worked!</h1>
<p>
<!--#echo var="REMOTE_HOST" -->
</p>
</body>
</html>
Testa programmet
Cold Fusion (foo.cfm):
<html>
<head>
<title>Test Fnord</title>
</head>
<body>
<h1>It Worked!</h1>
<p>
<cfoutput>#CGI.remote_host#</cfoutput>
</p>
</body>
</html>
ASP (foo.asp):
<html>
<head>
<title>Test Fnord</title>
</head>
<body>
<h1>It Worked!</h1>
<p>
<%
    Response.Write Request.ServerVariables("REMOTE_HOST")
%>
</p>
</body>
</html>
PHP (foo.php):
<html>
<head>
<title>Test Fnord</title>
</head>
<body>
<h1>It Worked!</h1>
<p>
<?php
    echo $_SERVER["REMOTE_HOST"]
?>
</p>
</body>
</html>
Testa programmet
Generellt rörande CGI-program och preprocessorer:
Vad gör CGI-program / hypertextpreprocessorer oftast?
- Skickar mail
 
- Läser/skriver till filer
 
- Läser/skriver till databaser, speciellt mha SQL
 
- Läser från andra webbresurser (ex DFs hemsida läser från AF:s "löpet")
 
- Genererar dynamiska bilder, grafer etc
 
- Tar emot filer "upload"
 
Roligt exempel på CGI-program:
http://www.elsewhere.org/cgi-bin/postmodern/ - tryck "Reload" några gånger. Förstasidan på min hemsida är också helt dynamisk (för att inte säga dadaistisk) vilket man ser om man kör "reload" ett par gånger.
Vad behöver man kunna för att skriva bra serverside-kod?
- Sin plattform: GNU/Linux, Solaris, Windows 2000, IBM 360
 
- Sin webbserver: Apache, Internet Information Server (IIS), iPlanet, Roxen
 
- Sitt script/programmeringsspråk: PHP, C, ASP, Python
 
- Sin databas (om man ska ha det): Oracle, MySQL, Microsoft SQL Server, PostgreSQL, MIMER
 
Vanliga kombinationer:
Windows 2000
Internet Information Server (IIS)
ASP (Active Server Pages)
Microsoft SQL Server
GNU/Linux eller Free/Open/NetBSD
Apache
PHP (Hypertext Preprocessor)
MySQL
IBM 360
Websphere
JSP
J2EE
Oracle
Clientside scripting/programming
JavaScript/JScript/ECMAscript exempel:
<html>
<head>
<title>10.000</title>
<script language="JavaScript">
<!--
function calculatedate()
{
        var strSplitme = (document.TheForm.fodelse.value);
        arrayOfStrings = strSplitme.split('-',3);
        var dtmFodd = new Date(arrayOfStrings[0],arrayOfStrings[1]-1,arrayOfStrings[2]);
        intMillis = dtmFodd.valueOf();
        intMillis = intMillis + (24*60*60*1000*10000);
        dtmFodd.setTime(intMillis);
        var intYear = dtmFodd.getFullYear();
        var intMonth = dtmFodd.getMonth()+1;
        var strMonth = new String(intMonth);
        if (strMonth.length<2) strMonth = '0'+strMonth;
        var intDay = dtmFodd.getDate();
        var strDay = new String(intDay);
        if (strDay.length<2) strDay = '0'+strDay;
        var strDate = 'All right du blir 10.000 dagar ';
        strDate = strDate+intYear+"-"+strMonth+"-"+strDay;
        alert(strDate);
}
//-->
</script>
</head>
<body>
<p>När blir jag 10.000 dagar?</p>
<form name="TheForm">
<input name="fodelse" type="text" size="10" value="1972-06-05">
<input type="button" onClick="calculatedate()" value="räkna din djävul">
</form>
</p>
</body>
</html>
Testa här:
När blir jag 10.000 dagar?
Skriv in ditt födelsedatum:
Fibonaccital:
function fibbonum(i)
{
        if (i == 0 || i == 1)
	    return 1;
	else
	    return fibbonum(i-1) + fibbonum(i-2);
}
function fibbostring()
{
        var x = "";
        for (i = 0; i < 16; i++)
	    x = x + fibbonum(i) + ", ";
	x += "....";
	alert(x);
}
Document Object Model (DOM)
Används för att lokalisera objekt i en webbsida så att de kan
processeras av Javascript/Jscript/ECMAscript.
Används också i Cascading Style Sheets (CSS) för att välja
vilka delar av markup:en man vill påverka.
I framtiden...
I framtiden vill vi skilja på form och innehåll och
därför vill vi använda XML för innehållet och XSL
för formen.
Redan idag kan vi använda HTML för innehållet och
CSS för formen om vi är noggranna.
Länkar jag tycker är bra att börja med:
    
    INTERNET DEVELOPMENT
    
        
HISTORICAL
        
            
- History of the Web
            
- History and growth
            
- A Little History of the World Wide Web
            
- Tim Berners-Lee: A short history of web development
            
- A Brief History of the Internet
            
- Michael Buckland's Paul Otlet Page
            
- Internets födelse 17 maj 1991
            
- Index of /History
        
        
        
HTTP
        
            
- HTTP - Hypertext Transfer Protocol Overview
            
- Libwww - the W3C Sample Code Library
            
- Libwww Ready to go Samples
            
- Index of /Library/src
            
- Forms in HTML documents
            
- Downloader Comparison Table
        
      
        
MIME
        
            
- IANA Home Page
            
- FTP for media types
            
- MIME References
            
- MIME (Multipurpose Internet Mail Extensions)
            
- The 8:th bit liberation movement!
            
- comp.mail.mime FAQ (frequently asked questions list)
            
- MIME media types
            
- Appendix A: MIME Type Detection in Internet Explorer
        
        
        
BROWSERS
        
            
- mozilla.org
            
- N E O P L A N E T
            
- NCSA Windows Mosaic Home Page
            
- Pages Enhanced for Lynx
        
    
        
CSS
        
            
- Cascading Style Sheets
            
- Browser Compatibility
            
- CSS Frequently Asked Questions - The HTML Writers Guild
            
- Cascading Style Sheets, level 1
            
- Cascading Style Sheets, Level 2
        
     
        
DHTML DOM etc
        
            
- Document Object Model (DOM) Level 1 Specification
            
- Document Object Model References
            
- SBN/SDK Merge Prototype
            
- Offline Browsing
        
    
        
CGI
        
            
- The Common Gateway Interface Specification
            
- Quick References to the Common Gateway Interface
            
- CGI Programming FAQ: INDEX
            
- Introduction to Object-Oriented Programming
            
- cgic: an ANSI C library for CGI Programming
            
- CGI.pm - a Perl5 CGI Library
            
- Index for HTML-specs
            
- An instantaneous introduction to CGI scripts and HTML forms, Academic Computing Services, University of Kansas
            
- Perl Tutorial
            
- CGI and other Environment Variables for the WN Server
        
          
        
ASP
        
            
COMponents
            
                
- ServerObjects Inc. Products
                
- VBAObjects
                
- Recordset
                
- SQL Tutorial
                
- SA-FileUp
                
- Database Access Component
                
- ASPFServ Component
                
- W3 JMAIL (tech.dimac.net)
                
- 15 Seconds : Component Products : ADSI
                
- CDOLive - Code Sample Library
                
- Windows Update: Active Directory Service Interfaces (ADSI) 2.5 : [Download, downloads, beta, Microsoft Active Directory Service Interfaces, ADSI, directory management, applications, Microsoft Visual Basic, Java, or C/C++]
            
           
            
ODBC/SQL ex
            
                
- ASP 101 - A Database Interfacing Primer
                
- Visual FoxPro Database Publishing
            
  
            
ASP apps
            
                
- JADA Productions Test Discussion Forum
            
 
            
- FAQ
            
- Roadmap
            
- .NET FAQ
            
- ZForum-ASPXchange
            
- Sample Active Server Pages
            
- ASP Developers Network
            
- Active Server Pages Technical Support Home Page
            
- Working with ASP
            
- Using/Learning ASP VBSCRIPT, ACTIVESERVER, ActiveX
            
- Best and Brightest Active Server Pages (ASP)
            
- PRB: ASP Fails to Access Network Files Under IIS 4.0
            
- 15 Seconds : ADO Section
            
- dbtroubleshoot ASP Quick Lessons
            
- activeserverpages.com The most popular ASP resource in the World
        
              
        
PHP
        
            
- PHP: PHP: Hypertext Preprocessor
            
- PHP3: Browser Capabilities Registry for PHP 3
            
- PHP: Frequently Asked Questions
            
- MySQL by T.c.X. DataKonsultAB
            
- Welcome to the Asp Tracker Home Page
            
- SourceForge: Project Info - PHP Client Sniffer
            
- Gallery
        
       
        
HTML
        
            
- HTML Home Page
            
- HTML 4.0 Working Draft Release
            
- Bare Bones Guide to HTML
            
- Colors
            
- Advanced HTML
            
- Introducing HTML 3.2
            
- Index for HTML-specs
            
- Mind Reading Markup Language (MRML)
            
- RTFtoHTML Version 4
            
Skräckexempel
                     
                
- LOCUS lokalbokningssystem vid Lunds Universitet
                
- web pages that suck -- web design, html, design, web pages
                
- Webbplatskritik - Autark Datakonsult AB
            
   
        
        
TCP/IP Sockets
        
            
- Programming UNIX Sockets in C - Frequently Asked Questions
            
- DHCP FAQ
        
  
        
XML
        
            
EMACS
            
                
- Mulberry Technologies -- tdtd Emacs Major Mode for SGML and XML DTDs
                
- A GNU Emacs mode for SGML files
            
  
            
Microsoft
            
                
- Microsoft XML Notepad
                
- XMLDOMDocument Object Members
                
- XMLDOMDocument Object
                
- MSDN Online Tools - XML Parser
            
    
            
- Extensible Markup Language (XML)
            
- James Clark's Home Page
            
- expat
            
- XML Sweden AB
            
- XML.com - XML Suite
            
- Frequently Asked Questions about the Extensible Markup Language
            
- Clean up your Web pages with HTML TIDY
            
- XML Resources
            
- Extensible Markup Language (XML)
            
- SGML/XML Sverige Ny II
            
- Public SGML/XML Software
            
- XMLGuiden
            
- Free XML software
            
- XHTML strict DTD
            
- Extensible Stylesheet Language (XSL)
            
- Using XSL for Structural Validation
            
- Declaring Elements and Attributes in an XML DTD
            
- Weird Scenes Inside The Goldmine
            
- XSL Transformations (XSLT)
            
- Whitehill Technologies - Products
            
- xmlTree - The only directory of XML content on the Web
            
- W3C XML Schema
        
                      
        
WAP / WML
        
            
- W3C: Mobile Access
            
- WAP Forum
            
- WAP Forum
            
- WAPman
            
- Wireless Application Protocol
            
- WebCab.de: Fetch Page
        
      
        
ETEXT
        
            
- Bookbooters: eBook formats explained
            
- Welcome to Project Runeberg
            
- Support for Windows CE (About Project Runeberg)
            
- Making of America
            
- PROJECT GUTENBERG OFFICIAL HOME SITE - INDEX
            
- rtf2latex2e Homepage
            
- RTF-Tools -- RTF software and documentation
            
- The web site of the UK TeX Users' Group
            
- ISO 8859 Alphabet Soup
            
- Unicode Home Page
            
- Unicode FAQ
            
- 
            
- Thomas Merz Consulting & Publishing
            
- Standards -- Electronic Text Center
            
- TEI Consortium
            
- ISO 639 Language Codes -- Electronic Text Center
            
- David Seaman. Guidelines for Text Mark-up at the Electronic Text Center, University of Virginia: Special Characters
            
- Get Going With DocBook
            
- Open eBook
            
- Free-ePress.com: Because you deserve to know what you're paying for.
            
- Jonas Webresurs/Webdesign/lang-attributet
            
- RTFtoHTML Version 4
            
- An attempt to map wingdings to existing unicode characters
            
- eGroups : rss-dev Files
            
- Slashdot | Microsoft Ebooks and Copy Protection
            
- RTF @ MSDN
            
- www.openoffice.org
            
- Microsoft Reader
            
- DjVuLibre: Open Source DjVu library and viewer
        
                             
        
IRC ICQ CHAT etc
        
            
- IrcW3 gateway help
            
- WWW-IRC GATEWAY HOMEPAGE
            
- iPulse
        
   
        
RFC o dyl
        
            
- IETF Home Page
            
- "Internet Society" (ISOC): Welcome Internet Society (ISOC) Web Site
            
- W3C - The World Wide Web Consortium
            
- Babel -- Internationalization of the Internet
            
- Request for Comments (RFC) Editor Homepage
            
- Current Internet-Drafts
            
- xml2rfc
        
       
        
LOOKUP FINGER etc
        
            
- Logfinger
            
- Finger Gateway
            
- NSLOOKUP Gateway
            
- InterNIC DNS Look Up Service
            
- RIPE NCC: Whois Queries
            
- Traceroute Gateway
            
- Multiple Traceroute Gateway
            
- Ping Gateway
            
- Ping Gateway
            
- Traceroute Gateways
            
- WHOIS | VeriSign
        
           
        
LDAP
        
            
- OpenLDAP, Title
        
 
        
MAIL
        
            
- Jari's Procmail index page
            
- Procmail FAQ
            
- The Spam Bouncer: a Procmail-Based Spam Filter
            
- Mail Abuse Prevention System
            
- 4.1. SMTP COMMANDS
            
- Outlook 97 Articles Available by Fax or E-Mail: Forms\Internet
            
- OL97: Forwarded Message Behaves Differently with Rules Wizard
            
- Microsoft BackOffice
        
        
        
WEBSERVRAR
        
            
Apache
            
                
- mod_ssl: The Apache Interface to OpenSSL
                
- The mod_mime_magic Module for Apache HTTPD
                
- CVS log for apache-2.0/conf/magic
                
- Apache CVS Repository
                
- Apache Project Development Site
                
- Apache URL Rewriting Guide
                
- Apache-SSL
                
- Apache Project
            
        
            
IIS
            
                
- http://www.microsoft.co...IS/Resources/online.htm
            
 
            
- The NCSA HTTPd Home Page
            
- Home of The Webalizer
            
- Microsoft Internet Information Server
            
- Roxen: Roxen Challenger - Best of Comdex Winner
            
- R M S: The Roxen Module Source
        
     
        
FTP
        
            
- WU-FTPD Development Group
            
- Official Shaolin Secure FTP Site
        
  
        
JAVA Script
        
            
- Determining Browser Type and Version with JavaScript
            
- JavaScript Reference
            
- JavaScript Guide 3.0
            
- NetscapeWorld - JavaScript - Customize users' experiences dynamically - March 1997
            
- Javascript Goodies (Resource Center)
            
- The Nasty JavaScript Tricks: Welcome
            
- The Nasty JavaScript Tricks: Finding Your Installed Plug-ins
        
       
        
PDF
        
            
- Project Cool Acrobat(R) Developer Zone
            
- Dynamic PDF
            
- Emerge - Solutions for the PDF Professional
            
- Thomas Merz Consulting & Publishing
            
- Q pdf dynamic writer
            
- Web Server Printing Toolkit
        
      
        
ISDN
        
            
- ISDN-tips, Ken Ehrsson (swedish version)
        
 
        
WEBDAV
        
            
- WebDAV Resources
        
 
        
Juridiska spetsfundigheter
        
            
- Svensk Lagsamling
            
- Patent- och registreringsverket skyddar patent, varumärken, mönster och namn
        
  
        
- Jonas Webresurs: Sveriges bästa webbskola! www.jonasweb.nu