Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets...

125
SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 1 Author: A. Balogh Internet HTML / PHP / CGI / VB / VBS / JavaScript … © Copyright 2019 Document name: SW HTML_PHP_CGI_JS_VBS-Syntax.docx Last update: 08.03.2019 Autor: A. Balogh Inhaltsverzeichnis: HTML ................................................................................................................................................................................ 5 HTML: EINFÜHRUNG ...................................................................................................................................................... 5 HTML: VERSIONEN ........................................................................................................................................................ 5 HTML: LINKS ................................................................................................................................................................. 5 HTML: PFADANGABEN ................................................................................................................................................... 5 HTML: GRUNDSTRUKTUR .............................................................................................................................................. 6 HTML: BEFEHLE ............................................................................................................................................................ 7 HTML: EXAMPLES ........................................................................................................................................................ 10 HTML: DYNAMISCHES ( DHTML ) .............................................................................................................................. 13 HTML: VERTIKAL ZENTRIEREN.................................................................................................................................... 14 HTML: AUTOMATISCHE WEITERLEITUNG .................................................................................................................... 14 PERSONAL HOMEPAGE ( PHP ) .............................................................................................................................. 15 PHP: EINFÜHRUNG........................................................................................................................................................ 15 PHP: SICHERHEIT .......................................................................................................................................................... 15 PHP: LINKS ................................................................................................................................................................... 15 PHP: PHP.INI ............................................................................................................................................................... 15 PHP: FEHLERSUCHE/DEBUGGING.................................................................................................................................. 16 PHP: COOKIES............................................................................................................................................................... 16 PHP: SYNTAX................................................................................................................................................................ 16 PHP: FUNKTIONEN ........................................................................................................................................................ 21 PHP: KLASSEN .............................................................................................................................................................. 28 PHP: FUNCTION ............................................................................................................................................................ 29 PHP: FASTTEMPLATE.................................................................................................................................................... 29 PHP: GRAFIKEN/CHARTS .............................................................................................................................................. 30 PHP: DB-LESEN............................................................................................................................................................ 31 PHP: BEISPIELE ............................................................................................................................................................. 32 PHP: PROGRAMMIERTECHNIKEN................................................................................................................................... 42 PHP: TOOLS ................................................................................................................................................................ 42 PHP-Coder ............................................................................................................................................................... 42 PHP-NUKE .............................................................................................................................................................. 42 WDDX .......................................................................................................................................................................... 42 SMARTY ......................................................................................................................................................................... 44 SMARTY: REQUIREMENTS........................................................................................................................................... 44 SMARTY: LIBRARIES / FILES ....................................................................................................................................... 44

Transcript of Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets...

Page 1: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 1 Author: A. Balogh

Internet HTML / PHP / CGI / VB /

VBS / JavaScript …

© Copyright 2019

Document name: SW HTML_PHP_CGI_JS_VBS-Syntax.docx Last update: 08.03.2019 Autor: A. Balogh

Inhaltsverzeichnis:

HTML ................................................................................................................................................................................ 5

HTML: EINFÜHRUNG ...................................................................................................................................................... 5 HTML: VERSIONEN ........................................................................................................................................................ 5 HTML: LINKS ................................................................................................................................................................. 5 HTML: PFADANGABEN ................................................................................................................................................... 5 HTML: GRUNDSTRUKTUR .............................................................................................................................................. 6 HTML: BEFEHLE ............................................................................................................................................................ 7 HTML: EXAMPLES ........................................................................................................................................................ 10 HTML: DYNAMISCHES ( DHTML ) .............................................................................................................................. 13 HTML: VERTIKAL ZENTRIEREN .................................................................................................................................... 14 HTML: AUTOMATISCHE WEITERLEITUNG .................................................................................................................... 14

PERSONAL HOMEPAGE ( PHP ) .............................................................................................................................. 15

PHP: EINFÜHRUNG ........................................................................................................................................................ 15 PHP: SICHERHEIT .......................................................................................................................................................... 15 PHP: LINKS ................................................................................................................................................................... 15 PHP: PHP.INI ............................................................................................................................................................... 15 PHP: FEHLERSUCHE/DEBUGGING.................................................................................................................................. 16 PHP: COOKIES ............................................................................................................................................................... 16 PHP: SYNTAX ................................................................................................................................................................ 16 PHP: FUNKTIONEN ........................................................................................................................................................ 21 PHP: KLASSEN .............................................................................................................................................................. 28 PHP: FUNCTION ............................................................................................................................................................ 29 PHP: FASTTEMPLATE .................................................................................................................................................... 29 PHP: GRAFIKEN/CHARTS .............................................................................................................................................. 30 PHP: DB-LESEN ............................................................................................................................................................ 31 PHP: BEISPIELE ............................................................................................................................................................. 32 PHP: PROGRAMMIERTECHNIKEN ................................................................................................................................... 42 PHP: TOOLS ................................................................................................................................................................ 42

PHP-Coder ............................................................................................................................................................... 42 PHP-NUKE .............................................................................................................................................................. 42

WDDX .......................................................................................................................................................................... 42

SMARTY ......................................................................................................................................................................... 44

SMARTY: REQUIREMENTS ........................................................................................................................................... 44 SMARTY: LIBRARIES / FILES ....................................................................................................................................... 44

Page 2: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 2 Author: A. Balogh

SMARTY: FILE PERMISSIONS ....................................................................................................................................... 44 SMARTY: SETUP........................................................................................................................................................ 44

Basic ......................................................................................................................................................................... 44 Index.php .............................................................................................................................................................. 44

Extended ................................................................................................................................................................... 45 Index.php .............................................................................................................................................................. 45 Setup.php .............................................................................................................................................................. 45

SMARTY: SYNTAX .................................................................................................................................................... 45 SMARTY: DEBUGGING ............................................................................................................................................ 46 SMARTY: EXAMPLES ............................................................................................................................................... 46 BEISPIELE ................................................................................................................................................................... 47

PEAR ............................................................................................................................................................................... 48

JAVA ............................................................................................................................................................................... 49

JAVA: EINFÜHRUNG ..................................................................................................................................................... 49 JAVA: IDE'S ................................................................................................................................................................. 49

JAVASCRIPT ( JS ) ....................................................................................................................................................... 50

JS: EINFÜHRUNG ........................................................................................................................................................... 50 JS: VERSIONEN .............................................................................................................................................................. 50 JS: LINKS ....................................................................................................................................................................... 50 JS: EVENTHANDLER ...................................................................................................................................................... 51 JS: OBJEKTE .................................................................................................................................................................. 53

JS: Document Object Model (DOM) ........................................................................................................................ 53 JS: SYNTAX ................................................................................................................................................................... 56 JS: BEISPIELE ................................................................................................................................................................ 62 JS: WIE KANN ICH JS-FUNKTIONEN AUS PHP HERAUS AUFRUFEN? ............................................................................... 67 JS: TOOL "HIERMENU" ................................................................................................................................................ 69

VISUAL BASIC SCRIPT ( VBSCRIPT / VBS ) .......................................................................................................... 74

MYSQL ........................................................................................................................................................................... 75

MYSQL: EINFÜHRUNG .................................................................................................................................................. 75 MYSQL: FILES: ............................................................................................................................................................. 75 MYSQL: LIZENZIERUNG ............................................................................................................................................... 75 MYSQL: KAPAZITÄT .................................................................................................................................................... 75 MYSQL: LINKS ............................................................................................................................................................. 75 MYSQL: TOOLS ............................................................................................................................................................ 75 MYSQL: COMMANDS MYSQL-MONITOR (MYSQL.EXE) ............................................................................................ 75 MYSQL: MYSQLADMIN.EXE ....................................................................................................................................... 76 MYSQL: MYODBC ...................................................................................................................................................... 77 MYSQL: PHPMYADMIN ................................................................................................................................................ 77 MYSQL: WINMYSQLADMIN ........................................................................................................................................ 78 MYSQL: API FUNKTIONEN ........................................................................................................................................... 78 BENUTZERVERWALTUNG ............................................................................................................................................... 79 STARTEN/STOPEN .......................................................................................................................................................... 79 MYSQL: DATENTYPEN ................................................................................................................................................. 79 MYSQL: SYNTAX .......................................................................................................................................................... 80

MySQL: CREATE / DROP TABLE ........................................................................................................................... 81 SQL: INSERT Examples ........................................................................................................................................... 81

MYSQL: BACKUP/RESTORE .......................................................................................................................................... 82 MYSQL: ERROR CODES ................................................................................................................................................ 82

MASSEINHEITEN......................................................................................................................................................... 83

FARBEN .......................................................................................................................................................................... 83

KN-FARBEN .................................................................................................................................................................. 89

MIME-TYPE'S ............................................................................................................................................................... 90

HEADER FIELD DEFINITIONS ........................................................................................................................................... 90

FEHLERMELDUNGEN ............................................................................................................................................... 90

COMMON GATEWAY INTERFACE ( CGI ) ........................................................................................................... 91

Page 3: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 3 Author: A. Balogh

CGI: EINFÜHRUNG .................................................................................................................................................... 91 CGI: TASTATURKOMBINATIONEN ................................................................................................................................. 91 CGI: DEBUGGEN ........................................................................................................................................................... 91 CGI: TEST-SCRIPT ..................................................................................................................................................... 92 CGI: VERZEICHNISSTRUKTUR ....................................................................................................................................... 92 CGI: UMGEBUNGSVARIABLEN ...................................................................................................................................... 92 CGI: E-MAIL NACHRICHTEN ......................................................................................................................................... 92

CGI: sendmail ........................................................................................................................................................... 93 CGI: SHELL-SKRIPTEN .................................................................................................................................................. 93 CGI: SYNTAX ............................................................................................................................................................. 93 CGI-BIN ORDNER.......................................................................................................................................................... 97

CGI: Wie verwende ich meine eigenen CGI-Programme? ....................................................................................... 99 CGIEMAIL von IPS ................................................................................................................................................ 100 FORMMAIL von IPS .............................................................................................................................................. 101 FORMMAIL Version 1.9......................................................................................................................................... 102

SKRIPTINTERPRETER ............................................................................................................................................. 103

PERL ( PL ) ................................................................................................................................................................. 103 PL: Einführung ....................................................................................................................................................... 103

PL: Datenbankzugriff ......................................................................................................................................... 103 PL: Syntax ............................................................................................................................................................... 103 Filehandling ............................................................................................................................................................ 104

TCL ............................................................................................................................................................................. 104 PYTHON ....................................................................................................................................................................... 104 REXX ......................................................................................................................................................................... 104 SERVERSEITIGE INCLUDES ( SSI & XSSI ) ................................................................................................................... 104 NPH-SKRIPTEN ........................................................................................................................................................... 104 C ................................................................................................................................................................................. 105

CGI: BEISPIELE ......................................................................................................................................................... 106

CGI: HOMEPAGES ....................................................................................................................................................... 106 CGI: SEARCH.HTML .................................................................................................................................................... 106 CGI: EINKAUFSKORB .................................................................................................................................................. 106 CGI: DATENBANKBEARBEITUNG ................................................................................................................................. 106 CGI: NACHRICHTENBRETT .......................................................................................................................................... 107 CGI: SITZUNGSVERWALTUNG ..................................................................................................................................... 107 CGI: COOKIES ............................................................................................................................................................. 107 CGI: FLATFILES .......................................................................................................................................................... 108

CGI: FlatFile read record ...................................................................................................................................... 108 CGI: FlatFile insert record .................................................................................................................................... 108 CGI: FlatFile delete record .................................................................................................................................... 109 CGI: FlatFile modify record ................................................................................................................................... 110

INTERNET INFORMATION SERVER ( IIS ) ......................................................................................................... 111

WEB-APPLIKATIONSPLATTFORMEN ................................................................................................................ 112

ACTIVE SERVER PAGES ( ASP ) ................................................................................................................................... 112 ALLAIRE COLDFUSION ................................................................................................................................................ 112 APACHE ....................................................................................................................................................................... 112 SERVERSEITIGES JAVA................................................................................................................................................. 112 NSAPI / ISAPI ............................................................................................................................................................ 113

FRONTPAGE SERVERERWEITERUNG ............................................................................................................... 113

MICROSOFT MANAGEMENT-KONSOLE ........................................................................................................................ 113

IPS INTERNET SERVICE PROVIDER ................................................................................................................... 114

PHP BEFEHLE .............................................................................................................................................................. 114 ZUGRIFFSZÄHLER / COUNTER ...................................................................................................................................... 115

GNU MAKE .................................................................................................................................................................. 116

WHAT IS GNU MAKE? ................................................................................................................................................ 116 Capabilities of Make ............................................................................................................................................... 116 Make Rules and Targets ......................................................................................................................................... 116

Page 4: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 4 Author: A. Balogh

ADVANTAGES OF GNU MAKE ..................................................................................................................................... 117 ABOUT GNU MAKE .................................................................................................................................................... 117

Makefiles And Conventions ............................................................................................................................... 117

CASCADING STYLE SHEET ( CSS ) ....................................................................................................................... 118

INTRODUCTION ............................................................................................................................................................ 118 W3 CONSORTIUM ........................................................................................................................................................ 118 VERSIONEN.................................................................................................................................................................. 118 ALLGEMEIN ................................................................................................................................................................. 118 LINKS .......................................................................................................................................................................... 118 TIP .............................................................................................................................................................................. 118 EINBINDEN .................................................................................................................................................................. 118

Extern .................................................................................................................................................................. 118 Intern ................................................................................................................................................................... 119

SYNTAX .................................................................................................................................................................... 119 @ ............................................................................................................................................................................ 119 A .............................................................................................................................................................................. 119

FARBEN/COLOR ........................................................................................................................................................... 121 SCHRIFTARTEN ............................................................................................................................................................ 121 SCHRIFTQUELLE .......................................................................................................................................................... 122 PSEUDO-FORMATE ...................................................................................................................................................... 122 MEDIENTYPEN @MEDIA .............................................................................................................................................. 122 ZENTRALE STANDARD CSS ......................................................................................................................................... 123

css_a1.css ............................................................................................................................................................... 123 TABELLEN ................................................................................................................................................................... 123

DOCUMENT OBJECT MODEL ( DOM ) ................................................................................................................ 123

REMOTE DATA SERVICE (RDS) ............................................................................................................................ 124

ABKÜRZUNGEN ......................................................................................................................................................... 125

Page 5: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 5 Author: A. Balogh

HTML

HTML: Einführung WWW-Consortium http://www.w3.org/ Ist ein sogenanntes Klartextformat. HT steht für Hypertext Besteht grundsätzlich aus zwei Teilen: Header und Body W3-Konsortium = Normierung der WWW-Technologie

HTML: Versionen HTML 1.0 HTML 2.0 Nov. 1995 HTML 3.2 14.1 1997 HTML 4.0 18.2.1998 Applets Java-Programme ActiveX Microsoft CGI-Programme / - Scripts Common Gateway Interface Möglichkeit Programme im WWW bereitzustellen. Datenverarbeitung geschieht auf dem Server-Rechner z.B. Zähler Besucher CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw. Frames Mehrfenstertechnik Java / -Script / JScript Von "Sun Microsystems" erfundene Script-Sprache. Lehnt sich an C/C++ an. Von Netscape lizenziert Perl Skriptsprache SGML Die "Mutter" aller Auszeichnungssprachen VRML Virtual Reality Modeling Language Für 3D im WWW .wrl XML Eigene neue Srachen definieren (z.B. Channel Definition Format "CDF") z.B. Corporate-Language definieren XSL

HTML: Links CWAK-Mailservice: www.mail-service.cwak.com

HTML: Pfadangaben / Der erste Schrägstrich hinter dem Basis-URI steht für das Wurzelverzeichnis des jeweiligen Internet-

Services. Es handelt sich meistens nicht um das tatsächliche Wurzelverzeichnis des Rechners oder der Festplatte, auf die Sie da zugreifen. Bei Web-Servern ist beispielsweise einstellbar, welches tatsächliche Verzeichnis dem Web-Wurzelverzeichnis entsprechen soll.

./ aktuelles Verzeichnis referenzieren ../ referenzieren Sie das Verzeichnis über dem aktuellen Verzeichnis, egal wie es heißt. ../../ referenzieren Sie das Verzeichnis über dem Verzeichnis über dem aktuellen Verzeichnis usw. Von

jedem der so adressierten Verzeichnisse können Sie wieder auf deren Unterverzeichnisse zugreifen, wie im letzten der obigen Beispiele gezeigt.

Page 6: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 6 Author: A. Balogh

HTML: Grundstruktur <html>

<head>

<title>Titel des HTML-Dokumentes (in Browser Fensterleiste)</title>

<meta name=... Meta Tags

<STYLE>… CSS Hier einbinden

<script language="JavaScript">… JavaScript

</head

<body>

Text, Verweise, Grafikreferenzen usw.

...

</body>

</html>

Page 7: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 7 Author: A. Balogh

HTML: Befehle Hinweise: Im HTML-Code sind keine Tabulatoren vorgesehen, benutzen sie stattdessen Style-Sheets Mehrere Leerzeichen hintereinander werden vom WWW-Browser ignoriert. Um Leerzeichen

zu erzwingen verwenden Sie die Zeichenfolge &#160 (geschütztes Leerzeichen) <!-- Kommentar --> Anfang / Ende Kommentar

&#160; Geschützes Leerzeichen ( $nbsp, chr(160))

&amp Zeichen &

&Auml Zeichen Ä

&auml Zeichen ä

&Ouml Zeichen Ö

&ouml Zeichen ö

&Uuml Zeichen Ü

&uuml Zeichen ü

&szlig Zeichen ß &lt Zeichen <

&gt Zeichen >

-- A -- <a href="x.html" ... >Linkbezeichnung </a>

...

tabindex=1

target="_blank" Startet die Seite in einem neuen Browserfenster

target="_parent"

target="_top"

rev="contents"

rev="chapter"

rel="next"

rel="prev"

rev="contents"

-- B -- <b>…</b> Bold

<big>…</big> Text Grösser

<blink>Text blinkt<7blink> Text blinkt

<bgsound src="datei.wav" loop=-1>

<br> Zeilenumbruch

<body>....</body> Start/End Bildschirmausgabe

topmargin

leftmargin

bgcolor

background="imags/bckgd.gif"

bgproperties="fixed"

text

link

vlink

alink

cellpadding Rand

class= Style-Sheet-Klasse

-- C -- <cite> Darstellung von Zitaten

<code> Programmcode

-- D -- <dir>…</dir> Verzeichnisliste

<li>...</li> Elemente

<div>...</div> Bereich mit mehreren Elementen formatieren

<div style="border:5mm groove #ff00ff;

position:absolute¦relative¦fixed;

align=left¦center¦right¦justify;

color:#FF00FF;

">

</div>

<dl>…</dl> Definitionsliste

<dd>…</dd>

Page 8: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 8 Author: A. Balogh

-- E -- <EM> Hervorgehoben, wird dargestellt durch Schrägschrift

<embed> VRML-Dokument

<!-- Netscape: -->

<embed src="background.mid" autostart="true" loop="true" hidden="true" height="0" width="0"> <embed src="liquida.xls">

<embed type="application/x-mplayer2"

pluginspage=http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer/>

-- F -- <font face=name> Schriftart festlegen

<font size=X> 1-7 (recommended 3,4)

<form></from> Formular

Das <FORM> Tag wird verwendet um eine Formular auf

einer Web-Seite anzulegen und um zu kennzeichnen,

dass die darin enthaltenen Felder alle zu demselben

Formular gehören.

Forms koennen nicht "gezielt" verschachtelt werden

<frameset …>…</frameset>

-- H -- <head>…</head> Titel des HTML-Dokumentes

<html>..</html> Start/End of HTML-File max 400 Zeichen !

<hX>X =1-6</hX> Überschriften

<hr> Horizontal Rule

-- I -- <i></i> Kursiv

id= Eindeutiger name im Dokument

lang="de" Language Deutsch

mailto: http-Keyword

<a href="mailto:[email protected]">Hans Muster, hans muster</a>

Trick: Email Adresse in Unicode-Format schreiben

<a href="mailto:[email protected]?subject=xxx ">Mail mit Subject</a></p>

-- L -- <link rel="alternate" type="application/rss+xml"

title="RSS" href="http://www.example.net/feed.rss" />

-- M -- <marquee>…Laufschrift</marquee> Laufschrift (ActiveX) nur Explorer!

<marquee scrollamount="50" scrolldelay="5">Text</marquee>

<marquee behavior="alternate"> Text</marquee>

direction="right¦left"

bgcolor=

<menu>…</menu> Menüliste

<li>...</li> Elemente

<meta name="author" content="A1 Information Technology, (www.a1-it.ch)">

<meta name="keywords" content=" Suchwort, ........ ">

<meta name="description" content="........., .........">

Dieser Text erscheint als Text bei einer Suche in

den Suchmaschinen.

Empfehlung nur auf Startseiten verwenden.

<meta name="robots" content="index, follow">

Weist den Robot an, sämtlichen Links zu folgen. So

werden nach und nach alle Ihre Seiten in den

Suchindex aufgenommen, ohne das Sie etwas dafür tun

müssen.

<meta name="revisit-after" content="30 days">

Sorgt dafür, daß der untersuchende Spider nach 30

Tagen zu Ihren Seiten zurückkehrt und diese neu

einliest. Funktioniert in der Praxis leider nur sehr

selten.

<meta name="publisher" content="A. Balogh">

Page 9: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 9 Author: A. Balogh

<meta name="copyright" content="A1 Information Technology ® 2003">

Verewigen Sie den Namen des Herausgebers und das

Copyright.

-- O -- <object >..</object>

<object "classid=clsid:663C8FEF-1EF9-11CF-A3-DB-080036F12502" data="CLOCK.STM"

codebase="http://www.acme.com/ole/">

/* Beispiel Flasplayer 6.0 einbinden

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"

codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0

,29,0" width="550" height="400">

<param name="movie" value="1.swf">

<param name="quality" value="high"><param name="LOOP" value="false">

<embed src="1.swf" width="550" height="400" loop="false" quality="high"

pluginspage="http://www.macromedia.com/go/getflashplayer"

type="application/x-shockwave-flash">

</embed></object>

<Embed

pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/"

filename="/sound/goodtime.mpg"

src="/sound/goodtime.mpg"

Name=NSPLay

ShowControls=0

ShowDisplay=0

ShowStatusBar=0

width=320

height=240

</embed>

<object>

<EMBED TYPE="application/x-mplayer2"

PLUGINSPAGE="http://microsoft.com/windows/mediaplayer/en/download/"

ID="MediaPlayer1NS" NAME="MediaPlayer1NS"

DISPLAYSIZE="0" AUTOSIZE="0" BGCOLOR="darkblue" SHOWCONTROLS="false"

SHOWTRACKER="-1" SHOWDISPLAY="1" SHOWSTATUSBAR="-1" VIDEOBORDER3D="-1"

WIDTH="0" HEIGHT="0"

SRC="/sound/a1it.wma" AUTOSTART="-1" DESIGNTIMESP="5311">

</EMBED>

</object>

<ol>...</ol> Geordnete Liste

<li>...</li> Elemente

onClick, on… EventHandler-Ereignisse

onClick="window.alert ('Danke!');"

-- P -- <p>...</p> Textabsatz, sichtbarer Abstand

<p align=center>

<pre>...</pre> PRE-Tag Eingegebene Leerzeichen werden angezeigt

-- S -- <s> Durchgestrichen

<select> ... </select> Auswahlliste

<select lang=".." size="..">

<span>...</span>

<span style="font-weight:bold;

color:red;

font-family: Arial;">

Text!

</span>

<sup> Hochgestellt

<sub> Tiefgestellt

<strike> Durchgestrichen

Page 10: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 10 Author: A. Balogh

<strong> ..</strong> Wird dargestellt durch Fettschrift

<style ...>...</style> Style Sheet Angaben sollten im Kopf stehen

style= CSS-Style

-- T -- <TT> Nichtproportionaler Typewriter-Zeichensatz

<title>....</title> Name des Browserfensters

Max. 64 Characters

Datei/Seiteneigenschaften: Titel ....

<ul>...</ul> Ungeordnete Liste

<li>...</li> Elemente

<small> kleiner

<table>

<colgroup>

<col width=\"10\">

<col width=\"20\">

</colgroup>

<thead>

<tfoot>

<tbody>

<tr>

<td>

<th> .. </th>

</td>

</tr>

</table> Tabelle

-- U -- <u>...</u> Unterstrichen/Underline

<img src=dateiname Immer im gleichen Verzeichnis wie source.

width=pixelbreite

height=pixelhöhe

alt=Bezeichnung

align=left,right,>

<img dynsrc="hochzeit.avi">

loop=infinite

width=pixelbreite

height=pixelhöhe

start=mouseover

controls

<a href="dateiname.html" tabindex=1 >Linkbezeichnung </a>

<a href=http://www.domain.ch/datei.html>Linkbezeichnung</a>

<a href=#sprungziel>Bezeichnung</a> //Direkt zur position im Dokument

<a href="../projektintern.htm#anker">Anker definieren und Verweise zu Ankern</a>

<a href="FW_KPI_002_1.php?vparm1=testmsg">TEST-TEST</a>

HTML: Examples

HTML: input <input type="button name=".." value=".."> // Value = Beschriftung des Buttons

<input type="radio" name=".." value=".." checked>

<input type="radio" name="vradio_1" value="M"> Male &nbsp; &nbsp;

<input type="reset" name=".." value="..">

<input type="submit" name="vsubmit" value="OK">

<input type="checkbox" name="vcheckbox_1" value="HTML" checked>

Page 11: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 11 Author: A. Balogh

<input type="checkbox" name="foo[]" value="foo"> // Array

<input type="text" name="vtext" value="…" size="30" maxlength="40">

size // Anzeigelänge in Zeichen

maxlength // interne Feldlänge in Zeichen

<input type="password" name="Zugangsnummer" maxlength=10 size=10>

Auf naechstem Feld positionieren

---------------------------------

<input TYPE="TEXT" NAME="text1" onBlur="this.form.text2.focus()">

<input TYPE="TEXT" NAME="text2" onBlur="this.form.text3.focus()">

Parameter:

readonly, disabled, tabindex(0 – 32767)

HTML: textarea <textarea name="user_eingabe" cols="50" rows="10"></textarea>

<textarea .. readonly>

HTML: Hintergrundfarbe / Schriftfarbe einer einzelnen Zelle Zieldarstellung der Idee:

Handhabung des Codes: <html>

<head>

<title>RUMWERKEL - Lass mich mal basteln...</title>

</head>

<body bgcolor=#D3D3D3>

<h4 align=center>- RUMWERKEL -<br>

Live von: Ich sein arbeite auf de meine Baustele

</h4>

Page 12: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 12 Author: A. Balogh

<hr width=50% noshade>

</hr>

<div align=center>

<img src="images\telrauch.jpg">

</div>

<h4 align=center>...hmmm, was? <i><font color=#990000>Meine</font></i> Webseite

fungsionird nix#?¬</h4>

<a href="images\madhack.gif">Warum Sie gefährdet sind?!</a>

<table border=1 width=500 cellpadding=30 bgcolor=#ff0000>

<tr valign=center>

<td>

<h3>Überschrift 1</h3><font color=#0000FF>

Ja zur Spalte 12222222222

</td>

<td><h3>Überschrift 2</h3>

Ja zur Spalte 24455555555

</td>

<td bgcolor=33FF00>

<h3>Überschrift 3</h3><font color=#FFCC00>

Ja zur Spalte 34444444444

</td>

</tr>

<tr align=center valign=top>

<td>Blabliblabla

<td>Blabliblabla

<td>Blabliblabla

</tr>

</table>

<table border=10 width=100%>

<tr>

<td>test</td>

<td>test</td>

</tr>

</table>

<table border=0 width=100%>

<tr>

<td cellspacing=10 cellpadding=10>test</td>

<td>test</td>

</tr>

</table>

</body>

</html>

Fazit: - Bei der Definition der Tabelle (dies ist auch die einzige Stelle wo 'table' ausgeschrieben wird) kann

die Default 'bgcolor' definiert werden. Diese kann nur hier definiert werden, an dem Ort, wo auch die ganze Tabelle default-definiert wird!

- Die einzelne Zelle wird beim command '<td> definiert. Hier werden alle Eigenschaften der EINZELNEN Zelle definiert, z.B. die 'bgcolor', welche in diesem Falle dann die default 'bgcolor' der 'table' übersteuert.

- Die Änderung der Textfarbe (<font color>) ist Textorientiert und kann stellenwillkürlich angewendet werden.

Bestimmt die Default-Hinter-grundfarbe für die ganze Tabelle (table & bgcolor)

Bestimmung der aktuellen Tabellenfarbe durch Über-steuerung der Default-bgcolor-farbe an dieser Stelle.

Page 13: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 13 Author: A. Balogh

HTML: Dynamisches ( DHTML ) Sammelbegriff für Lösungen für dynamische Anpassung von WWW-Seiten während der Anzeige.

- Datenanbindungen - Filter-Scripting

Page 14: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 14 Author: A. Balogh

HTML: Vertikal Zentrieren Gar nicht so einfach zum Beispiel auf einer Startseite ein Logo unabhängig von der Bildschirmauflösung exakt in den Mittelpunkt des Bildschirmes zu bringen. Das lässt sich erreichen, indem man eine Tabelle mit Angaben zu Breite und Höhe über das ganze Dokument legt. Hier der HTML-Code: <table border="0"

align="center"

width="100%"

height="100%"

cellspacing="0"

cellpadding="0">

<tr>

<td><center> Logo </center></td>

</tr>

</table>

HTML: Automatische Weiterleitung <html>

<head>

<meta http-equiv="Refresh" content="3; URL=http://www.a1shop.ch">

<title>Document has moved - Redirect</title>

</head>

<body bgcolor="#ffffff">

The page you are looking for has moved. <br>

You will be automatically redirected to the new location OR you can click the link

below.<br>

<a href="http://www.a1shop.ch">http://www.a1shop.ch</a>

</body>

</html>

Page 15: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 15 Author: A. Balogh

PERSONAL HOMEPAGE ( PHP )

PHP: Einführung PHP ist eine der ältesten in HTML eingebetteten Script-Sprache. Verwendet "Tags" Mit CGI ähnlichen Funktionalitäten. PHP ist kostenlos und wird als Quellcode bereitgestellt.

Eine sehr Leistungsfähige Funktion von PHP ist die Möglichkeit, Verbindungen zu verschiedenen relationalen Datenbanken einzurichten, wie etwa ORACLE, Sybase, Postgres, MySQL und Adabas. Ausserdem unterstützt es ODBC.

PHP: Sicherheit Jeder kann Daten an ein Script senden, z.B. auch Hochladen einer Datei. Traue deshalb den Umgebungsvariablen $HTTP_REFERER und $HTTP_USER_AGENT nur beschränkt.

PHP: Links www.php.net http://www.php.net/manual/de/ http://www.phpnuke.org/ Tool

PHP: PHP.INI Pfad: c:\winnt (c:\www ?)

[Session]

session.save_handler = files

session.save_path = c:\www\php\sessiondata

session.use_cookies = 1

session.name = PHPSESSID

session.auto_start = 0

session.cookie_lifetime = 0

session.cookie_path = /

session.cookie_domain =

session.serialize_handler = php

session.gc_probability = 1

session.gc_maxlifetime = 1440

session.referer_check =

session.entropy_length = 0

session.entropy_file =

session.entropy_length = 16

session.entropy_file = /dev/urandom

session.cache_limiter = nocache

session.cache_expire = 180

session.use_trans_sid = 1

url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"

short_open_tag Steuert <? oder <?php

display_errors Fehlermeldunge (default = ON)

error_log = php_errors Error in Logfile ausgeben

gpc_globals Security!

track_vars Is ALWAYS enabled as of PHP 4.0.3

register_globals = On

error_reporting(E_ALL) Empfohlen: E_ALL & E_NOTICE

value constant

0 Keine Errors werden angezeigt

1 E_ERROR

2 E_WARNING

4 E_PARSE

8 E_NOTICE

16 E_CORE_ERROR

32 E_CORE_WARNING

64 E_COMPILE_ERROR

Page 16: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 16 Author: A. Balogh

128 E_COMPILE_WARNING

256 E_USER_ERROR

512 E_USER_WARNING

1024 E_USER_NOTICE

2047 E_ALL

2048 E_STRICT

PHP: Fehlersuche/Debugging PHP-Debugger Stack-Traces Errors werden gemäss PHP.INI in die folgende Log-Datei geschrieben: php_errors print("<p>val = $val</p>"); Typische print Zeile für die Fehlersuche: debug( __LINE__, "Zweite Nachricht", "Test"); get_loaded_extensions(); Zeigt alle geladenen Module an.

print_r(get_loaded_extensions());

Array

(

[0] => xml

[1] => wddx

[2] => standard

[3] => session

[4] => posix

[5] => pgsql

[6] => pcre

[7] => gd

[8] => ftp

[9] => db

[10] => Calendar

[11] => bcmath

)

PHP: Cookies Ein Cookie ist eine kleine Datenmenge, die nach einer Server- oder Scriptabfrage vom Browser auf dem Client-Rechner gespeichert wird.

• Ein Host kann den Browser veranlassen bis zu 20 Cookies/Site zu speichern.

• Ein Cookie besteht aus Namen, Wert, Verfallsdatum sowie Host- und Pfadinformationen.

• Ein Cookie kann max. 4 KByte haben.

Warum werden Cookies eingesetzt? ➔ Um Besucher zu identifizieren. ➔ Um den Status von Transaktionen zu speichern.

Cookie setzen mit: header() / Set-Cookie Funktion: setcookie(…,…,…,..,) Löschen mit: setcookie mit namen aufrufen.

PHP: Syntax Standard Tag <?php ?>

Kurzform <? ?>

Script Tag <SCRIPT LANGUAGE="php"> </SCRIPT>

<script type="text/php">

echo ('You can put your PHP code here.');

</script>

Page 17: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 17 Author: A. Balogh

// Zwei Schrägstriche = Kommentar

# Auch das ist ein Kommentar

/*

Mehrzeiliger Kommentar

...

*/

<br> Gleich wie Return-Taste

&nbsp; Leerzeichenfür den Browser

nonbreaking space

nicht umbrechbares Leerzeichen

Gleiches Ergebnis mit &#160

&lt TEXT &gt Ergiebt < TEXT >

PHP: Schleifen $v1 = 0;

while ( $v1 < 100 ) {

$v1++; // $V1 um 1 erhöhen

break; // Schleife verlassen

}

for ([Variablenzuweisung]; [Test]; [Inkrementieren]) {

continue; // An den Anfang der Schleife!

break; // Schleife verlassen

}

for ($v1=0; $v1 < 100; $v1++) {

}

PHP: Escape-Sequenzen Unicode

\ Escape-Zeichen wird verwendet wenn Probleme mit den HTML

eigenen Anführungszeichen (") entstehen.

z.B. <font color="#000000"> in PHP <font color=\"#000000\">"

\O ASCII 0 (Nul)

\n \u000A Zeilenschaltung (Entspricht LineFeed(LF oder ASCII(13) )

Sendet an den Browser das Kommando, im HTML-Sourcecode eine

neu Zeile anzufangen.

\t \u0009 Tabulator ( ASCII (9) )

\r \u000D Return. Entspricht Carriage Return(CR) oder ASCII(10) )

\b \u000b Rückschritt

\f \u000C Seitenvorschub

\' \u0027 Apostroph. Einfaches Anführungszeichen

\" \u0022 doppeltes Anführungszeichen

\\ \u005C Backslash-Zeichen

\% Prozentzeichen

\_ Unterstrich

PHP: Konstanten define("BENUTZER", "Albert") //*Konstantendefinition

_FILE_

_LINE_

PHP_Version

PHP: Datentypen / Variablendefinition Integer, Double, String, Boolean, Object, Array

$ Beginn einer Variablen

$V1 = 100; Zuweisung von 100 zu einer variablen

$$V1 Variablenname in einer Variablen

${"benutzer"} Dynamische Variable

&$Variable Pointer der Variablen kann für Zuweisung verwendet werden

$b = 325;

$a = &$b Zuweisung "by reference". Die Speicheradresse der

Variablen $a wird auf die Speicheradresse der

Variablen $b gesetzt!

$vbool = TRUE; Erstellt eine Boolsche Varaible

global Globale definition einer Variablen

static Lokale Gültigkeit einer Variablen

Page 18: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 18 Author: A. Balogh

settype() Datentyp festsetzen

settype($var, "integer");

settype($var, "boolean");

settype($var, "float");

settype($var, "string");

settype($var, "array");

settype($var, "object");

settype($var, "null");

isset() Prüft ob die Variable definiert ist.

is_bool() Gibt True/False zurück wenn die variable Boolean ist.

is_array() Gibt True zurück wenn die variable ein Array ist.

is_null() Gibt True zurück wenn die variable NULL ist.

gettype() Datentyp feststellen

(double) $var1 Casting erstellt eine Kopie der Variablen

strval Wandelt den Typ einer Variablen in string um.

unset Entfernt eine Variable aus dem Speicher

PHP: Operatoren +, -, /, *, %

++ Variable um 1 erhöhen/inkrementieren ( $vx1++; )

+= 10 Variable um 10 erhöhen ( $a += 10; )

-=, /=, *=, %=, .=

== Vergleichsoperator ( gleich )

!= ungleich

=== identisch

!=== nicht identisch

>, >=, <, <=

||, or Or-Operator ( Alt + 124 )

xor

&&, and And-Operator

! Not

.= Concatinieren einer Variablen

Page 19: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 19 Author: A. Balogh

PHP: array handling array() Array auch direkt über [] möglich

Arrays die Zeichenketten als Index haben, heissen

"Assoziative Arrays" oder "Hash-Arrays"

array_walk()

array_merge() Mergen von zwei oder mehr "Arrays"

array_push() Arrays hinzufügen

array_shift() Erstes Array-Element löschen

array_slice() Arrays aufsplitten

asort() Assoziative Arrays sortieren

array_key_exists() Prüft ob ein Index existiert

if ( array_key_exists('0', $vtemp) ) {

echo 'Key exists<br>';

} else {

echo 'Key does not exist<br>';

}

explode() Zeichenkette in Array zerlegen

e.g. $vparm1 = explode(" ", $vnox2);

is_array() Gibt "true" zurück wenn die Variable eine Array ist.

ksort() Assoziative Arrays nach Schlüssel sortieren

sort() Arrays sortieren

ARRAY laden

===========

$vmonth_array = array("01", "02");

$vmonth_array[] = "01";

$vweek_array = array("Mon"=>"Menu1",

"Tue"=>"02");

Mehrdimensionales ARRAY

=======================

$array[1][2]

ARRAY durchlaufen

=================

$vmonth_array = array("01", "02");

foreach ( $vmonth_array as $vitem ) {

print "<br> $vitem";

break; // Frühzeitiges beenden der Schlaufe.

}

foreach ( $vmonth_array as $schluessel=>$vitem ) {

print "<br> $vitem";

}

print "<br>Anzahl Tabellenelemente:***".$vmonth_array[count($vmonth_array)-1];

Page 20: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 20 Author: A. Balogh

PHP: select Das folgende select statement gibt ein Array zurück, dass mit einer foreach Schlaufe

ausgewertet werden kann, um die selektierten items zu identifizieren.

<select name=\"vselect[]\" size=\"5\" multiple>

<option value=\"(*) ALL\" selected> (*) All KPI's

<option value=\"1\"> 1) MANPOWER PRICE EFFICIENCY

<option value=\"2\"> 2) MANPOWER COST&nbsp; EFFICIENCY

</select>

foreach ( $vselect as $vitem ) {

print "<br> $vitem";

}

PHP: Programming structures <?php

if(strstr($HTTP_USER_AGENT,'MSIE 6.0')) {

echo ('<center><b>You are using Internet Explorer 6.0</b></center>');

} else {

echo ('<center><b>You are not using Internet Explorer 6.0</b></center>');

}

?>

echo "Text<br>"; // Zeilenumbruch nach jedem echo

exit Beendet sofort die Bearbeitung und Ausgabe von HTML und PHP

( STOP, END )

break

die() Gibt vor dem Abbruch noch eine Meldung an den Browser aus.

header Weiterleiten/Umleiten auf eine andere Seite (Muss vor <html> stehen!)

z.B. header("Location: ../index.html");

header("Location: http://www.a1-it.ch");

Bilddatei zu Browser umleiten

header("Content-type: image/png");

PHP/CGI: GET/POST-Methode: Gilt sowohl für CGI wie auch PHP. GET - Standardmethode für WebServer Anfragen. - übergeben Daten werden in der Variablen QUERY_STRING gespeichert. - Variable in Perl %ENV - Bei GET werden die Daten durch ein Fragezeichen eingeleitet und dem URL angehängt. - Achtung! Limitation der Browser meist bei 2000 Zeichen. POST - Die Daten werden direkt übergeben. - wird nur verwendet wenn es im Formular für die Anfrage explizit angegeben ist. - wird verwendet z.B. wenn die Userid und Passwörter nicht im Log aufgeführt werden sollen. - wenn Dateien hochgeladen werden sollen. ? Anfragenzeichenkette

Trennt den eigentlichen Pfad von den Variablen.

$REQUEST_METHOD Zur Unterscheidung von GET/POST

$HTTP_GET_VARS Achtung Gross/Kleinschreibung!

$HTTP_POST_VARS Variablen welche mit POST übergeben wurden

foreach ( $HTTP_POST_VARS as $vitem ) {

echo ('<br>' . $vitem);

}

$_REQUEST associative array consisting of the contents of:

- $_GET, $_POST, $_COOKIE, $_FILES

Page 21: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 21 Author: A. Balogh

<form method="GET" action=test.php>

<form method="POST" action=test.php>

<form method="POST" action="<?php echo $PHP_SELF ?>" >

<form method="POST" action="mailto:[email protected]" enctype="text/plain">

PHP: Funktionen print() gibt Daten aus

abs() Absoluter Wert einer Zahl

copy($src, $tar) Datei auf einen Server kopieren/hochladen

exec() UNIX only? Shell aufrufen

### Läuft nur auf dem lokalen Apache Server?

<?PHP exec('xcopy d:\\buffer g:\\buffer /e/i', $a, $a1); ?>

echo exec('whoami');

flush() Ausgabepuffer leeren

pack() Pack data into binary string

pack ( [format], [mixed arguments])S

format:

@ NUL-fill to absolute position

a NUL-padded string

A SPACE-padded string

c signed char

C unsigned char

d double (machine dependent size and representation)

f float (machine dependent size and representation)

h Hex-string, low nibble first

H Hex-string, high nibble first

i signed integer (machine dependent size and byte order)

I unsigned integer (machine dependant size and byte order)

signed long (always 32 bit, machine byte order)

L unsigned long (always 32 bit, machine byte order)

N unsigned long (always 32 bit, big endian byte order)

n unsigned short (always 16 bit, big endian byte order)

s signed short (always 16 bit, machine byte order)

z.B. Windows 2000 (Intel Rechner)

S unsigned short (always 16 bit, machine byte order)

v unsigned short (alwas 16 bit, little endian byte order)

z.B. RS6000 (POWER Chip)

V unsigned long (always 32 bit, little endian byte order)

x NUL byte

X Back up one byte

popen() UNIX only? Pipe zu einem Prozess ( ähnlich fopen() )

passthru() UNIX only?

system() UNIX only?

shellcmd() UNIX only?

virtual() UNIX only?

tbl_out() Ausgabe einer HTML-Tabelle

rename() File umbenennen

set_time_limit (500); PHP.INI übersteuern sofern nicht im Save Mode!

unlink() Löscht ein File! Achtung slash verwenden.

linkinfo() Prüfen ob ein link existiert.

Page 22: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 22 Author: A. Balogh

Beispiel: ftp $ftp_server = "www.x.ch";

$ftp_user = "xxx";

$ftp_pass = "xxx";

// set up a connection or die

$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");

// try to login

if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {

echo "Connected as $ftp_user@$ftp_server\n";

} else {

echo "Couldn't connect as $ftp_user\n";

}

// upload a file

$remote_file = '/web/test.txt';

$file = 'd:\_buffer\test.txt';

if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) {

echo "<br>successfully uploaded $file\n";

} else {

echo "<br>There was a problem while uploading $file\n";

}

// close the connection

ftp_close($conn_id);

Beispiel: copy()

if ( copy('d:/buffer/test.txt','test.txt') ) {

echo 'OK';

} else {

echo 'NOK';

}

Für DBM muss der Apache-Server entsprechend vorbereitet sein! dbmopen() DBM: Datenbank öffnen (Flags: r/w/c/n)

dbmclose() DBM: Datenbank schliessen!

dbminsert() DBM: Daten hinzufügen

dbmreplace() DBM: Daten ändern

dbmfetch() DBM: Daten lesen

dbmexists() DBM: Daten suchen

dbmdelete() DBM: Daten löschen

die() Beendet script

fileatime() Wann zuletzt auf die Datei zugegriffen wurde.

filemtime() Wann die Datei geändert wurde

filectime() Änderung eines Dokumentes bestimmen.

file_exists() Ob eine Datei existiert

filesize() Dateilänge bestimmen

fopen() Datei zum bearbeiten öffnen

fgets() Datei Zeilenweise lesen

fgetc() Datei Zeichenweise lesen

fgetcsv() CSV lesen Zeichenweise lesen

feof() Dateiende anzeigen

fread() Datei-Abschnitte lesen

fseek() Dateizeiger in Datei positionieren

fwrite() Datei schreiben

fputs() Datei schreiben

flock() Datei sperren (shared/exclusive/release/non-blocking)

fsockopen() Netzwerkverbindung herstellen

gethostbyaddr() Hostnamen mittels IP-Adresse eruieren

include() Zur Einbindung von Library-Code

Parameter zurückgeben mit: RETURN $VParm1

include_once() Rekursivaufruffehler vermeiden.

is_file() Datei oder Verzeichnis?

is_readable() Kann die Datei gelesen werden?

is_writable() Datei

is_executable Datei

isset() Gibt false zurück wenn die Variable noch nicht definiert wurde

Page 23: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 23 Author: A. Balogh

mail() Auf UNIX über "Sendmail"

auf anderen Systemen PHP.INI(SMTP) anpassen.

mkdir() Verzeichnis erstellen

Beispiel: file_exists()

$vfile = 'c:\boot.ini';

if ( file_exists($vfile) ) {

echo 'File &lt;' . $vfile . '&gt; existiert!';

} else {

echo 'File &lt;' . $vfile . '&gt; nicht gefunden!';

}

Page 24: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 24 Author: A. Balogh

MySQL Funktionen mysql_connect() Step 1 Verbindung zu Datenbank aufbauen,

gibt einen Bezeichner zurück und baut die Verbindung autom. ab

beim beenden des scripts.

mysql_pconnect() Step 1 Gleich wie mysql_connect, baut aber die Verbindung

nicht autom. beim beenden des scripts ab.

mysql_select_db() Step 2 Datenbank auswählen.

=========================================================================================

mysql_fetch_row() Datensatz lesen

=========================================================================================

mysql_fetch_array() Erzeugt aus den gefundenen Datensätzen ein Array

EXAMPLE

$vsql = "SELECT * FROM if_input";

$vsql_result = mysql_query($vsql, $vlink);

while ( $vrow = mysql_fetch_array($vsql_result) ) {

echo '<p>'.$vrow['products_model'];

} // END while

=========================================================================================

mysql_fetch_assocy() Erzeugt aus den gefundenen Datensätzen ein assoziatives Array

Entspricht: mysql_fetch_array ( ohne numerische indizes )

=========================================================================================

mysql_fetch_object() Eigenschaften des Objektes abfragen.

mysql_field_name() Feldname

mysql_field_len() Feldlänge

mysql_field_flags() Flags

mysql_field_type() Feldtyp

mysql_close() Step last, Verbindung sauber beenden.

=========================================================================================

mysql_query() Sendet einen SQL-Befehl zum Server.

@mysql_query() Sendet einen SQL-Befehl zum Server, Fehlermeldung wird unterdrückt.

EXAMPLE

$vsql_result = mysql_query("SELECT COUNT(*) FROM titles");

EXAMPLE

$vsql_result = mysql_query("mylibrary", "SELECT COUNT(*) FROM titles");

EXAMPLE

ACHTUNG! Character fields gehören zwischen Hochkommas!

$vsql = "UPDATE wh_performance_location

SET Field_Char = '$t002_1_01',

Direct_Expenses = $t002_1_02,

Indirect_Expenses = $t002_1_03

WHERE location_id = $vbranch_office_id

AND department_id = '$vwls'

AND periode = $vperiode";

$vsql_result = mysql_query($vsql, $vlink);

EXAMPLE

$vsql = "SELECT *

FROM Table1 a LEFT JOIN Table2 b on a.key1 = b.key1";

$vsql_result = mysql_query($vsql, $vlink) or die("<br>Error-Msg");

EXAMPLE

$vsql = "SELECT *

FROM Table1 a LEFT JOIN Table2 b using(key1)";

$vsql_result = mysql_query($vsql, $vlink) or die("<br>Error-Msg");

EXAMPLE

$vsql = "ALTER TABLE branch_office

ADD Branch_Office_IdNO int(13) NOT NULL default '0' AFTER Trace";

Page 25: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 25 Author: A. Balogh

$vsql_result = mysql_query($vsql, $vlink) or die("<br>Error-Msg");

EXAMPLE

$vsql = "ALTER TABLE branch_office DROP Branch_Office_IdNO";

$vsql_result = mysql_query($vsql, $vlink) or die("<br>Error-Msg");

EXAMPLE

# Tabelle existiert nicht also erstellen und zwar nur Struktur!!!!

$vsql = "CREATE TABLE if_products select * from products where products_id <=-1";

$vsql_result = mysql_query($vsql, $vlink) or die("<br>Error-Msg");

EXAMPLE

$vsql = "SELECT MAX(categories_id) as max_categories_id FROM categories";

$vsql_result = mysql_query($vsql, $vlink) or die("<br>Couldn't read max!");

=========================================================================================

mysql_insert_id() ID des letzten INSERT's

mysql_num_fields() Anzahl der Spalten

=========================================================================================

mysql_num_rows() Gibt die Anzahl Datensätze welche mit SELECT gewählt wurden

zurück.

$vrows = mysql_num_rows($vsql_result);

=========================================================================================

mysql_list_tables() Gibt eine Liste der Tabellen in einer Datenbank aus.

EXAMPLE

$vtbl_list = mysql_list_tables('concerto',$vlink);

while ($vrow = mysql_fetch_row($vtbl_list)) {

echo "<p>" . $vrow[0];

}

EXAMPLE

# Testen ob eine Tabelle existiert

$vretcode = mysql_query ("select count(*) from products");

if (! $vretcode) {

echo "Tabelle existiert nicht.";

} else {

echo "Tabelle existiert!";

}

=========================================================================================

mysql_list_dbs() Liste der Datenbanken

EXAMPLE

$vdb_list = mysql_list_dbs($vlink);

while ($row = mysql_fetch_object($vdb_list)) {

echo "<p>" . $row->Database;

}

EXAMPLE

$vdb_list = mysql_list_dbs($vlink);

while ($row = mysql_fetch_row($vdb_list)) {

echo "<p>" . $row[0];

}

=========================================================================================

mysql_tablename() Anzahl Tabellen in der Datenbank

mysql_errno() ERROR Nummer

mysql_error() ERROR Text

Page 26: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 26 Author: A. Balogh

opendir() Verzeichnispointer um Verzeichnis lesen zu können

readdir() Verzeichnisinhalt lesen

rmdir() Verzeichnis löschen

require() Wie include, kann aber keinen Wert zurückgeben.

time() Zeit seit 1. Januar 1970 GMT

touch() Datei anlegen

Page 27: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 27 Author: A. Balogh

PHP: Stringhandling AddSlashes() Setzt Backslash vor Sonderzeichen

chr(27) Escape Zeichen.

chr(65) Gibt das dem ASCII Wert entsprechende Zeichen zurück (A).

chr(92) Backslash "\"

ereg() Muster vergleichen

ereg_replace() Muster vergleichen

number_format Zahlen formattiert ausgeben.

number_format($var1, '2','.',chr(39)) => 999'999.99

round() Runden

round($vproducts_price * 20, 0) / 20; ### Typische fünfer Rundung

preg_match() Muster vergleichen

preg_replace() Muster ersetzen

printf() Zahlen / Zeichenkette formatieren

print_r() Gibt Informationen über eine Variable aus

serialize($vstr) Serialisierte Zeichenkette

split() Zeichenkette aufsplitten

sprintf() Zeichenkette formatieren und an Variable übergeben

strpos() Position in Zeichenkette eruieren

$pos = strpos($vstring, "all");

if ($pos === false) { // note: three equal signs

print ("<br> Not found");

}

strlen() Länge der Zeichenkette eruieren

stristr() Case sensitiv!

strrchr() Letzten Character suchen

strtoupper() Wandelt einen String in UPPERCASE um.

strtolower() Wandelt einen String in UPPERCASE um.

str_repeat("-=", 10); Gibt -=-=-=-=-=... zurück

substr($v1,0,10) Teilzeichenkette

substr($v1,<start>, <länge>)

substr_replace()

substr_replace("abcde1", "12" 2, 2) = "ab12e"

strtok() Zeichenkette zerlegen

str_replace() Zeichenketten ersetzen

str_replace("a", "b", "aaaa"); ➔ "bbbb"

str_replace("\'", "", $variable);

str_replace("'", "", $variable);

trim()/ltrim()

Funktionen für das Verzeichnissystem chdir() Wechselt das Verzeichnis

closedir() Schliesst ein geöffnetes Verzeichnis

dir() Öffnet ein Verzeichnis $dir und erstellt eine Klasse

dirname() Gibt das Verzeichnis eines Pfades $path zurück

mkdir() Erstellt ein Verzeichnis mit den Zugriffsrechten

opendir() Öffnet ein Verzeichnis

rewinddir() Springt zum ersten Verzeichniseintrag

mdir() Löscht ein Verzeichnis

Beispiel: dir() // Alle Files eines Verzeichnisses anzeigen

<?php

$path = '.';

$folder = dir($path);

while ( $datei = $folder->read()) {

echo '&lt;'. $datei .'&gt;<br>';

}

Page 28: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 28 Author: A. Balogh

$folder->close();

?>

Beispiel: chdir() // Verzeichnis wechseln

$vchdir = 'h:\\';

if ( chdir( $vchdir ) ) {

echo 'OK &lt;'. $vchdir . '&gt;!<br>';

} else {

echo 'NOK &lt;'. $vchdir . '&gt;!<br>';

}

PHP: Klassen -> Operator für den Zugriff auf Objekte

$this 3 Erlaubt innerhalb der Klasse selbst den Zugriff auf alle

Eigenschaften und Methoden der Klasse.

class X extends Y Kopie der Elternklasse erstellen = X

Basis für alle Objektinstanzen, erzeugt eine Objektinstanz mit der Anweisung NEW. class erste_klasse {

}

$obj1 = new erste_klassse();

$obj2 = new erste_klassse();

print "\obj1 ist ein ".gettype($obj1)."<br>";

print "\obj2 ist ein ".gettype($obj2)."<br>";

Page 29: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 29 Author: A. Balogh

PHP: Function return; Beendet die Funktion und kann einen Wert zurückgeben:

z.B. return $vwert;

break; Ends execution of the current for, foreach while, do..while or switch

structure.

Break accepts an optional numeric argument which tells it how many nested

enclosing structures are to be broken out of.

break 1;

Beispiel:

/* Using the optional argument. */

$i = 0;

while (++$i) {

switch ($i) {

case 5:

echo "At 5<br>\n";

break 1; /* Exit only the switch. */

case 10:

echo "At 10; quitting<br>\n";

break 2; /* Exit the switch and the while. */

default:

break;

}

}

PHP: FastTemplate Prinzip: Konsequente Trennung von Code und Design.

- Das Design wird in verschiedenen Templates hinterlegt.

- Der Code enthält die Ablaufsteuerung und Programmlogik

Installation:

Page 30: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 30 Author: A. Balogh

PHP: Grafiken/Charts Erfordert die "Open-Source-Bibliothek" GD GD-Download: http://www.boutell.com/gd File: gd-2.0.1.zip Beim entpacken wird das Directory "gd-2.0.1" erstellt. Testfile: demoin.png (Space Shuttle) PHP Muss für GD kompiliert sein Programm: Microsoft Visual C++ 5.0 Bstandteil von Visual Studio 6.0 Option: –with-GD Kontrolle mit phpinfo(); Alternativ kann die Bibliothek mithilfe der Funktion dl() geladen werden. PHP.INI extension=php_gd2.dll ( php_gd.dll ) extension_dir = c:\www\apache\cgi-bin (Wo sich php_gd.dll befindet) Header testen mit PHP. Unter DOS ausführen: C:\www\Apache\cgi-bin>php test.php Resultat: X-Powered-By: PHP/4.0.6

Content-type: text/html

libpng muss für .PNG geladen werden Download: http://www.libpng.org/pub/png/libpng.html zlib laden für .. Download: http://sunsite.cnlab-switch.ch/ftp/mirror/infozip/zlib/ jpeg-6b GD Example:

header ("Content-type: image/jpeg");

header ("Content-type: image/png");

imagecreate() Handle erzeugen

GetImageSize() Grösse GIF, JPG, PNG, SWF, PSD or

BMP image file

ImageArc() Ellipse zeichnen

Imagechar() Zeichen zeichnen

imagecharup Zeichen 900 gedreht zeichnen

imagecolor() Handle für Farbe

imagedashedline() gestrichelte Linie zeichnen

imagefill() Fläche mit Farbe füllen

imagefilled() Rechteck mit Farbe füllen

imageinterlace() Interlacing modus aktivieren

imageline Linie zeichnen

imagecreateangle Rechteck zeichnen

imagestring Text schreiben

imagestringup Text 900 gedreht zeichnen

imagepng() Bild an Browser ausgeben

imagepng($im, $name);

Image2WBMP() creates the WBMP file in filename

imagedestroy() Platz wieder freigeben

phpBarGraph() Säulendiagramm

Liniendiagramm http://www.phpbuilder.com/columns/allan20000830.php3

PHPChartDirector

http://www.advsofteng.com/ USD 499.--

Page 31: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 31 Author: A. Balogh

PHP: DB-Lesen // STEP 1

// Verbindung zu MySQL aufbauen mysql_connect oder mysql_pconnect verwenden

$link = mysql_connect( "localhost", "root", "mysql" );

if ( !$link ) {

die ("Die Verbindung konnte nicht hergestellt werden!<br>");

}

else {

print ("Korrekte Verbindung hergestellt! [".$link."]<br>");

}

// STEP 2

// Datenbank auswählen

$vretcode = mysql_select_db( "testDB" )

or die( "Datenbank konnte nicht ausgewählt werden! ["

.mysql_errno()."] ".mysql_error()."<br>" );

echo $vretcode ➔ 1 = Succesful

// STEP 3

// ABFRAGE-SQL

$vsql = "SELECT *

FROM department_wh

WHERE department_id = $vwls";

$vsql_result = mysql_query($vsql,$vlink);

$vsql_result2 = mysql_result($vsql_result,0);

if ( $vsql_result2 == 0 ) {

// Nicht gefunden

}

=========================================================================================

Anzahl gelesener Datensätze

$vrows = mysql_num_rows($vsql_result);

print "<br>Anzahl gelesener Records ***".$vrows."***";

Page 32: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 32 Author: A. Balogh

PHP: Beispiele <?php phpinfo(); ?>

PHP: Excel Datei erzeugen

Check: Perl-Tool namens Excel::WriteSpreadsheet "Richtige" Excel-Dateien lassen sich kaum erzeugen, da .xls ein binäres, undokumentiertes

proprietäres Microsoft-Format ist, das zudem von Version zu Version verändert wird.

Stattdessen kann man aber Textdateien erzeugen, deren Werte (Spalten) mit Tabulatoren und

deren Zeilen mit CRLF (\r\n) getrennt sind, und diese Excel als .xls-Datei

"unterschieben". Wichtig ist hierbei, als Dateityp tatsächlich eine Excel-(.xls)-Datei zu

deklarieren - obwohl Excel diverse Importformate wie .csv (comma separated value) kennt,

funktioniert es damit, vermutlich mangels definiertem Content-Type, nicht wie gewünscht.

header("Content-Type: application/vnd.ms-excel");

header("Content-Disposition: inline; filename=\"excel.xls\"");

header("Content-type: application/x-msexcel" );

readfile($filename); // Datei 1:1 durchreichen

echo "Titel (A1)\r\nA2\tB2\r\nA3\tB3"; // ODER mit PHP erzeugen

Anmerkung: Trotz der Angabe inline bietet der Browser i.d.R. einen Dialog an, der das

direkte Öffnen oder aber das Speichern der Datei ermöglicht. Die Angabe attachment

dagegen führte zu kuriosen, nicht brauchbaren Ergebnissen...

Ein gänzlich anderer Weg, Excel-Dateien zu erzeugen, führt über die COM-Funktionen von

PHP 4. Damit kann man eine Excel-Instanz direkt ansteuern und so eine echte .xls-Datei

generieren. Wer das ausprobieren will, der besorge sich die Excel Class von Alain Samoun.

Excel Header Hexadecimal:

BOF(12 Bytes): 09 08 08 00 00 00 10 00 00 00 00 00

EOF(4 Bytes): 0A 00 00 00

function xlsBOF() {

global $vfp;

$vfp = fopen("test.xls","a");

// fwrite ($vfp, pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0) );

fwrite ($vfp, pack("cccccccc", 0x09, 0x00, 0x04, 0x00, 0x07, 0x00, 0x10, 0x00) );

return;

}

function xlsEOF() {

global $vfp;

// fwrite ($vfp, pack("ss", 0x0A, 0x00) );

fwrite ($vfp, pack("cccc", 0x0A, 0x00, 0x00, 0x00) );

return;

}

function xlsWriteNumber($Row, $Col, $Value) {

global $vfp;

// fwrite ($vfp, pack("sssss", 0x203, 14, $Row, $Col, 0x0) );

fwrite ($vfp, pack("ccccsscc", 0x03, 0x02, 0X0E, 0x00, $Row, $Col, 0x00, 0x00) );

// to be tested ("sssss", 0x0203, 14, $row, $col, 0x00 );

fwrite ($vfp, pack("d", $Value) );

return;

}

// Function to write a Number (double) into Row, Col function xlsWriteNumber($Row, $Col, $Value) {

return pack("sssss", 0x203, 14, $Row, $Col, 0x0).pack("d", $Value);

}

Page 33: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 33 Author: A. Balogh

function xlsWriteLabel($Row, $Col, $Value ) {

global $vfp;

$L = strlen($Value);

// fwrite ($vfp, pack("ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L) );

fwrite ($vfp, pack("ccsssccs", 0x04, 0x02, 8 + $L, $Row, $Col, 0x00, 0x00, $L) );

fwrite ($vfp, $Value );

return;

}

xlsBOF();

xlsWriteLabel(0,0,"This is a label"); // write a label in A1, use for dates too

xlsWriteNumber(0,1,9999); // write a number B1

xlsEOF(); // close the stream

PHP: settype() settype($foo, "integer" );

settype($bar, "string" );

➢ "boolean" (or, since PHP 4.2.0, "bool")

➢ "integer" (or, since PHP 4.2.0, "int")

➢ "float" (only possible since PHP 4.2.0, for older versions use the deprecated variant

"double")

➢ "string"

➢ "array"

➢ "object"

➢ "null" (since PHP 4.2.0)

PHP: printf() Formatzeichen:

% Keine Konvertierung

b Ganzzahl (Integer)

c Interpretiert den Wert als ASCII und gibt das passende Zeichen aus

d Gibt den Wert als Dezimalzahl aus

f Gibt Wert als Gleitkommazahl aus

o Gibt den Wert als Oktalzahl aus

s Gibt eine Zeichenkette aus

x Hexadezimalzahl klein

X Hexadezimalzahl gross

=========================================================================================

printf("Formatierung", $Amount);

printf("%04",36); // Gibt "0036" aus

printf("% 4",36); // Gibt " 36" aus

printf("#%02X%02X%02X", $rot,$gruen,$blau); // Gibt "#010101" aus

Page 34: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 34 Author: A. Balogh

$format = "There are %d monkeys in the %s";

printf($format,$num,$location); => "There are 5 monkeys in the tree".

=========================================================================================

$format = "The %2\$s contains %1\$d monkeys";

printf($format,$num,$location);

=========================================================================================

printf( "%.2f", $x );

PHP: sprintf() ' Start Füllzeichen

% Keine Konvertierung

b Behandelt den Wert als Ganzzahl(Integer)

c Interpretiert den Wert als ASCII und gibt dazu passende Zeichen aus.

d Gibt den Wert als Dezimalzahl aus

f Gibt den Wert als Gleitkommazahl aus

o Gibt den Wert als Oktalzahl aus

s Gibt eine Zeichenkette aus

x Gibt eine Zeichenkette aus

X Gibt Wert als Hexadezimalzahl aus. Verwendet Grossbuchstaben

sprintf (string format [, mixed args...])

sprintf ("%'X-10s", "Test")) // Rechts mit X Füllen

sprintf ("%'0-10s", "Test")) // Rechts mit Null füllen

sprintf("%'02s",$vprev_month); // Links mit 0 auffüllen

=========================================================================================

$wert = 155;

$binaer = sprintf ("%b", $wert);

echo ("<br> $binaer <br>"); // gibt 10011011 aus

=========================================================================================

$isodate = sprintf("%04d-%02d-%02d", $year, $month, $day);

=========================================================================================

$money1 = 68.75;

$money2 = 54.35;

$money = $money1 + $money2;

// echo $money will output "123.1";

$formatted = sprintf("%01.2f", $money);

// echo $formatted will output "123.10"

=========================================================================================

sprintf("%-=75s", $str);

=========================================================================================

"........12345"), you can use the following:

$txt = "Abracadabra"; // actual string

$fit = 16; // how many digits to use

$fill = "."; // what to fill

$digits = sprintf ("%'{$fill}{$fit}s", $txt);

=========================================================================================

ADDS SPACES TO A VARIABLE:

function FPHP_rspace($string, $length) {

$result = sprintf("%{$length}s", $string);

return($result);

}

EXAMPLE: $text = FPHP_rspace($text,50);

=========================================================================================

presumably, if you wanted to fill out a HTML line with space, you could

use:

$fill = "&nbsp;"; // what to fill

$digits = sprintf ("%'{$fill}d", $digit);

=========================================================================================

Page 35: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 35 Author: A. Balogh

Add Blanks to string! $txt = "Abracadabra"; // actual string

$fit = 16; // how many digits to use

$fill = chr(160); // what to fill

$digits = sprintf ("%'{$fill}-{$fit}s %s", $txt, "/");

print "$digits";

=========================================================================================

Adds a character to the end of a string

$x = sprintf("%'x-10s", "a");

echo $x;

=========================================================================================

For example, a table like this...

Col1 Col2

----- ------------------

1 something

142 something else

9999 etc...

is achieved using:

printf("% -5s% -18s", "1", "somthing");

printf("% -5s% -18s", "142", "somthing else");

printf("% -5s% -18s", "9999", "etc.");

PHP: Datei schreiben fwrite() int fopen (string filename, string mode, int [use_include_path])

mode

'r' Open for reading only; place the file pointer at the beginning of the file.

'r+' Open for reading and writing; place the file pointer at the beginning of the file.

'w' Open for writing only; place the file pointer at the beginning of the file and

truncate the file to zero length. If the file does not exist, attempt to create

it.

'w+' Open for reading and writing; place the file pointer at the beginning of the file

and truncate the file to zero length. If the file does not exist, attempt to

create it.

'a' Open for writing only; place the file pointer at the end of the file. If the file

does not exist, attempt to create it.

'a+' Open for reading and writing; place the file pointer at the end of the file. If

the file does not exist, attempt to create it.

'b' The mode may contain the letter 'b'. This is useful only on systems which

differentiate between binary and text files (i.e. Windows. It's useless on Unix).

If not needed, this will be ignored.

'1' You can use the optional third parameter and set it to "1", if you want to search

for the file in the include_path, too.

Open

$vfp = fopen ("/tmp/errorlog", "a+");

$vfp = fopen ("/home/rasmus/file.txt", "r");

$vfp = fopen ("/home/rasmus/file.gif", "wb");

$vfp = fopen ("http://www.php.net/", "r");

$vfp = fopen ("ftp://user:[email protected]/", "w");

fsockopen()

popen()

Read

fread($fp,<anzahl zeichen>); // Datei lesen

Write

fputs($fp, $output); // Alias of fwrite / Identically!

fwrite ($vfp, string, int [length])

Close

fclose($vfp);

Page 36: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 36 Author: A. Balogh

socket_set_timeout()

PHP: Datei zeichenweise lesen fgetc() settype($vfp, "integer");

settype($vchr, "string");

$vfp = fopen('test.txt', 'r');

while ( false !== ($vchr = fgetc($vfp) ) ) {

echo "$vchr\n";

}

PHP: Datei zeilenweise lesen fgets() settype($vfp, "integer");

settype($vchr, "string");

$vstartzeile = 1;

$vendzeile = 10;

$vfp = fopen('concertoexport.txt', 'r');

$vi = 1;

while (!feof($vfp) and $vi <= $vendzeile) {

$buffer = fgets($vfp, 4096);

echo ($buffer.'<br>');

$vi++;

}

fclose($vfp);

PHP: Datei mit Tabstop lesen fgetcsv()

settype($vfp, "integer");

settype($vchr, "string");

$vstartzeile = 1;

$vendzeile = 10;

$vfp = fopen('concertoexport.txt', 'r');

# $vfp = fopen('test.txt', 'r');

$vi = 1;

while (!feof($vfp) and $vi <= $vendzeile) {

$varray_inp = fgetcsv($vfp,4096,chr(9));

foreach ( $varray_inp as $vitem ) {

echo "&nbsp; $vitem";

}

echo '<br>Ende der Zeile!<p>';

$vi++;

}

fclose($vfp);

PHP: Datei komplett in Variable einlesen ( *.SQL )

$vfp = fopen("db_erstellen.sql", "r");

while (!feof($vfp)) {

$vbuffer = fgets($vfp, 4096);

$vsql = $vsql . $vbuffer;

}

fclose($vfp);

$vsql_result = mysql_query($vsql, $vlink);

PHP: $HTTP_.. if(isset($HTTP_X_FORWARDED_FOR)) // Reload sperren

echo $HTTP_USER_AGENT;

Page 37: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 37 Author: A. Balogh

if(strstr($HTTP_USER_AGENT,"MSIE")) {

echo "You are using Internet Explorer<br>";

}

PHP: header() header("location: FW_KPI_001.php");

<meta HTTP-EQUIV="refresh" content=4;url="example.php">

PHP: gettype() print gettype($vno_block);

PHP: function() function FPHP_xxxx ( $v1, $v2 …) {

echo "Beispiel.\n";

return $vret_code;

}

PHP: include() <?php include ("test.php"); ?> //Kann einen Wert zurückgeben

<?php require ("test.php"); ?> //Kann keinen Wert zurückgeben

PHP: index.html <html>

<body>

<h1>Das ist die Standard INDEX.Html Seite</h1>

<p>Das ist ein Absatz innerhalb body</p>

<?php

$vret_codex = include ("test.php");

print("Das ist der Return Wert [".$vret_codex."]");

?>

</body>

</html>

Page 38: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 38 Author: A. Balogh

PHP: Datumsbehandlung Die Datums- und Zeitfunktionen von PHP basieren auf der Auswertung des UNIX-Zeitstempels.

Wenn Sie Zeichen ausgeben wollen, die Formatangaben sind, müssen Sie die Formatangabe mit

einem Backslash entwerten. Bei Zeichen, aus denen auf diese Art Steuerzeichen würden, ist

ein doppelter Backslash erforderlich.

date() // String, gibt den lokale Zeitwerte zurück

date("D d M H : i : s a") ➔ 'Tue 01 Jun 08 : 06 : 14 am'

gmdate() // Wie date() aber GMT-Zeitzone

gmmktime() // Wie mktime() aber GMT-Zeitzone

gmstrftime() // Wie strftime () aber GMT-Zeitzone

getdate() // Gibt ein Array zurück mit dem Inhalt des

Timestamp

gettimeofday() // Gibt die aktuelle Zeit zurück

microtime() // String im Format millisekunden

mktime() // UNIX-Zeitstempel

strftime() // Formatiert ein Datum nach den lokalen

Einstellungen

strtotime() // Generiert einen Timestamp aus einem

String.

time() // Timestamp!

Sekunden seit dem 1. 1.1970 00:00 Uhr

print date("d/m/Y G.i:s", time()); // 19/10/2000 11.03:59

print date("m/d/y G.i:s", time()); // 10/19/00 11.03:59

print date("j of F Y, \a\\t g.i a", time()); // 19 of October 2000, at 11.03 am

checkdate($mon, $day, $year) // Datum Prüfen

=========================================================================================

Zeitmarke erzeugen verwenden ( mktime )

Timestamp ist die Zahl der Sekunden seit dem 1. Januar 1970. 00:00 Uhr.

mktime($h, $min, $sec, $mon, $day, $year, [$sommer_winter]);

$ts = mktime( 2, 30, 0, 5, 1, 1999 );

print date("m/d/y G.i:s<br>", $ts);

=========================================================================================

Vormonat laden

$vlastmonth_timestamp = mktime (0,0,0,date("m")-1, 01, date("Y"));

$vlastmonth_array = getdate($vlastmonth_timestamp);

$vlst_day = $vlastmonth_array['mday'];

$vlst_month = $vlastmonth_array['mon'];

$vlst_year = $vlastmonth_array['year'];

=========================================================================================

$tomorrow = mktime (0,0,0,date("m") ,date("d")+1,date("Y"));

$lastmonth = mktime (0,0,0,date("m")-1,date("d"), date("Y"));

$nextyear = mktime (0,0,0,date("m"), date("d"), date("Y")+1);

/* Today is March 10th, 2001, 5:16:18 pm */

$today = date("F j, Y, g:i a"); // March 10, 2001, 5:16 pm

$today = date("m.d.y"); // 03.10.01

$today = date("j, m, Y"); // 10, 3, 2001

$today = date("Ymd"); // 20010310

$today = date('h-i-s, j-m-y, it is w Day z '); // 05-16-17, 10-03-01, 1631 1618 6

Fripm01

$today = date('\i\t \i\s \t\h\e jS \d\a\y.'); // It is the 10th day.

$today = date("D M j G:i:s T Y"); // Sat Mar 10 15:16:08 MST 2001

$today = date('H:m:s \m \i\s\ \m\o\n\t\h'); // 17:03:17 m is month

$today = date("H:i:s"); // 17:16:17

=========================================================================================

$today = getdate();

$month = $today['month'];

$mday = $today['mday'];

$year = $today['year'];

echo "$month $mday, $year";

=========================================================================================

Page 39: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 39 Author: A. Balogh

date( Formatzeichen, int[timestamp])

Formatzeichen:

a - "am" or "pm"

A - "AM" or "PM"

B - Swatch Internet time

d - day of the month, 2 digits with leading zeros; i.e. "01" to "31"

D - day of the week, textual, 3 letters; i.e. "Fri"

F - month, textual, long; i.e. "January"

g - hour, 12-hour format without leading zeros; i.e. "1" to "12"

G - hour, 24-hour format without leading zeros; i.e. "0" to "23"

h - hour, 12-hour format; i.e. "01" to "12"

H - hour, 24-hour format; i.e. "00" to "23"

i - minutes; i.e. "00" to "59"

I (capital i) - "1" if Daylight Savings Time, "0" otherwise.

j - day of the month without leading zeros; i.e. "1" to "31"

l (lowercase 'L') - day of the week, textual, long; i.e. "Friday"

L - boolean for whether it is a leap year; i.e. "0" or "1"

m - month; i.e. "01" to "12"

M - month, textual, 3 letters; i.e. "Jan"

n - month without leading zeros; i.e. "1" to "12"

O - Difference to Greenwich time in hours; i.e. "+0200"

r - RFC 822 formatted date; i.e. "Thu, 21 Dec 2000 16:01:07 +0200" (added in PHP 4.0.4)

s - seconds; i.e. "00" to "59"

S - English ordinal suffix, textual, 2 characters; i.e. "th", "nd"

t - number of days in the given month; i.e. "28" to "31"

T - Timezone setting of this machine; i.e. "MDT"

U - seconds since the epoch

w - day of the week, numeric, i.e. "0" (Sunday) to "6" (Saturday)

W - ISO-8601 week number of year, weeks starting on monday (added in PHP 4.1.0)

(Saturday)

Y - year, 4 digits; i.e. "1999"

y - year, 2 digits; i.e. "99"

z - day of the year; i.e. "0" to "365"

Z - timezone offset in seconds (i.e. "-43200" to "43200"). The offset for timezones west

of UTC is always negative, and for those east of UTC is always positive.

=========================================================================================

echo date ("l dS of F Y h:i:s A");

echo "July 1, 2000 is on a " . date ("l", mktime(0,0,0,7,1,2000));

PHP: Function to call JS-Alert <?php

function FPHP_js_alert($valert) {

echo "<SCRIPT LANGUAGE=\"javascript\">\n";

echo "<!-- In HTML – Kommentar eingebundenes JavaScript\n";

echo " window.alert('$valert')\n";

echo " // -->\n";

echo "</script>\n";

flush();

}

?>

<?php FPHP_js_alert("Your message"); ?>

PHP: test.php <?php

$vret_code = 10;

return $vret_code;

?>

<a href="newpage.php?<?print $query ?>"Go</a>

PHP: if-Anweisung if ( !isset( $bob ) ) {

$bob= array();

};

session_register('bob');

=========================================================================================

if ( Ausdruck ) {

# Anweisungen

Page 40: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 40 Author: A. Balogh

{

else {

# Anweisungen

}

=========================================================================================

if ( 1=1 ) {

# Anweisungen

{

elseif ( 1 = 2 ) {

# Anweisungen

}

else {

# Anweisungen

}

=========================================================================================

$vnox = " ";

if ( trim($vnox) <= "" ) {

print "JA";

}

else {

print "Nein";

}

=========================================================================================

PHP: switch ( select )

switch ( $i ) {

case 0:

print "i equals 0";

break;

case 1:

print "i equals 1";

break;

case 2:

print "i equals 2";

break;

default:

print "i is not equal to 0, 1 or 2";

}

PHP: Reverse a string function reverseNumbersOnly(inString) {

tempVar = '';

for (i=inString.length-1;i>-1;i--)

{ if (inString.charAt(i)==parseInt(inString.charAt(i)))

{ tempVar+=inString.charAt(i); }

}; return tempVar;

}

string strrev ( string string)

Returns string, reversed.

<php

echo strrev("Hello world!"); // outputs "!dlrow olleH"

?>

Page 41: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 41 Author: A. Balogh

PHP: Mit FORM Variable übergeben 001 =========================================================================================

###############

# test1.php

###############

<html>

<body>

<FORM method=post action="test2.php">

Email: <INPUT name="email" type="text"><br>

Message:<br>

<TEXTAREA name="message"></textarea><br>

<input type=submit>

</FORM>

</body>

</html>

=========================================================================================

###############

# test2.php

###############

<?php

print "Variable EMAIL: ".$email;

print "Variable MESSAGE: ".$message;

mail( "[email protected]", "Feedback Form Results", $message, "From: $email" );

header( "Location: http://www.a1-it.ch/index.html" );

?>

=========================================================================================

PHP: Mit FORM Variable übergeben 002 =========================================================================================

###############

# test1.php

###############

<form action="test2.php" method="get">

<select name="vselect_1" multiple>

<option value="computer" > computer </option>

<option value="monitor" > monitor </option>

<option value="camera" > camera </option>

<option vaue="printer" > printer </option>

</select>

<input type="submit" name="vsubmit" value="OK">

</form>

=========================================================================================

###############

# test2.php

###############

<?php

while( list($key, $var) = each($HTTP_GET_VARS)) {

if ( is_array($var) ) {

for($a=0;$a<count($var);$a++)

echo $key." = ".$var[$a]."<br>\n";

}

else {

echo $key." = ".$var."<br>\n";

}

}

?>

PHP: Mit FORM dateien uploaden <form action="file-upload.php" method="post" enctype="multipart/form-data">

Send these files:<br>

<input name="userfile[]" type="file"><br>

<input name="userfile[]" type="file"><br>

<input type="submit" value="Send files">

</form>

Page 42: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 42 Author: A. Balogh

PHP: Programmiertechniken Server: Sessiondaten werden auf dem Server entweder in Textdateien, in Datenbanken oder im Prozessspeicher des Webservers gespeichert. Client Die Daten werden entweder als Cookie oder als GET/POST-Vartiablen von Skript zu Skript weitergereicht.

PHP: Parameterübergabe/Sitzungs-ID's Session.autostart() Setzt ein COOKIE.

Verhalten ueber PHP.INI: session.cookie_lifetime

session.auto_start()

enable-trans-sid

Session_start()

Session_register() Variablen registrieren ( session_save_path() )

Führt ebenfalls session_start() durch falls noch nicht erfolgt.

Note: It is not currently possible to register resource

variables in a session. For example, you can not create a

connection to a database and store the connection id as a

session variable and expect the connection to still be valid the

next time the session is restored. PHP functions that return a

resource are identified by having a return type of resource in

their function definitions. A list of functions that return

resources are available in the resource types appendix.

Session_unregister() Variablen löschen

session_is_registered() Überprüft eine Variable True/False

Session_destroy() Session beenden und alle Sitzungsvariablen auflösen.

Session_encode() Gibt die serialisierten Variablen der aktuellen Session zurück.

Session_unset() Löscht alle Variablen.

Session_name() Gibt den Namen zurück oder startet die Session mit dem

angegebenen Namen

Session_id() Gibt die aktuelle Session ID zurück oder öffnet die Session mit

der angegebenen Session ID.

Cookies POST/GET -> $QUERY_STRING Global define

PHP: TOOLS

PHP-Coder PHP-Entwicklungsumgebung von: ST Software www.stsoft.cjb.net

PHP-NUKE 1. Alles nach htdocs/PHP_NUKE kopieren 2. mysqladmin –u root –pxxx create nuke 3. mysql -u root -pxxxx nuke < nuke.sql 4. http://localhost/PHP_Nuke/html/Admin.php

Login Userid: God Password: Password 5.

WDDX What is WDDX? WDDX is an XML-based technology that enables the exchange of complex data between Web programming languages, creating what some refer to as 'Web syndicate networks'. WDDX consists of a language-independent representation of data based on an XML 1.0 DTD, and a set of modules for a wide variety of languages that use WDDX. WDDX can be used with HTTP, SMTP, POP, FTP and other Internet protocols that support transferring textual data.

Page 43: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 43 Author: A. Balogh

Page 44: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 44 Author: A. Balogh

SMARTY Smarty is a template engine for PHP.

To make PHP-Scripts independent of the layout.

Application logic = PHP

Presentation logic = SMARTY

SMARTY: Requirements PHP 4.06 or higher

SMARTY: Libraries / Files \smarty\Smarty.class.php \smarty\Smarty_Compiler.class.php \smarty\Config_File.class.php \smarty\debug.tpl \smarty\plugins\*.php (all of them) \templates \templates_c Content created/compiled by Smarty! \configs \cache \index.php

SMARTY: File Permissions chown –R nobody:nobody /web/www.balogh.ch/smarty/templates_c chmod –R 777 /web/www.balogh.ch/smarty/templates_c ls –all templates_c *** Anzeige der Berechtigungen chown –R nobody:nobody /web/www.balogh.ch/smarty/cache chmod –R 755 /web/www.balogh.ch/smarty/cache ls –all cache *** Anzeige der Berechtigungen drwxr-xr-x 7 guidoisler site14 1024 Mar 2 2003 Smarty

drwxr-xr-x 4 guidoisler site14 1024 Mar 2 2003 admin

-rwxrwxrwx 1 guidoisler site14 212 Mar 2 2003 aktuell.txt

-rwxrwxrwx 1 guidoisler site14 6 Mar 2 2003 anlaesse.txt

drwxr-xr-x 2 guidoisler site14 1024 Mar 2 2003 cache

drwxr-xr-x 2 guidoisler site14 1024 Mar 2 2003 configs

drwxr-xr-x 2 guidoisler site14 1024 Mar 2 2003 html

drwxr-xr-x 2 guidoisler site14 3072 Mar 2 2003 images

-rw-r--r-- 1 guidoisler site14 1999 Mar 3 2003 index.php

drwxr-xr-x 2 guidoisler site14 1024 Mar 3 2003 templates

drwxrwxrwx 11 guidoisler site14 1024 Mar 3 2003 templates_c

SMARTY: SETUP

Basic

Index.php <?php

define("SMARTY_DIR", "d:/data/webs/a1-it/smarty/");

require_once(SMARTY_DIR."Smarty.class.php");

$smarty = new Smarty();

Page 45: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 45 Author: A. Balogh

$smarty->template_dir = 'd:/data/webs/a1-it/templates/';

$smarty->compile_dir = 'd:/data/webs/a1-it/templates_c/';

$smarty->config_dir = 'd:/data/webs/a1-it/configs/';

$smarty->cache_dir = 'd:/data/webs/a1-it/cach/';

$smarty->assign('name', 'Albert');

$smarty->display('index.tpl');

?>

Extended

Index.php <?php

require('/setup.php');

$smarty = new Smarty_A1IT;

$smarty->assign('name', 'Albert'); ➔ Variable $name definieren

$smarty->display('index.tpl');

?>

Setup.php <?php

define("SMARTY_DIR", "d:/data/webs/a1-it/smarty/");

require_once(SMARTY_DIR."Smarty.class.php");

class Smarty_A1IT extends Smarty {

function Smarty_A1IT() {

$this->Smarty();

$this->template_dir = 'd:/data/webs/a1-it/templates/';

$this->compile_dir = 'd:/data/webs/a1-it/templates_c/';

$this->config_dir = 'd:/data/webs/a1-it/configs/';

$this->cache_dir = 'd:/data/webs/a1-it/cach/';

$this->caching = true;

$this->assign('app_name','A1-IT');

}

}

?>

SMARTY: SYNTAX {* This is a comment *} Kommentar {include file='header.tpl'} Include {if $name eq 'Fred'} if then else You are not allowed here! {else} Welcome to this site! {/if} <SELECT name=company> {html_options values=$vals selected=$selected output=$output}

Page 46: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 46 Author: A. Balogh

</SELECT> {html_select_date display_days=yes} Comfortable anzeige von Dropdowns {literal} {/literal} Alles dazwischen wird nicht interpretiert. Z.B. für JavaScript {$smarty.get.page} Display Values from GET {$smarty.post.page} Displays Values from POST {$smarty.cookies.username} {$smarty.server.SERVER_NAME} z.B. A1IT {$smarty.env.PATH} {$smarty.session.id} {$smarty.request.username} {$smarty.now¦date_format:'%Y-%m-%d %H:%M:%S'} {$smarty.const._MY_CONST_VAL} {$smarty.capture} {$smarty.section} {$smarty.foreach} {$smarty.template} Aktuell verarbeitetes template

SMARTY: DEBUGGING $smarty->compile_check = true; $smarty->debugging = true;

SMARTY: EXAMPLES <?php

// ***********************************************************

// START: Smarty initialisierung

// ***********************************************************

define('SMARTY_DIR','d:/data/webs/a1-it/smarty/');

require(SMARTY_DIR."Smarty.class.php");

$smarty = new Smarty;

$smarty->template_dir = "d:/data/webs/a1-it/templates";

$smarty->compile_dir = "d:/data/webs/a1-it/templates_c";

$smarty->config_dir = "d:/data/webs/a1-it/configs";

$smarty->cache_dir = "d:/data/webs/a1-it/cache";

// END: Smarty initialisierung

// ***********************************************************

// ***********************************************************

// START: Smarty debugging options

// ***********************************************************

// $smarty->compile_check = true;

// $smarty->debugging = true;

// END: Smarty debugging options

// ***********************************************************

// ***********************************************************

// START: PHP Verarbeitung

// ***********************************************************

if ( $text1 == "test" ) {

$text1 = "OK";

}

// END: PHP Verarbeitung

// ***********************************************************

// ***********************************************************

// START: Smarty Werte zuweisen

// ***********************************************************

Page 47: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 47 Author: A. Balogh

$smarty->assign("text1", $text1);

// END: Smarty Werte zuweisen

// ***********************************************************

$smarty->display('test.htm');

?>

BEISPIELE In *.TPL {$smarty.server.SERVER_NAME} Zeigt den ServerNamen an z.B. www.a1-it.ch {$smarty.env.PATH}

{$smarty.now|date_format:'%Y-%m-%d %H:%M:%S'} ➔ 2004-09-26 10:28:56

{$smarty.now|date_format:'%d.%m.%Y %H:%M:%S'} ➔ 26.09.2004 10:30:50

{$title|upper} ➔ Variable in Grossbuchstaben ausgeben

Page 48: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 48 Author: A. Balogh

PEAR

PEAR (PHP Extension and Application Repository) ist ein zentrales Archiv für Klassen und

Bibliotheken in PHP mit einem hohen Wiederverwendungswert. Innerhalb von PEAR existiert

darüber hinaus PECL, in dem Erweiterungen für PHP, die in C und C++ geschrieben sind,

enthalten sind.

PEAR ist Malin Bakken gewidmet. Die ersten Bestandteile vom PEAR wurden kurz vor ihrer

Geburt geschrieben.

Der Zweck von PEAR ist die Verbreitung nützlicher, geprüfter und qualitativ hochwertiger

objekt orientierter Skripte (Packages) in PHP und Erweiterungen in C, die von allen PHP-

Entwicklern genutzt werden können.

Gleichzeit sollen die Standards, die in PEAR definiert werden, dazu dienen, dass Entwickler

Code schreiben können, der portabel, auf vielen anderen Systemen und Konfigurationen

einsetzbar und gut lesbar ist.

Wer ein Package zu PEAR beisteuern will, der sollte die Mailingliste [email protected]

abonnieren und sich mit den PEAR Coding Standards auseinandersetzen.

Installation: go-pear.php

To use PEAR without any problems you need to add your PEAR Installation path

(g:\www\apache2\htdocs\PEAR)

to your include_path.

include_path=".;g:\www\apache2\htdocs\PEAR\; g:\www\apache2\htdocs\catalog\";

Page 49: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 49 Author: A. Balogh

JAVA

JAVA: Einführung Java ist eine Objektorientierte, Interpreter-Programmiersprache Versionen; Java 1.1, Java 2.0 Syntax: Ähnlich C++ 1991 entwickelt durch SUN. Geplant um Geräte zu steuern. http://java.sun.com JavaBean

JAVA: IDE's Java WorkShop von Sun Visual Café von Symantec Jbuilder von Inprise Java und das Internet Der Benutzer lädt Java-Bytecode aus dem Internet und führt in auf seinem PC aus. Syntax Achtung: Gross & Kleinschreibung wird berücksichtigt. Java-Applet: Kleine Software Anwendung, die in der Programmiersprache Java geschrieben ist. PlugIn: Spezielle Software die heruntergeladen werden kann und sich im Browser einklinkt. z.B. Flash von Macromedia

Page 50: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 50 Author: A. Balogh

JavaScript ( JS ) Nicht zu verwechseln mit Jscript oder Java selbst.

ACHTUNG! Sowohl in Netscape wie auch in Microsoft Internet Explorer gibt es die Möglichkeit JavaScript abzuschalten!

- IE: Extras/Internetoptionen/Sicherheit/Active Scripting

JS: Einführung JS ist eine Skriptsprache welche früher LiveScript genannt wurde. Mit JS greifen Sie auf Web-Clients(Browser) zu, mit Java auf Web-Server, Von Netscape eingeführt, Lizenziert. Bibliotheken nennt man die JavaScript Funktionssammlungen ( .js ).

➢ Werden nicht kompiliert, ➢ Werden direkt durch den JavaScript Interpreter des Browsers ausgeführt. ➢ Laufen Client oder Serverseitig ➢ Sollen Webseiten nutzerfreundlich gestalten und mehr Action reinbringen ➢ Nicht für Formularanfragen gedacht. ➢ Erscheinungsbild und Attribute von HTML-Befehlen beeinflussen ➢ Mit JavaScript können nicht die typischen Aufgaben von CGI-Script gelöst werden.

Mit JS können sogenannte Maus-Rollover erstellt werden. Dazu werden zwei Bilder benötigt, eines, dass als Standard angezeigt wird, und ein anderes, dass als Antwort auf das Ereignis mouseOver angezeigt wird. Bilder erhält man:

• durch downloads aus dem Internet z.B. http://www.gograph.de

• erstellen eines Navigationsbuttons und ändern der Farbe des Buttons

• die on/off Bilder sollten voraus geladen werden, um lange Ladezeiten zu vermeiden.

Als Erweiterung zur HTML erlaubt JavaScript es Ihnen, auf alle Komponenten zuzugreifen, aus denen eine Webseite besteht, und sie zu manipulieren. Document Object Model (der Teil der Sprache, der definiert, welche Komponenten oder Objekte Sie mit JS beeinflussen können.

NS DOM: http://developer.netscape.com/tech/dom/ MS DOM: http://msdn.microsoft.com/workshop/author/dhtml/reference/objects.asp

Webseite-Komponenten: - Links, Bilder, PlugIns, HTML-Formular-Elemente, Details Browserkonfiguration.

JS: Versionen JavaScript 1.0 JavaScript 1.1 JavaScript 1.2 JavaScript 1.3

JS: Links Serverseitiges JavaScript: http://developer.netscape.com/docs/manuals/ssjs/1_4/contents.htm Bibliotheken: http://developer.netscape.com/docs/technote/dynhtml/collapse/index.html

Page 51: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 51 Author: A. Balogh

JS: EventHandler Schnittstelle zwischen JavaScript und HTML sind die EventHandler (onClick etc.). EventHandler beginne mit einem führenden "on...". onAbort Image Das Laden des Bildes wird unterbrochen

onBlur

Bezieht sich auf das Konzept "Focus".

onBlur Button, Checkbox, Fileupload, Wenn ein anderes Element angeklickt wird.

Layer, Password, Radio, Reset,

Select, Submit, Text, Textarea,

Window

onChange

Fileupload, input, select, text, textarea

onChange="FJS_x(this.value);"

onChange="FJS_x(.., ..); FJS_Function2(.., ..); FJS_Function3(.., ..); "

onchange=form_submit('','newSearch')

onchange="alert(this.value);"

onChange="showimage()"

onChange="NEW_URL='x.php'+document.formular.element.value;window.location.href=NEW_URL;"

onClick Button, Document, Checkbox

Link, Radio, Reset, Submit

onDblClick Document, Link Achtung! Wird vom Macintosh nicht

unterstützt.

onError Image, Window

onFocus

Wird ausgeführt wenn das Objekt den Fokus erhält.

onKeyDown

onKeyPress

onKeyUp

onLoad

<body onload="window.alert("TestHallo");">

<body onload="window.document.Frm_Main.vcountry_idx.focus ();">

onMousedown

onMouseout

onMouseout="window.status='';return true;"

onMouseOver

<a>

Wir oft kombiniert mit onMouseOut.

onMouseOver="window.status='Klicken Sie, um mehr über uns zu erfahren!'; return true;"

onMouseUp

onMove

onReset

onResize

onSelect

Wird ausgewählt wenn ein Anwender Text in einem Element auswählt.

onSubmit

onUnload

body

onunload="window(alert("TestByBy");">

Java applets haben den Dateinachnamen class

<script language="JavaScript"> JavaScript-Interpreter

...

</script>

Page 52: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 52 Author: A. Balogh

=========================================================================================

<script language="JavaScript" SRC=dateipfad/meinscript.js">

<applet code="code.class" codebase="Pfad" width="129" height="24">

<param name=".." value="..">

<param name=".." value="..">

<param name=".." value="..">

</applet>

=========================================================================================

<META HTTP-EQUIV="CONTENT-SCRIPT-TYPE" CONTENT="text/javascript">

<script language="JavaScript" src="rechnung.js"> </SCRIPT>

Page 53: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 53 Author: A. Balogh

JS: Objekte

JS: Document Object Model (DOM)

document.getElementsByName() Damit kann jedes HTML-Elemente angesprochen

werden, dass ein name-Attribut hat. document.getElementsById() Damit kann jedes HTML-Elemente angesprochen

werden, dass eine ID hat.

document.getElementsByTagName() Damit kann jedes HTML-Elemente angesprochen

werden, ohne ID- oder Name-Attribut.

date

var date = new Date();

var hh = date.getHours();

var tm = date.getMinutes();

var month = date.getMonth();

window

(frame, parent, self, top) // alles Synonyme für window

window.document // Wird mit dem HTML-Tag <BODY .. </BODY> erstellt.

window.document.all.elementID.style.styleAttributName

window.document.all.tdID

window.document.applets[0]

window.document.cookie

window.document.images

window.document.links[0].port //Bezieht sich auf die <a href's

window.document.links[0].search //Bezieht sich auf die <a href's

window.document.links[0].hostname //Bezieht sich auf die <a href's

window.document.links[0].href //Bezieht sich auf die <a href's

window.document.links[0].target //Bezieht sich auf die <a href's

window.document.meinFormular.buttonEins.Click()

window.document.meinFormular.IhrName.value

window.document.writeln(i)

window.document.write(builtInScroll)

window.document.write("Xxx")

window.document.write("Test &lt;true&gt;"); // Test <true>

window.document.frm_Test.sel_year.focus(); // Feld erhält focus

window.document.frm_Test.sel_year.select(); // Feld Markieren

window.document.frm_x.vfield1.disabled = false;

window.document.embeds[0]

window.alert("Test\n") \n erzwingt Zeilenumbruch

window.alert(window.document.frm_Test.sel_year.length); // Anzahl elemente in select

window.alert(window.document.frm_Test.sel_month.selectedIndex);

window.alert(window.document.forms[0].elements[0].value);

window.alert(window.document.frm_name.elementID.value); // Einzelnes Element abfragen

window.confirm()

if ( window.confirm("Abfrage?") ) {

alert("Positiv");

}

window.event.keyCode z.B 13 = Enter

window.location = "script.php"

window.location.href = "script.php?PHPSESSID=xxx&refresh=+ + vdatum.getTime()

Die Dummy Variable refresh sorgt dafür, dass die

augrefufene Seite in jedem Fall erneut angezeigt wird!

window.location.replace() Sorgt dafür, dass die aktuelle Seite nicht mehr über den

Back-Button erreichbar ist!

window.maximize = fullscreen()

Page 54: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 54 Author: A. Balogh

window.moveTo(50,100) // Window platzieren

window.navigate("http://127.0.0.1/" + vparm1 + vsession_id);

window.open ('URL','Name','Parameter')

window.open('http://www.a1-it.ch/index.html','mywindow','Parameter')">

Parameter:

width=400,

height=200

channelmode=No/Yes sets if the window appears in channel mode

fullscreen=No/Yes

menubar=no/yes

scrollbars=no/yes

toolbar=no

directories=no

location=no

status=yes

resizable=no

left=100

top=100

screenX=100

screenY=100

alwaysLowered immer im Hintergrund

alwaysRaised immer im Vordergrund

dependent als Child

directories

hotkeys

innerHeight

window.prompt ('Testabfrage')

elements // Typen: hidden, text, checkbox, select-multiple

// select-one, submit, radio, button, fileupload,

// reset, textarea

elem.style.fontweight ="bold"

myform.elements[i].disabled = true;

event.keyCode

event.which

forms

history

back

image

navigator // Bezieht sich immer auf den ausführenden Browser.

navigator.userAgent // IE6.0 <Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0>

navigator.appVersion // Browser Version

// IE6.0 => <4.0 (compatible; MSIE 6.0; Windows NT 5.0)>

// NS4.76 => <4.76 [en] (Win98; U)>

// NS7.01 => <5.0 (Windows; en-US)>

navigator.appName // Browser

// IE6.0 => <Microsoft Internet Explorer>

// NS4.76 => <Netscape>

navigator.plugins[] // navigator.plugins["LiveAudio"][0]

navigator.plugins.length //

navigator.mimeTypes // var X = (navigator.mimeTypes["video/mpeg"] != null);

selectObj.options[2] = null

selectObj.options.length = 3

selectObj.options[4] = new Option("Yahoo",http://www.yahoo.com)

selectObj.options[4].defaultSelected

selectObj.options[4].index

selectObj.options[4].Selected

selectObj.options[4].text

Page 55: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 55 Author: A. Balogh

selectObj.options[4].value

selectObj.options[4].defaultSelected

Example: Creating a new Select-list

myselect = new SelectList(100,100,150,18)

myselect.list.add('zero','item 0')

myselect.list.add('one','item 1')

this

this.style.color='black'

this.moveTo(0,0)

this.outerWidth = screen.availWidth

this.outerHeight = screen.availHeight

Zeichenkette/String

Zeichenkette.toLowerCase()

Zeichenkette.toUpperCase()

Zeichenkette.indexOf("abc") // liefert die Pos. von "abc"

Zeichenkette.concat(vstr1, vstr2) // Zechenkett oder Arrays verbinden

Zeichenkette.substring(14,19) // Anfansposition, Endpoition!

Zeichenkette.replace("a","b")

Page 56: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 56 Author: A. Balogh

JS: Syntax

JS: Einbindung:

Fügt man ein Skript in den Abschnitt HEAD eines HTML-Dokumentes ein, wird das Skript sofort ausgeführt, noch bevor der Browser überhaupt den Abschnitt BODY des HTML-Dokumentes anzeigen kann. Diese Technik erlaubt es JS zum verändern des Body's einer Webseite einzusetzen. <!— --> Ausblenden des JavaScripts, falls ein Browser diesen nicht interpretieren kann.

// Kommentar Operator von JavaScript

Es gibt in JS keine Zeichen zum Fortsetzen einer Zeile!

JS: Standard Header <script> <html>

<head>

<script language="JavaScript">

<!-- In HTML – Kommentar eingebundenes JavaScript

function FJS_xx1() { // JS-Function

...

return;

}

// -->

</script>

</head>

<body>

</body>

</html>

JS: Extended Header <script> <html>

<head>

<script language="JavaScript"

type="MimeType"

src="NameDerQuellDatei"

charset="ISO-Zeichensatz">

<!-- In HTML – Kommentar eingebundenes JavaScript

function FJS_Test1() { // JS-Function

...

return;

}

// -->

</script>

</head>

<body>

</body>

</html>

JS: Variablendeklaration. // Variablen deklariert innerhalb einer Function sind nur dort gültig!

var i==0

var A=10, B=5, c=15

var is = new is() // Erzeugt eine neue Instanz des Objektes

var MeineKatze = "Wuschel"

var Varray = new Array("X1", "X2") // Array

var Varray = new Array(51) // Array

var Vboolean = False/True

var Vdate = new Date()

var agt=navigator.userAgent.toLowerCase()

Page 57: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 57 Author: A. Balogh

typeof // Gibt den variablentyp zurück z.B. string

void() // nichts tun!

JS: Kommentare // Einzeiliger Kommentar

/* .. */ Mehrzeiliger Kommentar

JS: Operatoren. %

++

--

-

+

; // trennt JS-Anweisungen in einer Zeile

,

=

+= 10

-= 10

*=

/=

%=

(Bed) ? : // (Bedingung) ? true-anweisung : false-anweisung

¦¦ // Logisches Oder

&& // Logisches Und

== // Gleichheit prüfen

!= // Nicht gleich

\n // Zeilenumbruch

\f // Wagenrücklauf";

\b // Backspace";

\r // DOS-Extra-Zeilenumbruch";

\t // Tabulator";

\" // Anführungszeichen";

JS: with document.writeln(document.lastmodified)

document.writeln(document.location)

document.writeln(document.title)

with (document) {

writeln(lastmodified)

writeln(location)

writeln(title)

}

JS: for .. for ( Ausdruck; Bedingung; Update ) {

Anweisung1

}

for ( var i=1; i<=10; i++ ) {

document.writeln(i)

}

JS: while while( Bedingung) {

..

if ( 1=1 ) {

break // Bricht die Schleife ab

{

else }

continue // Zurück an den Anfang der Schleife

}

}

JS: do while do {

..

}

while ( Bedingung )

Page 58: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 58 Author: A. Balogh

JS: if .. else if ( x==6 ) {

..

}

else {

..

}

=========================================================================================

if ( x==6 && y=10 ) { // AND

if ( x==6 || x=7 ) { // OR ([Alt Gr] + 7)

=========================================================================================

if ( x=6 ) { // ACHTUNG! weist x=6 zu!!!!!

..

}

=========================================================================================

if ( V1 == null ) { // Test auf null

}

=========================================================================================

if (x == y) {

Anweisung1 // Kommentar: Strichpunkte(;) sind optional ausser

Zahl = 42; Zahl2 = 40; // es sind zwei Anweisungen in einer Zeile!

..

}

JS: switch / case ACHTUNG break beendet die ganze function!

switch ( Variable ) {

case "A" :

alert("Fall_1");

break;

case "B" :

alert("Fall_2");

break;

default :

alert("Fall_Default");

}

JS: this function FJS_Test1(Eingabe1) {

this.name=Eingabe1

if (The_Form.zip_code.value.length != 5) {

alert("The Zip code must be 5 digits!");

JS: return false <a href="ohneJS.html" onClick="location.href='mitJS.html'; return false"> Test</a>

JS: prompt Zeigt eine Dialogbox an mit den Knöpfen OK und Abbrechen.

window.prompt ( String, Vorgabe)

Anweisung1

Page 59: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 59 Author: A. Balogh

JS: confirm() Zeigt eine Dialogbox an.

if ( confirm("jhgjhgjhg") ) {

alert("xxx");

}

else {

alert("hghjg");

}

JS: Numeric values parseInt() Versucht einen Wert in eine Ganzzahl umzuwandeln. Gibt entweder die

Ganzzahl oder NaN zurück.

parseInt("42") // Ergebnis 42

parseInt("42.33 // Ergebnis 42

parseFloat() Versucht einen Wert in eine Dezimahlzahl umzuwandeln.

parseFloat("42") // Ergebnis 42

parseFloat("42.33 // Ergebnis 42.33

(""+ 2500) // Ergebnis gibt die Zahl als String zurück!

isNaN() Gibt TRUE zurück wenn keine Zahl oder "Not a Number(NaN)"!

Page 60: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 60 Author: A. Balogh

JS: OBJECT mit EIGENSCHAFTEN / METHODE function FJS_Obj1(V1_i, V2_I, V3_i) {

this.V1=V1_I "this" bezieht sich auf FJS_Obj1

this.V2=V2_i

this.V3=V3_i

this.M1= FJS_Obj2(this.V1) Methode

}

function FJS_Obj2(V1_i) {

if (V1_I = "Test" ) {

document.writeln(V1_I)

}

}

Test = new FJS_Obj1("Wert1", "Wert2", "Wert3") Neue Instanz erzeugen mit new

Test.M1 Methode aufrufen!

JS: Date var heute = new Date()

var stunden = heute.getHours()

var minuten = heute.getMinutes()

JS: write write "<FORM NAME=\"myForm\" ACTION=\"thisPage.html\" METHOD=POST>";

write "<input name=\"search\" size=30 maxlength=60>";

write "</FORM>";

JS: Funktionen clearTimeout() Stoppt die Ausführung von Code welche

mit setTimeout gestartet wurde

parseInt() // Zahlenkette in Integer umwandeln

indexOf("x") // Wert suchen

getTime()

getMinute()

getMonth()

getSeconds()

getDate()

getDay()

getFullYear()

getHours()

setInterval()

getMilliseconds()

getMinutes()

getMonth()

getSeconds()

getTime()

getUTCDate()

getUTCFullYear()

getUTCHours()

getUTCMonth()

getUTCSeconds()

getYear()

parse()

reload()

self.location.reload();

replace(parameter, text)

field.replace("'", "");

setDate()

setFullYear()

setHours()

setMilliseconds()

setMinutes()

setMonth()

setSeconds()

setTime()

setTimeout()

setUTCDate()

setUTCFullYear()

setUTCHours()

setUTCMilliseconds()

Page 61: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 61 Author: A. Balogh

setUTCMinutes()

setUTCMonth()

setUTCSeconds()

setYear()

toGMTString()

toLocalString()

toString()

toUTCString()

UTC()

Page 62: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 62 Author: A. Balogh

JS: Beispiele

JS: Neues Fenster öffnen ohne die eigene Site zu verlassen. <html>

<script language="JavaScript">

function FJS_popitup() {

var neuesFenster = open("http://www.telefonbu.ch", "zweitesFenster",

"scrollbars, resizable, width=500, height=400");

}

</script>

<body>

<a href="javascript:FJS_popitup()">Testlink?</a>

oder

<a href="javascript:void FJS_popitup(vparm1, vparm2)">Testlink?</a>

</body>

</html>

JS: Faltbarer Index http://devedge.netscape.com/evangelism/tools/xbCollapsibleLists/

JS: Radio Button abfragen function FJS_1() {

var v1 = window.document.frm_003_1_01.vsharex[0].checked;

var v2 = window.document.frm_003_1_01.vsharex[1].checked;

return;

}

<body>

<input type="radio" name="vr1" value="1" checked> onClick="FJS_1();"> Shared

<input type="radio" name="vr1" value="2" onClick="FJS_1();"> Dedicated

JS: Passwortschutz <script language="JavaScript">

function FJS_liespasswort() {

var passwort = prompt("Bitte geben Sie ein Passwort ein:\('geheim'\)", "xxxx");

if (passwort == "geheim") {

document.writeln("<body><h1>Glückwunsch!</h1>

Ihr Passwort wurde akzeptiert.

Viel Spass auf unserer Site.

Hier folgt der Site Code!

</body>");

}

else {

document.writeln("<body><h1>Tut uns leid!</h1>

Sie haben versucht unsere Site mit einem falschen

Passwort zu betreten.

Bitte drücken Soie die Schaltfläche <b>Zurück</b>

Bei Ihrem Browser und versuchen Sie es erneut.

</body>");

}

}

</script>

<body onLoad="FJS_liespasswort();">

JS: location =========================================================================================

<script language="JavaScript">

parent.location.href='<?php echo $to; ?>';

parent.location.href='FW_KPI_005_1.php';

</script>

=========================================================================================

<script language="JavaScript">

function anzeigenMeldung(message) {

window.status=message

Page 63: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 63 Author: A. Balogh

}

</script>

JS: Site als Main-Frame anzeigen! <script language="JavaScript">

if (top != self ) {

top.location.href = location.href;

}

</script>

JS: bilder voraus laden <script language="JavaScript">

function bilderLaden() {

if (document.images) { // überprüft ob IMG Tags im Dokument enthalten sind.

var bildDateien = bilderLaden.arguments;

var arrayLaden = new Array();

for (var i=0; i < bildDateien.length; i++) {

arrayLaden[i] = new Image;

arrayLaden[i].src = bildDateien[i];

}

}

}

bilderLaden('logo.gif', 'test.gif');

</script>

JS: bilder tauschen (rollover) <script language="JavaScript">

function tauschen( id, newsrc ) {

var dasBild = findeBild(id);

if (dasBild) {

dasBild.src = newsrc;

}

function findeBild(name) {

var dasBild = false;

if (document.images) {

dasBild = document.images[name];

}

if (dasBild) {

return dasBild;

}

return false;

}

</script>

<body>

<a href="xxx.html"

onMouseOut ="tauschen('bild1','bild1_weiss.gif'); return true;"

onMouseOver="tauschen('bild1','bild1_grau.gif'); return true;"

>

<img name="bild1" src="bild1_weiss.gif">

</body>

Page 64: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 64 Author: A. Balogh

JS: Einfacher "rollover" <body>

<a href="xxx.html"

onMouseOut ="this.style.color='red';"

onMouseOver ="this.style.color='red'";

>

<img name="bild1" src="bild1_weiss.gif">

</body>

JS: IMAGE mit Kontext <img src="../images/apache_pb.gif" title="test" alt="testsplash"

onMouseOver="window.status='Klicken Sie, um mehr über uns zu erfahren!'; return true;"

onMouseout="window.status='';return true;"

>

Page 65: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 65 Author: A. Balogh

JS: Submit FORM automatically! <script language="JavaScript">

<!-- Hide JavaScript

function FJS_submitIt() {

document.form_NO.submit();

or

document.forms[0].submit(); // as well.

}

// -->

</script>

<html>

<body>

<form method="POST" name="form_NO" action="test1.php">

<select size="1" name="vnox" onChange="FJS_submitIt();">

<?php echo "$vno_block"; ?>

</select>

</form>

</body>

</html>

JS: FORM mit Verzweigung zu Link!

<html>

<script>

function FJS_call_do(vparm1) {

var myform = document.frm_1;

switch ( vparm1 ) {

case "B1" :

alert("Fall_B1");

myform.action="http://www.js-examples.com/";

break;

case "B2" :

alert("Fall_B2");

myform.action="http://www.js-examples.com/consult";

break;

default :

alert("Fall_Default ["+vparm1+"]");

}

myform.submit();

}

</script>

<body>

<form name="frm_1">

<input type="button" name="txtbutton" value="B1" onClick=" FJS_call_do (this.value)">

<input type="button" name="txtbutton" value="B2" onClick=" FJS_call_do (this.value)">

ACHTUNG bei Hochkomma: onClick=" FJS_call_do ('A1') ">

</form>

</body>

</html>

Page 66: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 66 Author: A. Balogh

JS: Count Checkboxes/RadioBoxes Selected <script>

function cntprimary(cnt){

cnt=0;

for(i=1; i<=8; i++){

var enc=eval("document.nameofform.checkbox"+i+".checked");

if(enc){

cnt++;

}

}

return cnt;

}

</script>

<form name=nameofform>

<input type="radio" name="checkbox1" value="check me">

<input type="radio" name="checkbox2" value="check me">

<input type="radio" name="checkbox3" value="check me">

<input type="radio" name="checkbox4" value="check me">

<input type="radio" name="checkbox5" value="check me">

<input type="radio" name="checkbox6" value="check me">

<input type="radio" name="checkbox7" value="check me">

<input type="radio" name="checkbox8" value="check me">

</form>

<BR><a href="javascript:alert(cntprimary())">how many?</a>

JS: Elements listen

var myform = window.document.frm_004_1_1;

for (var i=0; i < myform.elements.length; i++) {

if ( myform.elements[i].type == "text" ) {

alert ("Testlisting ***" + myform.elements[i].value + "***");

}

}

JS: PHP & JS <head>

<script LANGUAGE="JavaScript">

function redirect() {

window.location = "http://yourURL.com?

<?php echo $variable1 ?>&

<?php echo $variable2 ?>"

}

setTimeout("redirect();", 4000)

</script>

</head>

<body bgcolor="#ffffff" text="#000000" id=all>

<?php

echo( "Welcome to my site, $variable1!" );

?>

<br>

If you are not redirected shortly,

<a href="http://yourURL.com?<?php echo $variable1?>&<?echo $variable2?>">Click Here</a>

Page 67: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 67 Author: A. Balogh

</body>

</html>

JS: Detect Screen sizes <html>

<head>

</head>

<body>

<script type=text/javascript>

var isIE5 = document.all;

var isIE4 = document.all; // who is using this anyways?

var isNet4 = !isIE5; // just assume... i know .. i know... ;-)

function getWindowWidth() {

if (isNet4) return(window.innerWidth);

if (isIE5) return(document.body.clientWidth);

if (isIE4) return(400);

return(-1);}

function getWindowHeight() {

if (isNet4) return(window.innerHeight);

if (isIE4) return(document.body.clientHeight);

return(-1);}

function getPageWidth() {

if (isNet4) return(document.width);

if (isIE4) return(document.body.scrollWidth);

return(-1);}

function getPageHeight() {

if (isNet4) return(document.height);

if (isIE4) return(document.body.scrollHeight);

return(-1);}

function getPageScrollX() {

if (isNet4) return(window.pageXOffset);

if (isIE4) return(100);

if (isIE5) return(document.body.scrollLeft);

return(-1);}

function getPageScrollY() {

if (isNet4) return(window.pageYOffset);

if (isIE4) return(document.body.scrollTop);

return(-1);}

document.write("WindowWidth="+getWindowWidth()+"<BR>")

document.write("WindowHeight="+getWindowHeight()+"<BR>")

document.write("PageWidth="+getPageWidth()+"<BR>")

document.write("PageHeight="+getPageHeight()+"<BR>")

document.write("PageScrollX="+getPageScrollX()+"<BR>")

document.write("PageScollY="+getPageScrollY()+"<BR>")

</script>

</body>

</html>

JS: Wie kann ich JS-Funktionen aus PHP heraus aufrufen? JavaScript läuft auf dem Client (im Browser), PHP läuft auf dem Server, also genau am anderen Ende der Welt; wenn die HTML-Seite beim Browser ankommt, ist PHP mit der Arbeit schon fertig. Der Aufruf einer JavaScript-Funktion aus PHP ist also prinzipiell unmöglich. Allerdings kann man Werte von PHP an JavaScript übergeben; um eine in PHP vorhandene Variable in

JavaScript verwenden zu können, muss man sie innerhalb eines <script>-Bereiches ausgeben:

Page 68: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 68 Author: A. Balogh

<script language="JavaScript">

<?php printf("js_var = '%s';\n", addslashes($php_var)); ?>

</script>

Auf diese Weise wird die JavaScript-Variable js_var mit dem Wert der PHP-Variable $php_var vorbelegt.

Natürlich kann man so auch beliebigen ausführbaren JavaScript-Code ausgeben, den der Browser anschliessend verarbeitet. Wichtig ist nur zu verstehen, dass ein logischer, räumlicher und auch zeitlicher Schnitt zwischen PHP- und JavaScript-Code vorhanden ist.

Page 69: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 69 Author: A. Balogh

JS: TOOL "HierMenu" Hierarchische Menüstrukturen anzeigen: Files: Die Listings sind zu finden unter: http://www.webreference.com/dhtml/hiermenus/latest/ HM_Loader.js HM_Arrays.js HM_ScriptNS4.js HM_ScriptIE4.js HM_ScriptDOM.js LoadMe.html Beispiel STEP 1: Diesen Code ins Dokument platzieren

<HTML>

<HEAD>

<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">

<!--

if(window.event + "" == "undefined") event = null;

function HM_f_PopUp(){return false};

function HM_f_PopDown(){return false};

popUp = HM_f_PopUp;

popDown = HM_f_PopDown;

//-->

</SCRIPT>

STEP 2:

- HM_Loader.js anpassen

- Korrektes Array laden HM_Arrays.js

/* HM_Loader.js

* by Peter Belesis. v4.2.1 020219

* Copyright (c) 2002 Peter Belesis. All Rights Reserved.

*/

HM_DOM = (document.getElementById) ? true : false;

HM_NS4 = (document.layers) ? true : false;

HM_IE = (document.all) ? true : false;

HM_IE4 = HM_IE && !HM_DOM;

HM_Mac = (navigator.appVersion.indexOf("Mac") != -1);

HM_IE4M = HM_IE4 && HM_Mac;

HM_Opera = (navigator.userAgent.indexOf("Opera")!=-1);

HM_Konqueror = (navigator.userAgent.indexOf("Konqueror")!=-1);

HM_IsMenu = (HM_DOM || HM_NS4 || (HM_IE4 && !HM_IE4M));

HM_BrowserString = HM_NS4 ? "NS4" : HM_DOM ? "DOM" : "IE4";

if(window.event + "" == "undefined") event = null;

function HM_f_PopUp(){return false};

function HM_f_PopDown(){return false};

popUp = HM_f_PopUp;

popDown = HM_f_PopDown;

/* HM_GL representiert die Globalen Einstellungen */

HM_GL_MenuWidth = 150;

HM_GL_FontFamily = "Arial,sans-serif";

HM_GL_FontSize = 10;

HM_GL_FontBold = true;

HM_GL_FontItalic = false;

HM_GL_FontColor = "black";

Page 70: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 70 Author: A. Balogh

HM_GL_FontColorOver = "white";

HM_GL_BGColor = "transparent";

HM_GL_BGColorOver = "transparent";

HM_GL_ItemPadding = 3;

HM_GL_BorderWidth = 2;

HM_GL_BorderColor = "red";

HM_GL_BorderStyle = "solid";

HM_GL_SeparatorSize = 2;

HM_GL_SeparatorColor = "yellow";

HM_GL_ImageSrc = "HM_More_black_right.gif";

HM_GL_ImageSrcLeft = "HM_More_black_left.gif";

HM_GL_ImageSrcOver = "HM_More_white_right.gif";

HM_GL_ImageSrcLeftOver = "HM_More_white_left.gif";

HM_GL_ImageSize = 5;

HM_GL_ImageHorizSpace = 5;

HM_GL_ImageVertSpace = 5;

HM_GL_KeepHilite = false;

HM_GL_ClickStart = false;

HM_GL_ClickKill = 0;

HM_GL_ChildOverlap = 40;

HM_GL_ChildOffset = 10;

HM_GL_ChildPerCentOver = null;

HM_GL_TopSecondsVisible = .5;

HM_GL_ChildSecondsVisible = .3;

HM_GL_StatusDisplayBuild = 0;

HM_GL_StatusDisplayLink = 1;

HM_GL_UponDisplay = null;

HM_GL_UponHide = null;

HM_GL_RightToLeft = false;

HM_GL_CreateTopOnly = HM_NS4 ? true : false;

HM_GL_ShowLinkCursor = true;

HM_GL_ScrollEnabled = false;

HM_GL_ScrollBarHeight = 14;

HM_GL_ScrollBarColor = "lightgrey";

HM_GL_ScrollImgSrcTop = "HM_More_black_top.gif";

HM_GL_ScrollImgSrcBot = "HM_More_black_bot.gif";

HM_GL_ScrollImgWidth = 9;

HM_GL_ScrollImgHeight = 5;

function HM_f_CenterMenu(topmenuid) {

var MinimumPixelLeft = 0;

var TheMenu = HM_DOM ? document.getElementById(topmenuid) : window[topmenuid];

var TheMenu = HM_DOM ? document.getElementById(topmenuid) : HM_IE4 ?

document.all(topmenuid) : eval("window." + topmenuid);

var TheMenuWidth = HM_DOM ? parseInt(TheMenu.style.width) : HM_IE4 ?

TheMenu.style.pixelWidth : TheMenu.clip.width;

var TheWindowWidth = HM_IE ? (HM_DOM ? HM_IEcanvas.clientWidth :

document.body.clientWidth) : window.innerWidth;

return Math.max(parseInt((TheWindowWidth-TheMenuWidth) / 2),MinimumPixelLeft);

}

if(HM_IsMenu) {

document.write("<SCR" + "IPT LANGUAGE='JavaScript1.2'

SRC='HM_Arrays.js' TYPE='text/javascript'><\/SCR" + "IPT>");

document.write("<SCR" + "IPT LANGUAGE='JavaScript1.2'

SRC='HM_Script"+ HM_BrowserString +".js'

TYPE='text/javascript'><\/SCR" + "IPT>");

}

//end

Page 71: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 71 Author: A. Balogh

STEP 3: HM_Loader.js erstellen

<SCRIPT LANGUAGE="JavaScript1.2" TYPE="text/javascript">

<!--

// HM_PG representiert die "Page Specific" Einstellungen

// Einfügen in der Head section der betroffenen Seite

HM_PG_MenuWidth = 150;

HM_PG_FontFamily = "Arial,sans-serif";

HM_PG_FontSize = 10;

HM_PG_FontBold = 0;

HM_PG_FontItalic = 0;

HM_PG_FontColor = "blue";

HM_PG_FontColorOver = "white";

HM_PG_BGColor = "#DDDDDD";

HM_PG_BGColorOver = "#FFCCCC";

HM_PG_ItemPadding = 3;

HM_PG_BorderWidth = 2;

HM_PG_BorderColor = "black";

HM_PG_BorderStyle = "solid";

HM_PG_SeparatorSize = 2;

HM_PG_SeparatorColor = "#d0ff00";

HM_PG_ImageSrc = "HM_More_black_right.gif";

HM_PG_ImageSrcLeft = "HM_More_black_left.gif";

HM_PG_ImageSrcOver = "HM_More_white_right.gif";

HM_PG_ImageSrcLeftOver = "HM_More_white_left.gif";

HM_PG_ImageSize = 5;

HM_PG_ImageHorizSpace = 0;

HM_PG_ImageVertSpace = 2;

HM_PG_KeepHilite = true;

HM_PG_ClickStart = 0;

HM_PG_ClickKill = false;

HM_PG_ChildOverlap = 20;

HM_PG_ChildOffset = 10;

HM_PG_ChildPerCentOver = null;

HM_PG_TopSecondsVisible = .5;

HM_PG_ChildSecondsVisible = .3;

HM_PG_StatusDisplayBuild = 1;

HM_PG_StatusDisplayLink = 1;

HM_PG_UponDisplay = null;

HM_PG_UponHide = null;

HM_PG_RightToLeft = false;

HM_PG_CreateTopOnly = 1;

HM_PG_ShowLinkCursor = 1;

HM_PG_NSFontOver = true;

HM_PG_ScrollEnabled = false;

HM_PG_ScrollBarHeight = 14;

HM_PG_ScrollBarColor = "lightgrey";

HM_PG_ScrollImgSrcTop = "HM_More_black_top.gif";

HM_PG_ScrollImgSrcBot = "HM_More_black_bot.gif";

HM_PG_ScrollImgWidth = 9;

HM_PG_ScrollImgHeight = 5;

// -->

</SCRIPT>

Page 72: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 72 Author: A. Balogh

STEP 4: Setup des HM_Arrays.js

HM_Array1 = [

[100, // menu_width

"HM_f_CenterMenu('HM_Menu1')", // left_position

90, // top_position

"red", // font_color

"yellow", // mouseover_font_color

"yellow", // background_color

"black", // mouseover_background_color

"blue", // border_color

"green", // separator_color

1, // top_is_permanent

1, // top_is_horizontal

0, // tree_is_horizontal

1, // position_under

1, // top_more_images_visible

1, // tree_more_images_visible

"null", // evaluate_upon_tree_show

"null", // evaluate_upon_tree_hide

, // right_to_left

1, // display_on_click

true, // top_is_variable_width

false], // tree_is_variable_width

["Experts","/experts/",1,0,1],

["Contents","/index2.html",1,0,0],

["Services","/index2.html",1,0,0],

["About","http://webref.com/about.html",1,0,0]

]

HM_Array1_1 = [

[],

["3-D Animation","/3d/",1,0,0],

["Design","/dlab/",1,0,0],

["HTML","http://webref.com/html/",1,0,0],

["JavaScript","/js/",1,0,0],

["Graphics","/graphics/",1,0,0],

["DHTML","/dhtml/",1,0,1],

["Perl","/perl/",1,0,0],

["XML","http://webref.com/xml/",1,0,0]

]

HM_Array1_1_6 = [

[],

["Diner","/dhtml/diner/",1,0,0],

["Dynomat","http://webref.com/dhtml/dynomat/",1,0,0],

["Links","/dhtml/links/",1,0,0]

]

HM_Array2 = [

[120, // menu width

200, // left_position

300, // top_position

"black", // font_color

"white", // mouseover_font_color

"white", // background_color

"black", // mouseover_background_color

"black", // border_color

"gray", // separator_color

0, // top_is_permanent

0, // top_is_horizontal

0, // tree_is_horizontal

1, // position_under

1, // top_more_images_visible

1, // tree_more_images_visible

"null", // evaluate_upon_tree_show

"null", // evaluate_upon_tree_hide

, // right_to_left

, // display_on_click

0, // top_is_variable_width

0], // tree_is_variable_width

Page 73: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 73 Author: A. Balogh

["Experts","/experts/",1,0,1],

["Contents","/index2.html",1,0,0],

["Services","/index2.html",1,0,0],

["About","/about.html",1,0,0]

]

HM_Array2_1 = [

[],

["3-D Animation","/3d/",1,0,0],

["Design","/dlab/",1,0,0],

["HTML","/html/",1,0,0],

["JavaScript","/js/",1,0,0],

]

STEP 5: Aufruf von HM_Loader.js am ende des HTML platzieren.

<SCRIPT LANGUAGE="JavaScript1.2"

SRC="HM_Loader.js"

TYPE='text/javascript'></SCRIPT>

STEP 6: Aufrufe in HTML einbauen

<BODY>

.

. other HTML

.

<A HREF="/"

onMouseOver="HM_f_PopUp('HM_Menu1',event)"

onMouseOut="HM_f_PopDown('HM_Menu1')">Webreference</A>

<A HREF="/index2.html"

onMouseOver="HM_f_PopUp('HM_Menu2',event)"

onMouseOut="HM_f_PopDown('HM_Menu2')">Contents</A>

.

. other HTML

.

</BODY>

Page 74: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 74 Author: A. Balogh

VISUAL BASIC SCRIPT ( VBScript / VBS ) VB ist nur bedingt geeignet für die CGI-Programmierung. Benötigt eine wince-Schnittstelle. Alternative Active Server Page ( ASP ) mit IIS einsetzen. Ist nicht enthalten in Netscape!

<script language="VBcript">

...

</script>

Basis-Struktur

==============

<html>

<head>

<script language="vbscript">

<!--

dim vRetCodeB as boolean

-->

</script>

</head>

<body>

</body>

</html>

Page 75: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 75 Author: A. Balogh

MySQL

MySQL: Einführung MySQL ist eines der populärsten freien Datenbanksysteme (Open Source "GPL"). Es wird vor allem für dynamische Webseiten in Kombination Linux, Apache und PHP oder Perl eingesetzt. LAMP Linux, Apache, MySQL, PHP & Perl WAMP Windows, Apache, MySQL, PHP & Perl MySQL gilt als sehr schnelle Datenbank. Alternative Open-Souce-DB ist "PostgresSQL". Allgemein üblich werden SQL-Commands gross geschrieben: CREATE INSERT INTO SELECT UPDATE INNER JOIN OUTER JOIN Umfassen mehr Datensätze als INNER JOIN's

MySQL: Files: tbl_name.frm enthält sämtliche Angaben zur Tabellenstruktur tbl_name.isd enthält die Daten tbl_name.ism enthält die Daten

MySQL: Lizenzierung Open Source Projekt, d.h. der vollständige Quellcode ist frei verfügbar. GNU Public License (GPL) LGPL Library GPL für kommerzielle Nutzung (ca. 200 USD).

MySQL: Kapazität GB/TB: ??? Max. Records: 50'000'000 Benutzer: ??? Locking: Nur "Table locking" möglich, kein "Record/row locking" Zur selben Zeit kann nur EIN User die Datenbank updaten! Hot Backup: Mit MySQL kann kein Backup bei laufendem Betrieb durchgeführt werden. Code: Kein UNICODE (Multi-Byte-Zeichensatz) DB-Modul gleich für W95/ 98 / NT WS / NT Server

MySQL: Links Informationen über den letzten Stand der MySQL-Entwicklung:

http://www.mysql.com/development/ http://www.mysql.com/support

MySQL: Tools PhpMyAdmin V2.2.0 Web Administrationstool WinMySQLadmin V.1.0 MySQLFront V.1.22

MySQL: Commands MySQL-Monitor (MySQL.Exe) Location Win: c:\www\mysql\bin\mysql.exe Location Unix: /etc/rc.d/init.d/mysql start / stop Bemerkung: Komandos immer mit einem Semikolon (;) oder \g abschliessen!

Page 76: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 76 Author: A. Balogh

net start mysql net stopp mysql use Knet Datenbank wechseln select count(*) from country; select version(); select user(); show tables; grant select on knet.* to root identified by 'mysql'; set password for <root>=password('<pwd');

MySQL: MySQLAdmin.Exe Location: c:\www\mysql\bin\mysqladmin.exe mysql mysql_install_db mysqlbinlog mysqldumpslow mysql_config mysql_setpermission mysqlbug mysqlhotcopy mysql_convert_table_format mysql_zap mysqlcheck mysqlimport mysql_find_rows mysqlaccess mysqld_multi mysqlshow mysql_fix_privilege_tables mysqladmin mysqldump mysqltest

Page 77: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 77 Author: A. Balogh

MySQL: MyODBC ODBC Schnittstelle zu MySQL. Download: http://www.mysql.com/downloads/api-myodbc.html

Installation: Setup.Exe

MySQL: phpMyAdmin phpMyAdmin mit Passwort absichern. Siehe .htaccess-Datei (Apache).

Page 78: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 78 Author: A. Balogh

MySQL: WinMySQLadmin Sicherheitsrisiko: \winnt\my.ini

MySQL: API Funktionen mysql_affected_rows() Returns the number of rows changed/deleted/inserted by the last UPDATE,

DELETE, or INSERT query. mysql_close() Closes a server connection. mysql_connect() Connects to a MySQL server. This function is deprecated; use mysql_real_connect() instead. mysql_change_user() Changes user and database on an open connection. mysql_character_set_name() Returns the name of the default character set for the connection. mysql_create_db() Creates a database. This function is deprecated; use the SQL command CREATE DATABASE instead. mysql_data_seek() Seeks to an arbitrary row in a query result set. An beliebige Datensatzposition springen. mysql_debug() Does a DBUG_PUSH with the given string. mysql_drop_db() Drops a database. This function is deprecated; use the SQL command DROP

DATABASE instead. mysql_dump_debug_info() Makes the server write debug information to the log. mysql_eof() Determines whether or not the last row of a result set has been read. This function is deprecated; mysql_errno() or mysql_error() may be used

instead. mysql_errno() Returns the error number for the most recently invoked MySQL function. mysql_error() Returns the error message for the most recently invoked MySQL function. mysql_real_escape_string() Escapes special characters in a string for use in a SQL statement taking into account the current charset of the connection. mysql_escape_string() Escapes special characters in a string for use in a SQL statement. mysql_fetch_field() Returns the type of the next table field. mysql_fetch_field_direct() Returns the type of a table field, given a field number. mysql_fetch_fields() Returns an array of all field structures. mysql_fetch_lengths() Returns the lengths of all columns in the current row. mysql_fetch_row() Fetches the next row from the result set. mysql_field_seek() Puts the column cursor on a specified column. mysql_field_count() Returns the number of result columns for the most recent query. mysql_field_tell() Returns the position of the field cursor used for the last mysql_fetch_field(). mysql_free_result() Frees memory used by a result set. mysql_get_client_info() Returns client version information. mysql_get_host_info() Returns a string describing the connection. mysql_get_proto_info() Returns the protocol version used by the connection. mysql_get_server_info() Returns the server version number. mysql_info() Returns information about the most recently executed query. mysql_init() Gets or initialises a MYSQL structure. mysql_insert_id() Returns the ID generated for an AUTO_INCREMENT column by the previous

query. mysql_kill() Kills a given thread. mysql_list_dbs() Returns database names matching a simple regular expression. mysql_list_fields() Returns field names matching a simple regular expression. mysql_list_processes() Returns a list of the current server threads. mysql_list_tables() Returns table names matching a simple regular expression. mysql_num_fields() Returns the number of columns in a result set. mysql_num_rows() Returns the number of rows in a result set. mysql_options() Sets connect options for mysql_connect(). mysql_ping() Checks whether or not the connection to the server is working, reconnecting as necessary. mysql_query() Executes a SQL query specified as a null-terminated string. Resource link_identifier (Id)

Page 79: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 79 Author: A. Balogh

#2 #3 #5 #8 mysql_real_connect() Connects to a MySQL server. mysql_real_query() Executes a SQL query specified as a counted string. mysql_reload() Tells the server to reload the grant tables. mysql_row_seek() Seeks to a row in a result set, using value returned from mysql_row_tell(). mysql_row_tell() Returns the row cursor position. mysql_select_db() Selects a database. mysql_shutdown() Shuts down the database server. mysql_stat() Returns the server status as a string. mysql_store_result() Retrieves a complete result set to the client. mysql_thread_id() Returns the current thread ID. mysql_thread_safe() Returns 1 if the clients are compiled as thread safe. mysql_use_result() Initiates a row-by-row result set retrieval.

Benutzerverwaltung grant revoke Anlegen eines neuen Benutzers: grant select on DBxxx.* to <user> identified by '<pwd>'

Starten/Stopen Settings/Control Panel/Administrative Tools/Services =>Restart Service

MySQL: Datentypen Numerische Datentypen

TINYINT 1 Byte Sehr kleine Ganzzahl.

Wertbereich von –128 bis 127 oder von 0 –255

INT 4 Byte Normale Ganzzah.

Werebereich von –8.388.698 bis 8.388.607

FLOAT(M,D) 4 Byte Kleine einfache genaue Fliesskommazahl mit Vorzeichen.

Wertebereich von –3.402823466E+38 bis –1.175494351E-38, 0 und

1.175494351E-38 bis 3.402823466E+38

Datentypen für Datum und Zeit

DATE 3 Byte Datum. Wertebereich vom '1000-01-01' bis zum '9999-12-31'

Format: 'YYYY-MM-DD'

DATETIME 8 Byte Datum und Zeit. Wertebereich vom '1000-01-01 00:00:00' bis zum

'9999-12-31 23:59:59'

Format: 'YYYY-MM-DD HH:MM:SS'

String-Datentypen

CHAR <= 255 Byte Zeichenkette mit fester Länge.

VARCHAR <= 255 Byte Zeichenkette mit vriabler Länge.

ENUM 1 ¦ 2 Byte Aufzählung. Maximal 65'535 Einzelwerte aus einer Liste

SELECT DISTINCT Abfragen: Mehrfachausgabe vermeiden!

SELECT DISTINCT Field1, Field2

SELECT ORDER BY:

SELECT * FROM y ORDER BY Field1

SELECT WHERE Abfragen:

=

<

<=

>

>=

Page 80: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 80 Author: A. Balogh

!=

<=>

LIKE

LIKE "b%";

not like

IN / NOT IN

SELECT * FROM tbl1 WHERE field1 IN (1,3,5,10)

Not supported: SELECT * from table WHERE id IN (SELECT id from table2)

is null

is not null

WHERE ISNULL(Field)

WHERE field IS NULL

WHERE COALESCE(value, " ") < "69"

WHERE IFNULL(value, " ") < "69"

WHERE value BETWEEN "a" and "c"

enspricht WHERE substring(value,1,1) >= "a" AND substring(value,1,1) <= "c"

REGEXP "^[bB]";

Aggregatfunktionen:

count()

count(*)

avg()

min()

max()

sum() Summe des Abfrageergebnisses

std()

stddev()

bit_or()

bit_and()

Examples:

MySQL: Syntax * Überblick über die von MySQL verwalteten Datenbanken

mysqlshow

* MySQL Manager

mysqlmanager

* MySQL Manager

mysqlwatch

* Test

mysqladmin version

*** Startet den MySQL - Interpreter

mysql

* Setzen der Standarddatenbank für folgende Befehle

use testDB;

* Kreieren einer Datenbank

create database test2;

mysqladmin version

mysqladmin status

mysqladmin reload Reload grant tables

Page 81: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 81 Author: A. Balogh

MySQL: CREATE / DROP TABLE

create table [if not exists] Table1 ( id int not null auto_increment,

choice tinyint not null,

primary key (id));

KEY [index_name] (index_col_name, …)

UNIQUE KEY [index_name] (index_col_name, …)

CREATE TABLE BRANCH_OFFICE (

BONO varchar(6) NOT NULL default '',

Branch_Office_Id int(13) NOT NULL default '0',

KN_Group_ID int(13) default NULL,

Is_Active char(1) NOT NULL default 'Y',

Language_Id int(13) default NULL,

Name varchar(80) NOT NULL default '',

Location_Id int(13) NOT NULL default '0',

Modified datetime NOT NULL default '0000-00-00 00:00:00',

Remark varchar(255) default NULL,

Trace int(20) NOT NULL default '0',

PRIMARY KEY (Branch_Office_Id),

UNIQUE KEY Branch_Office_AK1 (BONO),

KEY BRANCH_OFFICE_IF339 (Language_Id),

KEY BRANCH_OFFICE_IF340 (KN_Group_ID),

KEY BRANCH_OFFICE_IF56 (Location_Id)

) TYPE=MyISAM;

SQL: INSERT Examples INSERT [LOW_PRIORITY | DELAYED] [IGNORE]

[INTO] tbl_name [(col_name,...)]

VALUES (expression,...),(...),...

or

INSERT [LOW_PRIORITY | DELAYED] [IGNORE]

[INTO] tbl_name [(col_name,...)]

SELECT ...

or

INSERT [LOW_PRIORITY | DELAYED] [IGNORE]

[INTO] tbl_name

SET col_name=expression, col_name=expression, ...

=========================================================================================

INSERT INTO table01 (field01,field02) VALUES (1,'first');

MySQL doesn't yet support

SELECT ... INTO TABLE.... Currently MySQL only supports SELECT ... INTO OUTFILE....

=========================================================================================

INSERT INTO tmp_no (branch_office_id_no)

SELECT branch_office.branch_office_id_no

FROM branch_office

WHERE branch_office.branch_office_id = branch_office.branch_office_id_no

* Löschen einer Datenbank/Tabelle/Records

drop database [if exists] <dbname>

drop table [if exists] <tablename>

DELETE [LOW_PRIORITY]

FROM tbl_name

[WHERE <condition>] [LIMIT rows]

e.g.

$vsql = "DELETE

FROM wh_performance_location

WHERE department_id = 10100

";

* Alter Table

Page 82: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 82 Author: A. Balogh

ALTER TABLE

ALTER TABLE tblA1SerialCheck MODIFY macarray VARCHAR(80) AFTER Mac;

* Optimize Table

optimize table

* Öffnen von MySQL mit UserID und Passwort

mysql –u username –p****

* Statusanzeige

status;

* Laufenden Prozess beenden

kill;

* SELECT

SELECT a.titel, b.titel01 FROM anz_anzeigen a, anz_rubriken b

WHERE b.rubrik = a.rubrik

mysql> SELECT CONCAT("My", "S", "QL"); -> "MySQL"

mysql> SELECT char(77,121,83,81,"76"); -> "MySQL"

MySQL: Backup/Restore Dump aller DB's erstellen mysqldump -u root --password=xxx --opt --all-databases > test.sql Dump einzelne DB erstellen mysqldump -u root --password=xxx --opt –databases KNet > test.sql mysqlhotcopy mysqldump --help mysqldump --opt database > backup-file.sql mysqldump [OPTIONS] database [tables] mysqldump [OPTIONS] database [tables] > backup.sql mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...] mysql database < backup-file.sql mysql -e "source /patch-to-backup/backup-file.sql" database mysqldump --opt database | mysql --host=remote-host -C database mysqldump --databases database1 [database2 database3...] > my_databases.sql RESTORE TABLE tbl_name[,tbl_name...] FROM '/path/to/backup/directory'

MySQL: Error Codes ERROR 6: Error on delete of '.\knet\address_type.MYI' (Errcode: 13)

Page 83: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 83 Author: A. Balogh

Masseinheiten pt Punkt(=1/72") pc Pica(1pc = 12 Punkte) px Pixel/Bildpunkt % Prozent in Inch(=2.54cm) mm Millimeter cm Zentimeter em Faktor bezieht sich auf die elementeigene Schrifthöhe h1 {line-height:1.2em;} = 1.2 Mal ex Schrifthöhe der kleinen Buchstaben

Farben #123456 Farbdefinition (immer sechs-stellig)

¦ ¦ ¦

¦ ¦ +-----→ 56 = Blau-Wert

¦ +-------→ 34 = Grün-Wert

+---------→ 12 = Rot Wert

bgcolor=#000000 Schwarz/black

bgcolor=#000066 dunkelblau

bgcolor=#000080 dunkelblau/navy

bgcolor=#0000ff Blau/blue

bgcolor=#008000 Grün/green

bgcolor=#008080 Blaugrün/Meerblau/teal

bgcolor=#00c0c0 Blaugrün

bgcolor=#00ff00 Hellgrün/lime

bgcolor=#00ffff Hellblau/aqua/cyan

bgcolor=#800000 Dunkelrot/maroon

bgcolor=#800080 Violett/Lila/purple

bgcolor=#808000 Ocker/Oliv/olive

bgcolor=#808080 Dunkelgrau/grey (Dateihintergrund)

bgcolor=#990000 Rot

bgcolor=#c0c0c0 Hellgrau/silver

bgcolor=#cc00cc violette

bgcolor=#f0f8ff aliceblue

bgcolor=#ff0000 Rot/red

bgcolor=#ff00ff Magenta/Pink/Fuchsia

bgcolor=#ffff00 Gelb/yellow

bgcolor=#ffffff Weiss/white

oder

bgcolor=black

color=black

Page 84: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 84 Author: A. Balogh

Page 85: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 85 Author: A. Balogh

Page 86: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 86 Author: A. Balogh

Page 87: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 87 Author: A. Balogh

Page 88: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 88 Author: A. Balogh

Page 89: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 89 Author: A. Balogh

KN-Farben Color 1: background-color:#18216e;

Color 2: background-color:#33408F;

Color 3: background-color:#4757a4;

Color 4: background-color:#90A9D2;

Color 5: #2d5597

Page 90: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 90 Author: A. Balogh

MIME-Type's Gibt an in welchem Format die Information verfasst ist und in welchem Format sie

anzuzeigen ist.

MIME-Media-type wird in der Interenet-Dokumentation oft kurz als "media Type / MIME type"

bezeichnet

Default "Content-Type : text/plain; charset= us-ascii"

.js text/javascript

application/vnd.ms-excel application/x-msexcel application/ms-excel MS-Word-Dateien application/msword Textdatei text/plain HTML-Datei text/html GIF-Grafik image/gif Image Exchange Format image/ief PNG-Grafik image/png JPEG-Grafik image/jpeg TIFF-Grafik image/tiff X-Bitmap image/x-bitmap X-Pixmap image/x-xpixmap

header field definitions Content-Encoding: gzip

Content-Location Speziell wenn mehrere Lokationen die Source enthalten koennen.

header("Content-Location: ( absoluteURI | relativeURI) ")

Content-Disposition Anzeigen INLINE oder Download oder..

header("Content-Disposition: inline; filename='$name' ")

Fehlermeldungen Internet Explorer cannot download …

Page 91: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 91 Author: A. Balogh

Common Gateway Interface ( CGI )

CGI: EINFÜHRUNG Common Gateway Interface ( CGI ).

• CGI dient der Implementierung von Web Applikationen

• Ein CGI Programm wird vom WebServer ausgeführt.

• CGI-Scripte sind Programme, die auf einem Internetserver ausgeführt werden und Aufgaben, wie z.b. das Abrufen und Versenden von Bestellungen übernehmen.

• CGI's sind schwieriger zu programmieren als Skripte

CGI Programme können erhebliche Sicherheitslücken eröffnen (Sicherheit).

Eine der grössten Schwächen von CGI ist es, dass es relativ kompliziert ist, Programme zu schreiben, die eine Verbindung zu einer Datenbank einrichten. Wenn das CGI Skript Daten aus einer Datenbank braucht, muss er ausserdem bei jeder Ausführung eine Verbindung zu der Datenbank einrichten und sich anmelden. Das beeinträchtigt die Leistung Ihres WebServers und verlangsamt die Ausführung der Applikation erheblich, weil das öffnen und schliessen von Datenbanken enorm viel Zeit benötigt.

Shebang-Zeile = Erste Zeile im Skript

Für die Entwicklung von CGI-Programmen können nahezu alle Programmiersprachen verwendet werden. CGI ist die definierte Schnittstelle zwischen dem WebServer und dem externen Programm, das Sie schreiben wollen.

Realms sind Dokumente auf einem WebServer, die untrer demselben Authorisierungssystem angeordnet sind. Mit anderen Worten, für den Zugriff auf Dokumente in einem Realm werden dieselben Benutzer-Ids und Kennwörter verwendet.

Java-Servlets äquivalent zu den CGI-Programmen. Einer der ersten WebServer war: NCSA HTTPD Web-Inhaltstypen:

➢ text/html HTML-Dokument Beispiele: Matt's Script Archive: http://www.worldwidemart.com/scripts CGI Dokumentation: http://hoohoo.ncsa.uiuc.edu/cgi/

CGI: Tastaturkombinationen Ctrl + D

CGI: Debuggen Print-Befehl benutzen.

Page 92: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 92 Author: A. Balogh

CGI: TEST-SCRIPT Lauffähig auf Raq4R Aufrufen mit: http://www.a1-it.ch/cgi-bin/testcgi.cgi Dateiname: testcgi.cgi

#!/usr/bin/perl --

print "Content-type: text/html\n\n";

print "<html>\n";

print "<head>\n <title>TEST CGI</title>\n </head>\n\n";

print "<body>\n\n";

print "<center> <h1>TEST MESSAGE FROM CGI</h1> </center>\n";

print "</body>\n";

print "</html>\n";

CGI: Verzeichnisstruktur Typische Verzeichnisstruktur (Apache Server):

Server Stammverzeichnis --------- Conf

¦

+---- htdocs

¦

+---- cgi-bin

¦

+---- bin

CGI: Umgebungsvariablen AUTH_TYPE CONTENT_LENGTH CONTENT_TYPE DOCUMENT_ROOT GATEWAY_INTERFACE http_ACCEPT http_ACCEPT http_FROM http_REFERER http_USER_AGENT PATH_INFO PATH_TRANSLATED QUERY_STRING REMOTE_ADDR REMOTE_HOST REMOTE_IDENT REQUEST_METHOD SCRIPT_NAME SERVER_NAME SERVER_PORT SERVER_PROTOCOL SERVER_SOFTWARE

CGI: E-Mail Nachrichten Mail Clients:

➢ Outlook Express ➢ Netscape Messenger ➢ Eudora

Page 93: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 93 Author: A. Balogh

➢ Pine ➢ Blat (Kostenloser Mail Transfer Agent "MTA" http://gepasi.dbs.aber.ac.uk/softw/Blat.html )

o Liest die E-Mail Nachricht aus einer Textdatei o Argumente:

▪ Name des zu verwendenden SMTP-Servers ▪ Mail-Sender ▪ Mail-Empfänger ( Liste!)

MTA ( Mail Transfer Agent) sendmail UNIX MTA sendmail SMTP-Protokoll ( Port 25 ) Headers: To: From: CC: BCC: Subject:

CGI: sendmail UNIX: Von der Befehlszeile aus

$ sendmail –n –t –o1

From: [email protected]

To: [email protected]

Subject: A Subject

Dies ist der Nachrichtentext

Perl

open (MAIL, "¦ /usr/lib/sendmail –n –t –oi");

print MAIL "From: [email protected]\n";

print MAIL "To: [email protected]\n";

print MAIL "Subject: Demo-Mail\n\n";

print MAIL "This is the message body.\n";

close MAIL;

CGI: Shell-Skripten #!/bin/sh

echo ***Ausgabe

echo 'Content-type: text/html'

cat whatever.html

#!/bin/sh

echo 'Content-type: text/html'

echo

echo "<html><head><title>Beispiel</title></head>"

echo "<body>"

echo "Das ist ein Beispiel"

echo "</body></html>"

CGI: SYNTAX Im HTML-Code werden: <FORM action="....cgi"> und <INPUT type="…" value="…"> benötigt. UNIX Dateiumleitung cat irgendeinedatei > zieldatei UNIX Pipes ls ¦ more

Page 94: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 94 Author: A. Balogh

#!/usr/local/bin/perl.exe *** Welcher Interpreter benutzt wird

*** Muss leer sein

use CGI; *** importieren CGI.pm (Perl CGI-Modul)

*** Attribute: (siehe Carp)

*** use CGI qw(:standard)

$query = new CGI; *** Instanz des Objektes CGI erstellen

<!-- Ende Startsequenz (Standard)

<!-- ***************************************************************** -->

<!-- Start der Subroutine print_page_start

<!-- ***************************************************************** -->

&print_page_start;

if ($query->param('submitted')) {

$error_message = "";

&validate_form;

if ($error_message eq "") {

&print_form_values;

}

else {

print "<UL>\n" . $error_message . "</UL>\n";

&print_form;

}

}

else {

&set_initial_values;

&print_form;

}

&print_page_end;

<!—Ende der Subroutine print_page_start

<!-- ***************************************************************** -->

<!-- ***************************************************************** -->

<!-- Start der Subroutine validate_form

<!-- ***************************************************************** -->

sub validate_form {

$name = $query->param('name');

$quest = $query->param('quest');

$fav_color = $query->param('fav_color');

if ($name eq "") {

$error_message .= "<LI>You must enter a name.\n";

}

if ($quest eq "") {

$error_message .= "<LI>You must enter your quest.\n";

}

if ($fav_color eq "") {

$error_message .= "<LI>You must select your favorite color.\n";

}

}

<!—Ende der Subroutine validate_form

<!-- ***************************************************************** -->

x: print $query->redirect($query-<param('link'));

CGI: While Schleife

while (<FILE>) {

print;

}

while (1) { *** Endlosschleife 1 immer wahr

print;

}

while ($i < 100) { *** Wird beendet sobald i = 99

$i++ *** inkrementiert 1

}

foreach $color ('red', 'green', 'blue') {

print $color, "\n";

}

Page 95: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 95 Author: A. Balogh

CGI: Array handling

@colors = ('red', 'green', 'blue');

foreach @colors (@colors) {

print $colors, "\n";

}

CGI: if - Anweisung

if (2 > 1) {

print "2 ist grosser als 1. \n";

}

print "2 ist grosser als 1. \n" if (2 > 1);

if (2 > 1) {

print "2 ist grosser als 1. \n";

}

else {

print "2 ist nicht grosser als 1. \n";

}

Page 96: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 96 Author: A. Balogh

CGI: unless - Bedingung

unless ($number == 7) {

print "Die Zahl ist ungleich 7. \n";

}

CGI: Operator Vergleich

== numerisch gleich

!= nummerisch ungleich

> numerisch grosser

< numerisch kleiner

>= numerisch grosser gleich

<= numerisch kleiner gleich

eq Zeichenkette gleich

ne Zeichenkette ungleich

gt Zeichenkette grösser

lt Zeichenkette kleiner

le Zeichenkette kleiner gleich

ge Zeichenkette grösser gleich

CGI: Metazeichen

^ Anfang einer Zeichenkette

$ Ende einer Zeichenkette

. Wildcard steht für jedes beliebige Zeichen

* Steht für 0 oder mehrere Zeichen oder Zeichengruppe

// Schrägstriche Begrenzungszeichen

+ Wie * aber für ein oder mehr

? Wildcard

\ Backslash ist das Escape Zeichen für Metazeichen in regulären Ausdrücken

[..] Zeichengruppe

/(rcolburn¦rafe¦webmaster)@rc3.org/

Entspricht: [email protected]

[email protected]

[email protected]

CGI: <FORM>-Tag

<FORM ACTION="/cgi-bin/eaxample.cgi"> *** Attribute

*** ACTION = Wie ein Link

*** METHOD = Get oder Post

*** ENCTYPE = application/x-www-form-urlencode

*** TARGET = ..

<!—Hier Formularfelder einfügen -->

</FORM>

CGI: <INPUT>-Tag

<input type="text" name="Vname" size=30 maxsize=50>

*** Attribute

*** NAME =

*** VALUE =

*** TYPE "text", "radio", "checkbox", "hidden"

*** "file", "reset", "submit"

<INPUT TYPE="text" NAME=Vname" onChange="SCheck_Example()">

*** Aufruf der Subroutine "SCheck_Example()"

<INPUT TYPE="text" NAME=Vname"

onChange="top.location.href=this.options[this.selectedIndex].value">

<INPUT TYPE="text" NAME=Vname" onSubmit="return SCheck_Example()">

*** Aufruf der Subroutine "SCheck_Example()"

CGI: <TEXTAREA>-Tag

<textarea NAME="example" COLS=40 ROWS=4>

*** Eingabefeld mit mehreren Zeilen (ROWS)

*** WRAP = Zeilenumbruch J/N

This is just an example

Page 97: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 97 Author: A. Balogh

</TEXTAREA>

CGI: <SELECT>-Tag

<select name="color"> *** Eingabefeld mit mehreren Zeilen (ROWS)

<OPTION VALUE="red">Red

<OPTION VALUE="blue" SELECTED>Blue

<OPTION VALUE="yellow">Yellow

</select>

print

print $query->header;

print $query->header('image/gif);

print $query->header(-type=>'text/plain'', -cookie=>$cookie);

@Varray *** Variable Array

&S_Routine *** & Leitet Subroutine ein.

$ *** Meist Variablendefinition

$_ *** Standardvariable

$Variable = "Das ist der Inhalt der Variablen"

use CGI qw(:standard); *** funktionsbasierte Schnittstelle

use CGI qw(-nph);

eval *** Kapselt Codeblöcke

flock *** Dateisperre

while

while foreach

join

$query->param('link')

$query->redirect

CGI-Bin Ordner

Abbildung 1: CGI Ablauf

Ihr Domain ist z.B. www.ips.ch CGI-Bin Pfad: http://www.ips.ch/cgi-bin/script.cgi Root Pfad ist somit: /home/sites/www.ips.ch/web/cgi-bin Andere Pfade: Pfad für Pearl: /usr/bin/perl Pfad für Datum: /usr/date Pfad für Mailer: /usr/sbin/sendmail Warum läuft mein CGI Programm nicht?

Das Fileattribute muss auf 'chmod 755' gesetzt sein Der Filename muss die Endung .cgi haben

Page 98: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 98 Author: A. Balogh

Der Perl 5 Pfad ist: /usr/bin/perl , dies muss in der ersten Zeile des CGI stehen Das CGI muss im ASCII Text Format auf den Server kopiert werden Das CGI sollte ins CGI-BIN Verzeichnis kopiert werden

chmod a+x damit jedermann das Programm ausführen darf chmod a+w guestbook.html guestlog.html Leider ist es uns nicht möglich kostenlosen Support zum installieren von CGI Programmen zu geben. Sollten Sie denoch unsere Hilfe benötigen schreiben Sie uns ein E-Mail an [email protected] Support: CHF 125.-- / Stunde

Page 99: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 99 Author: A. Balogh

CGI: Wie verwende ich meine eigenen CGI-Programme? 1. Legen Sie Ihre CGI-Programme im dem vorhandenen cgi-bin Verzeichnis ab:

http://www.ips.ch/cgi-bin/script.cgi 2. CGI-Scripts müssen im ASCII-Modus zum Server übertragen werden! 3. Die Zugriffsrechte des cgi-bin-Verzeichnisses und der CGI-Dateien müssen auf chmod 755 gesetzt

sein.

4. CGI-Programme und -Verzeichnisse mit chmod 775 und chmod 777 werden nicht ausgeführt. Hinweis: Dies gilt nicht bei Frontpage-Webs. Wenn Sie Frontpage verwenden, folgen Sie der normalen Prozedur für CGIs.

Page 100: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 100 Author: A. Balogh

CGIEMAIL von IPS CGIEMAIL Dieses Programm sendet die Einträge Ihrer HTML-Formulare aus dem Web direkt per E-Mail an eine bestimmte Adresse. Beispiel: Erstellen Sie eine einfache Text-Datei mit Namen "beispiel" (ohne Erweiterung) und mit folgendem Inhalt. Anschließend legen Sie diese im www-Verzeichnis Ihres Servers ab. To: [email protected] Subject: Beispiel-Betreff Dies ist eine Test-Nachricht. Dies ist eine Test-Nachricht. Name ...: [name] Telefon : [tel] Diese Datei wird per E-Mail an [email protected] gesendet. Cgiemail ersetzt automatisch [name] und [tel] und alle weiteren Angaben innerhalb der eckigen Klammern mit den entsprechenden Angaben, die Ihr Besucher in Ihrem Web-Formular eingetragen hat. Wichtig: Die "To:"- und "Subject:"-Zeilen sowie eine nachfolgende Leerzeile müssen immer vorhanden sein. Hier sehen Sie einen Teil des zugehörigen HTML-Formulars: <form method="post" action="/cgi-bin/cgiemail/beispiel"> Ihr Name: <input type=text name="name"> Ihre Telefonnummer: <input type=text name="tel"> etc... Sie können auch eine eigene "Erfolgs-Seite" definieren, die nach erfolgreichem Versand der E-Mail automatisch dem Benutzer angezeigt wird: <input type="hidden" name="success" value="http://IhreDomain.de/erfolgsseite.html">

Page 101: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 101 Author: A. Balogh

FORMMAIL von IPS Formmail ist ein sehr einfach zu verwendender Formular-Prozessor. Binden Sie einfach folgenden Code in Ihr HTML-Formular ein:

Test:

http://www.a1-it.ch/cgi-bin/FormMail.cgi?recipient=<E-Mail>

<form method="post" action="http://IhreDomain.de/cgi-bin/formmail.cgi"> <input type=hidden name="recipient" value="[email protected]"> <input type=hidden name="subject" value="Bestellung"> <input type=hidden name="return_link_url" value="http://IhreDomain.de/"> <input type=hidden name="return_link_title" value="Zurück zur Homepage"> Die komplette (englische) Bedienungsanleitung zu Formmail gibts hier. Anleitung: Erstellen Sie ein Formular z.B. mit Frontpage gehen Sie in den HTML Text und ersetzen Sie <FORM> mit dem folgenden HTML Text <form ACTION="http://www.ipshost.ch/cgi-bin/form/public.cgi" METHOD=POST> <input type="hidden" name="to" value="[email protected]"> <input type="hidden" name="redir" value="http://www.a1-it.ch/danke.htm"> <input type="hidden" name="subject" value="Anfrage E-Mail"> Tips: Jedes Formular muss einen 'Abschicken' Button haben, so dass der Besucher Ihrer Homepage das Formular abschicken kann Achten Sie darauf dass Sie im ganzen HTML Text nur 1 <form> und ein </form> haben Zwischen <form> und </form> müssen alle Eingabefelder sein die per E-Mail an Sie geschickt werden Der Root Pfad ist somit: /home/sites/www.ips.ch/web/cgi-bin Andere Pfade: Pfad für Pearl: /usr/bin/perl Pfad für Datum: /usr/date Pfad für Mailer: /usr/sbin/sendmail

Page 102: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 102 Author: A. Balogh

FORMMAIL Version 1.9 Copyright by Matt Wright / [email protected] Upload: Unbedingt im ASCII-Mode hochladen! chmode Read/Execute Vorteile: Kein SPAM Mail mehr möglich Datei FormMail.cgi nach cgi-bin kopieren. Anonymous user muss read/execute Berechtigung haben. Erforderliche Parameter: $mailprog = '/usr/lib/sendmail' // Position des sendmail programmes $referers = ('a1-it.ch', 'sv001') // Domänen auf welchen die FORMS sich befinden darf. $recipients = $referers // Alle erlaubten Empfänger!

Page 103: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 103 Author: A. Balogh

SKRIPTINTERPRETER

PERL ( PL )

PL: Einführung Script-Sprache. Die am meisten verwendete CGI-Programmiersprache. Interpreter verfügbar unter: http://www.activestate.com (Bessere Version!)

http://www.perl.com Comprehensive Perl Archive Network ( CPAN ) CGI.pm = Perl Modul ( im Interpreter enhalten) use CGI

Fehlersuche: use CGI::Carp; use CGI::Carp qw(fatalsToBrowser);

Alternative: cgi-lib.pl (Nur 15KB) require "cgi-lib.pl"; durch use CGI qw(:cgi-lib): ersetzen Kompilieren aber nicht ausführen: perl –cw example.pl man ls Gibt einen Hilfetext aus für diesen Befehl POD-Dateien Altes Perl Dokumentationsformat ( Plain Old Documentation) Pod2html. PL: Datenbankzugriff Zwei Komponenten werden benötigt:

➢ DBI-Modul (Database Interface zu beliebiger Datenbank ) ➢ DBD-Treiber ( Database Driver Code für bestimmte Datenbank )

Treiber unter: http://www.perl.com/CPAN

PL: Syntax -0[octal] specify record separator (\0, if no argument) -a autosplit mode with -n or -p (splits $_ into @F) -c check syntax only (runs BEGIN and END blocks) -d[:debugger] run scripts under debugger -D[number/list] set debugging flags (argument is a bit mask or flags) -e 'command' one line of script. Several -e's allowed. Omit [programfile]. -F/pattern/ split() pattern for autosplit (-a). The //'s are optional. -i[extension] edit <> files in place (make backup if extension supplied) -Idirectory specify @INC/#include directory (may be used more than once) -l[octal] enable line ending processing, specifies line terminator -[mM][-]module.. executes `use/no module...' before executing your script. -n assume 'while (<>) { ... }' loop around your script -p assume loop like -n but print line also like sed -P run script through C preprocessor before compilation -s enable some switch parsing for switches after script name -S look for the script using PATH environment variable -T turn on tainting checks -u dump core after parsing script -U allow unsafe operations -v print version number, patchlevel plus VERY IMPORTANT perl info -V[:variable] print perl configuration information -w TURN WARNINGS ON FOR COMPILATION OF YOUR SCRIPT. Recommended. -x[directory] strip off text before #!perl line and perhaps cd to directory # Kommentar

Page 104: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 104 Author: A. Balogh

#!\www\perl\bin\perl –w 1. Zeile! Pfad der Perl.Exe datei!

print "Content-type: text/plain\n\n"; Ausgabe als Text!

Script: Simpler Ausgabetest

#!\www\perl\bin\perl –w

print "Content-type: text/plain\n\n";

print "Hello world!\n";

print "Please hit return to end the program!";

$wait_for_return = <stdin>;

Script: Zeigt Datenbanken an!

#!\www\perl\bin\perl –w

print "Content-type: text/plain\n\n";

use DBI();

$dbh = DBI->connect(

"DBI:mysql:database=mysql;host=localhost",

"user", "password", {'RaiseError' => 1});

$sth->finish();

Filehandling open (FILE, "irgendeinedatei.html"); Datei öffnen

open (FILE, "< irgendeinedatei.html"); Datei lesen

open (OUTPUT, "> irgendeinedatei.html") Datei öffnen für Ausgabe

or die "kann die datei nicht lessen";

TCL

Python Ähnlich wie Perl. Objektorientiert.

REXX

Serverseitige Includes ( SSI & XSSI ) Datei Extension: *.shtml SSI = Server Side Includes XSSI = Extended SSI Der WebServer muss so konfiguriert sein, dass automatisch nach SSI Anweisungen untersucht wird. Beispiele: <!--#exec cmd="/cgi-bin/xxx.cgi"-->

<!--#exec cgi="/cgi-bin/xxx.cgi"-->

<!--#include virtual="/cgi-bin/xxx.cgi"-->

NPH-Skripten Namenspräfix: nph Wurde implementiert für Server-Push.

Die wichtigste Nutzung von NPH-CGI-Skripten ist heute, dass CGI.pm skripten unter Microsofts IIS funktioniert. CGI.pm kann nur unter IIS eingesetzt werden, wenn Sie die Header im NPH-Modus erzeugen.

Page 105: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 105 Author: A. Balogh

C cgic ist eine CGI-Bibliothek für C. #include "cgic.h"

Page 106: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 106 Author: A. Balogh

CGI: BEISPIELE

CGI: Homepages http://www.cgi-resources.com http://www.worldwidemart.com/scripts http://www.freecode.com http://sciptsearch.com http://www.extropia.com

CGI: Search.html <html>

<head>

<title>Matt's Script Archive Search Engine</title>

</head>

<body bgcolor=#FFFFFF text=#000000>

<center>

<h1>Matt's Script Archive Search Engine</h1>

</center>

Use the form below to search through the files at Matt's Script Archive!<p>

<hr size=7 width=75%><p>

<form method=POST action="http://worldwidemart.com/scripts/cgi-bin/demos/search.cgi">

<center>

<table border>

<tr>

<th>Text to Search For: </th><th><input type=text name="terms" size=40><br></th>

</tr><tr>

<th>Boolean:

<select name="boolean">

<option>AND

<option>OR

</select>

</th>

<th>Case <select name="case">

<option>Insensitive

<option>Sensitive

</select><br></th>

</tr><tr>

<th colspan=2>

<input type=submit value="Search!"> <input type=reset><br></th>

</tr></table></form></center>

<hr size=7 width=75%><p>

Simple Search created by Matt Wright and can be found at

<a href="http://www.worldwidemart.com/scripts/">Matt's Script Archive</a>.

</body></html>

CGI: Einkaufskorb Siehe Beispiel "16. X.pl" Bestandteile:

➢ Katalog ➢ Artikel in den Einkaufskorb legen ➢ Artikel aus dem Einkaufskorb löschen ➢ Inhalt des Einkaufskorbes anzeigen ➢ Aufträge absetzen

CGI: Datenbankbearbeitung Siehe Beispiel "19.2 xx"

Page 107: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 107 Author: A. Balogh

CGI: Nachrichtenbrett Siehe Beispiel "14.2 display.pl"

CGI: Sitzungsverwaltung Siehe Beispiel "15.1 sessionwithhiddenfields.pl"

CGI: Cookies Siehe Beispiel " 15.4 setcookieusingcgipm.pl" Siehe Beispiel " 15.6" Code aus Buch "Jetzt lerne ich CGI"

Page 108: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 108 Author: A. Balogh

CGI: FlatFiles Begrenzungszeichen: : ; Tab , Beispielprogramme: 13.2 xxx.pl – 13.6 xxx.pl

CGI: FlatFile read record open (GUESTS, "< $guest_file") or

die "Can't open $guest_file: $!";

while (<GUESTS>) {

chomp;

($name, $email, $browser) = split /\t/;

if ($name =~ /$search_name/i) {

print "$name<BR>\n$email<BR>\n$browser<BR>\n<HR>\n";

}

}

CGI: FlatFile insert record if ($query->param()) {

if (&valid_form) {

# Create the record to be inserted

$record = $query->param('name') . "\t";

$record .= $query->param('email') . "\t";

$record .= $query->param('browser') . "\n";

# Wrap this code in an eval block in order to trap

# errors.

eval {

open (GUESTS, ">> $guest_file") or

die "Can't open $guest_file: $!";

flock GUESTS, 2;

print GUESTS $record;

close GUESTS;

print "<P>New record inserted.</P>\n";

}

}

else {

&print_form;

}

}

else {

&print_form;

}

Page 109: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 109 Author: A. Balogh

CGI: FlatFile delete record if ($query->param()) {

$search_name = $query->param('search_name');

# Wrap this code in an eval block in order to trap

# errors.

eval {

open (GUESTS, "+>> $guest_file") or

die "Can't open $guest_file: $!";

flock GUESTS, 2;

seek GUESTS, 0, 0;

my @guests = <GUESTS>;

my @new_guests = ();

foreach $guest (@guests) {

($name, $email, $browser) = split /\t/, $guest;

if ($name !~ /$search_name/i) {

push @new_guests, $guest;

}

}

seek GUESTS, 0, 0;

truncate GUESTS, 0;

print GUESTS @new_guests;

close GUESTS;

print "Record(s) deleted.\n";

}

}

else {

print "<FORM>\n";

print "<INPUT TYPE=\"text\" NAME=\"search_name\"><BR>\n";

print "<INPUT TYPE=\"submit\">\n";

print "</FORM>\n";

}

Page 110: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 110 Author: A. Balogh

CGI: FlatFile modify record if ($query->param()) {

if ($query->param('new_name')) {

if (&valid_form) {

# Wrap this code in an eval block in order to trap

# errors.

eval {

open (GUESTS, "+>> $guest_file") or

die "Can't open $guest_file: $!";

flock GUESTS, 2;

seek GUESTS, 0, 0;

my @guests = <GUESTS>;

my @new_guests = ();

foreach $guest (@guests) {

chomp $guest;

($name, $email, $browser) = split /\t/, $guest;

if ($name eq $query->param('name') &&

$email eq $query->param('email') &&

$browser eq $query->param('browser')) {

$name = $query->param('new_name');

$email = $query->param('new_email');

$browser = $query->param('new_browser');

$guest = "$name\t$email\t$browser";

}

$guest .= "\n";

push @new_guests, $guest;

}

seek GUESTS, 0, 0;

truncate GUESTS, 0;

print GUESTS @new_guests;

close GUESTS;

print "<P>Record(s) modified.</P>\n";

print "<A HREF=\"retrieve.pl\">Retrieve records.</A>\n";

}

}

else {

&print_form;

}

}

else {

&print_form;

}

}

else {

&print_record_list;

}

Page 111: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 111 Author: A. Balogh

INTERNET INFORMATION SERVER ( IIS ) IIS 5.0 unterstützt den Standard CGI 1.1 Installation: Siehe "Konfigurieren von CGI-Anwendungen" http://10.63.220.20/iishelp/ Suchen am besten unter Index. Virtuelles Verzeichnis anlegen: cgi-bin Physisches Verzeichnis \...\Scripte Perl-Code:

#!(usr/local/bin/perl

use CGI;

$query = new CGI;

print $query->header;

print "<html><head><title>A Test</title></head>\n";

print "<body>The test was successfull.</body></html>";

Test: Aufrufen mittels http://localgost/cgi-bin/test.pl Resultat:

Page 112: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 112 Author: A. Balogh

WEB-APPLIKATIONSPLATTFORMEN

Active Server Pages ( ASP ) Verwendet "Tags" Mit CGI ähnlichen Funktionalitäten. ASP unterstütz standardmässig VBScript ( .vbs ) und JavaScript ( .js ). Andere ASP-Plattformen: Chili!Soft Die drei Komponenten von ASP:

➢ ActiveX Komponenten / Steuerelemente ➢ Skripten ➢ HTML-Seiten

Syntax

ASP <% %>

Allaire ColdFusion Verwendet "Tags" Mit CGI ähnlichen Funktionalitäten. Ursprünglich für WNT. Unterstützt:

➢ Netscape NSAPI ➢ MS ISAPI ➢ CGI

Apache Der gebräuchlichste WebServer im Internet ( Anteil 2001 50%). Unterstützt:

➢ Apache API

Serverseitiges Java

Grosser Vorteil ist die Portierbarkeit von einem WebServer zum anderen.

Slogan von Sun: "Write once, Run Anywhere"

Applets, kleine Applikationen, die in Web-Browsern ausgeführt werden. Servlets, sind Java-Applikationen, die von WebServern ausgeführt werden.

Page 113: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 113 Author: A. Balogh

NSAPI / ISAPI

FrontPage Servererweiterung

Microsoft Management-Konsole Die Installation erfolgt mit der Installation der Office Tools: Start / Programme / Microsoft / Internet Explorer / Personal Web Server / Front Page Server Administrator

Page 114: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 114 Author: A. Balogh

IPS Internet Service Provider

PHP Befehle Warum werden meine PHP Befehle nicht ausgeführt? Damit die PHP Befehle ausgeführt werden muss die Datei die Erweiterung php haben. Als Beispiel: start.php

Page 115: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 115 Author: A. Balogh

Zugriffszähler / Counter Links: Wie benutze ich den grafischen Zugriffszähler? Beliebig viele grafische Zähler, wie Sie sie sicher schon häufig im Netz gesehen haben, können Sie folgendermassen einrichten: Binden Sie einfach den folgenden Code in die gewünschten Seiten ein: <img src="/cgi-bin/nph-count?width=5&link=http://IhreDomain.de/BeliebigeSeite.html"> Mögliche Parameter: width=[Nummer] Anzahl der Dezimalstellen des Zählers. link=[URL] URL der Seite, auf der der Zähler eingerichtet ist. increase=[Nummer] Gibt an, um wieviel Stellen der Zähler bei jedem Zugriff erhöht werden soll. show=NO Zähler ist unsichtbar, zählt aber weiterhin die Zugriffe. Mein Frontpage Counter geht nicht, was soll ich tun? Am einfachsten verwenden Sie den Counter aus unserem Member Bereich. Dieser ist äusserst einfach einzusetzen. oder Prüfen Sie Ihre Frontpage HTML einstellungen beim Counter, diese sollten so aussehen: <!--webbot bot="HitCounter" u-custom i-digits="5" i-image="0" PREVIEW="&lt;strong&gt;[Zugriffszähler]&lt;/strong&gt;" i-resetvalue="0" startspan --> <img src="_vti_bin/fpcount.exe/?Page=index.html|Image=0|Digits=5" alt="Hit Counter"> <!--webbot bot="HitCounter" endspan i-checksum="43146" -->

Dies setzt Frontpage automatisch ein, mit dem geht es NICHT! <!—webbot bot="HitCounter" i-image="0" i-digits="5" b-reset="TRUE" PREVIEW="&lt;strong&gt;[Zugriffszähler]&lt;/strong&gt;" u-custom i-resetvalue="0" --> Kopieren Sie den folgenden HTML Text in Ihrer Homepage <img alt="Counter Image"

SRC="http://193.135.144.195/cgi-bin/vcounter.cgi?page=www.ihrdomain.ch&style=odometer">

Parameter: odometer

curly LED LED_g odometer_sm rosewood

Page 116: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 116 Author: A. Balogh

GNU Make Download: ftp://ftp.gnu.org/pub/gnu Tools: autoconf automake libtool m4

What Is GNU Make? Make is a tool which controls the generation of executables and other non-source files of a program from the program's source files.

Make gets its knowledge of how to build your program from a file called the makefile,

which lists each of the non-source files and how to compute it from other files. When

you write a program, you should write a makefile for it, so that it is possible to use

Make to build and install the program.

Capabilities of Make

• Make enables the end user to build and install your package without knowing the details of how that is done -- because these details are recorded in the makefile that you supply.

• Make figures out automatically which files it needs to update, based on which source files have changed. It also automatically determines the proper order for updating files, in case one non-source file depends on another non-source file.

As a result, if you change a few source files and then run Make, it does not need

to recompile all of your program. It updates only those non-source files that

depend directly or indirectly on the source files that you changed.

• Make is not limited to any particular language. For each non-source file in the program, the makefile specifies the shell commands to compute it. These shell commands can run a compiler to produce an object file, the linker to produce an executable, ar to update a library, or TeX or Makeinfo to

format documentation.

• Make is not limited to building a package. You can also use Make to control installing or deinstalling a package, generate tags tables for it, or anything else you want to do often enough to make it worth while writing down how to do it.

Make Rules and Targets A rule in the makefile tells Make how to execute a series of commands in order to build a target file from source files. It also specifies a list of dependencies of the target file. This list should include all files (whether source files or other targets) which are used as inputs to the commands in the rule.

Here is what a rule looks like: target: dependencies ...

commands

...

When you run Make, you can specify particular targets to update; otherwise, Make updates the first target listed in the makefile. Of course, any other target files needed as input for generating these targets must be updated first. Make uses the makefile to figure out which target files ought to be brought up to date, and then determines which of them actually need to be updated. If a target file is newer than all of its dependencies, then it is already up to date, and it does not need to be regenerated. The other target files do need to be updated, but in the right order: each target file must be regenerated before it is used in regenerating other targets.

Page 117: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 117 Author: A. Balogh

Advantages of GNU Make GNU Make has many powerful macro features for use in makefiles, beyond what other Make versions have. It can also regenerate, use, and then delete intermediate files which need not be saved. GNU Make also has a few simple features that are very convenient. For example, the -o file option which

says ``pretend that source file file has not changed, even though it has changed.'' This is extremely useful when you add a new macro to a header file. Most versions of Make will assume they must therefore recompile all the source files that use the header file; but GNU Make gives you a way to avoid the recompilation, in the case where you know your change to the header file does not require it. However, the most important difference between GNU Make and most versions of Make is that GNU Make is free software.

About GNU Make Full documentation for GNU make is found in the Make manual, which is included in the GNU Make distribution. You can also buy printed copies of the Make manual from the Free Software Foundation; the money we raise goes to fund free software development.

Alternatively you can browse the online documentation available at

www.gnu.org/manual/make/index.html

You can download GNU make from the GNU FTP site ftp.gnu.org or one of its mirrors.

You can also obtain it by buying the GNU Source Code CD-ROM from the Free

Software Foundation; this too helps fund free software development.

GNU make was written by Richard Stallman and Roland McGrath.

Makefiles And Conventions We have developed conventions for how to write Makefiles, which all GNU packages ought to follow. It is a good idea to follow these conventions in your program even if you don't intend it to be GNU software, so that users will be able to build your package just like many other packages, and will not need to learn anything special before doing so.

These conventions are found in the chapter ``Makefile conventions'' (147 k

characters) of the GNU Coding Standards (147 k characters).

Page 118: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 118 Author: A. Balogh

Cascading Style Sheet ( CSS )

Introduction Cascading Style-Sheets (Ergänzungssprache/Formatbeschreibungssprache) Die HTML-Sprache enthält nur Befehle dafür, was ein Element ist, nicht wie es darzustellen ist. Das Ziel ist die Trennung von Daten und Layout. CSS-Style Sheets innerhalb von HTML-Tags ( <h1 style="font-family: Arial">BlaBla...</h1> ) Zentrale CSS-Dateien. Mit CSS-Dateien können unterschiedliche Medientypen definiert werden. Damit können verschiedene Layouts auf verschiedenen Ausgabegeräten definiert werden.

W3 Consortium Entwicklungsstufen:

Working Draft Candidate Recommendation

Proposed Recommendation Recommendation

Versionen 1996 CSS 1.0 CSS1 CSS-Level 1

CSS 2.0

Allgemein Online-Syntaxprüfung: http://jigsaw.w3.org/css-validator/

Links http://ibis.life.nottingham.ac.uk/~plxtb/css/test-css.html Alle Browser: http://www.hoary.org/browse/ www.w3.org/Style/CSS/

TIP • Mit <div> koennen die CSS-Style Befehle für einen ganzen Bereich festgelegt werden.

• Bei unsichtbaren HTML-Tabllen wird der Text für den Benutzer erst am Schluss angezeigt. Dies kann beschleunigt werden durch die Verwendung von Positionierten Texten.

• Gut verwendete CSS-Stylesheets sparen ladezeit und vermeiden jedes Mal eine Grafik einbinden zu müssen

Einbinden Es können mehrere Vorlagendateien eingebunden werden. die letzte überschreibt dabei Definitionen vorhergehender. Extern <LINK REL=stylesheet HREF="demo.css" TYPE="text/css">

oder <LINK REL=stylesheet HREF="../css/demo.css" TYPE="text/css">

oder <LINK REL=stylesheet HREF="http://www.a1-it.ch/css/demo.css" TYPE="text/css">

oder Media-Abhängig <LINK REL=stylesheet MEDIA="…" HREF="http://www.a1-it.ch/css/demo.css" TYPE="text/css">

Page 119: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 119 Author: A. Balogh

Eventuell nötig <meta http-equiv="Content-Style-Type" content="text/css">

Intern <style type="text/css">

#foot {font-family:Papyrus;} # Allg. Identifier (id="foot")

h1 {font-family:ArtNouveau;}

h2 a { …} # Verschachtelung von Formaten

- Gilt für alle a innerhalb H2!

h2+p { …} # Benachbarte Formate

- Nur für 1.ten Absatz nach h2

@media screen {body {background-image:url(meta-bg1.jpg);

div {margin-left:12.5%;

margin-right:12.5%;

padding:20px;

background-color:#CFCFCF;

color:blue;

}

a {text-decoration:none; font-weight:bold;} # Formatklassen

a.intern {color:orangered;} # Format-Unterklassen ( class="intern")

a.extern {color:darkred;} # Format-Unterklassen ( class="extern")

a.extern.2 {color:blue;} # Format-Unterklassen ( class="extern 2") </style>

Verwendung von Formatunterklassen HTML-Notation: <style type="text/css">

a.intern {color: red; }

a.extern {color: blue; }

a.foot {color: yellow; }

</div>

<a href=http://www.a1-it.ch class="intern"> Bauernhaus</a>

<a href=http://www.a1-it.ch class="extern"> Bauernhaus</a>

<a href=http://www.a1-it.ch id="foot"> Bauernhaus</a>

Verwendung von Formatunterklassen XML-Notation: <a href=http://www.a1-it.ch class~="extern"> Bauernhaus</a>

SYNTAX Eigenschaft: Wert ; <div style="...">...</div> Style Blockweise festlegen <span style="...">...</span> Style Inline-Level /*….*/ Kommentare

@ @font-face { font-family:Niagara Solid; url(http://www.a1-it.ch/myfont.ttf) }

A

B background-image:url(papier.jpg); background-color:#CFCFCF; background-repeat:no-repeat; background-repeat:repeat; background-repeat:repeat-x; nur "eine Zeile lang" waagerecht wiederholen background-repeat:repeat-;y bgproperties=fixed; Erzwingt Wasserzeichen border-collapse:collapse; Tabellenrahmen bündig oder separate

border:1px solid #000000; border-width: 5px;

Page 120: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 120 Author: A. Balogh

border-bottom:groove 2px; border-left:groove 2px; border-style:dotted; dashed, solid, double, groove, ridge, inset, outset border-top:

C color:#7C5503; red, blue, white, black

D display:none; table, inline-table, table-row, table-row-group, table-header-group, table-footer-group, table-column, table-column-group, cell

F font font-style: normal; italic, oblique font-family:Arial, sans-serif; Grundschriftart meist installiert. Verdana, Courier, Times New Roma, Bookman Old Style, Papyrus, Geneva, Verdana, Swiss, SunSans-Regular font-size:20pt; font-stretch: normal; wider, narrower, ultra-condensed, extra-condensed, condensed font-variant:small-caps; Kapitälchen ( normal, small-caps ) font-weight:bold; normal, bold, bolder, lighter

L letter-spacing line-height:16pt;

M margin:30px; margin-left:20%; margin-right:20%; margin-top: 0;

P

padding:20px; padding-top:3cm; padding-bottom:3cm; padding-left:3cm; padding-rightpadding-right:3cm; position:relative; Entspricht dem Netscape eigenen <ilayer>

R

repeat

T

table-layout:auto; fixed text-align:center; Horizontal in der Mitte text-decoration:none; Text unterstreichen, durchstreichen etc. none, underline, overline, line-through, blink text-indent:30px; Einzug erste Zeile text-shadow:none; Schatteneffekt none, <color>, <num1><num2> text-transform:capitalize; Gross- Kleinbuchstaben capitalize, uppercase, lowercase, none

V

vertical-align:text-top; middle, text-bottom

W

word-spacing

Page 121: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 121 Author: A. Balogh

Farben/Color FARBÜBERSICHT: D:\Install_WWW\Tools\selfhtml\tcaed.htm 8-Bit Farben Setzen sich aus 3 hexadezimal Ziffern zusammen ( z.B. h1 {color:#F00;} ). 16-Bit Farben Setzen sich aus 5 hexadezimal Ziffern zusammen ( z.B. h1 {color:#FF000;} ). Farbwörter:

activeborder Farbe der aktiven Fenstertitelzeile

activeborder Farbe der aktiven Fenstertitelzeile.

activecaption Farbe der Überschrift in der aktiven Fenstertitelzeile.

appworkspace Farbe des Hintergrunds der aktiven Anwendung.

background Farbe des Desktop-Hintergrunds.

buttonface Farbe von Buttons in Dialogfenstern.

buttonhighlight Farbe für 3D-Schatten von Buttons in Dialogfenstern.

buttontext Farbe von Texten beschrifteter Buttons in Dialogfenstern.

captiontext Farbe von Überschriften in Dialogfenstern.

greytext Farbe von deaktiviertem Text Dialogfenstern.

highlight Farbe von ausgewählten Einträgen in Auswahllisten.

highlighttext Farbe von selektiertem Text.

inactiveborder Farbe einer nicht aktiven Fenstertitelzeile.

inactivecaption Farbe der Überschrift in einer nicht aktiven Fenstertitelzeile.

infobackground Farbe für Tooltips und Hints (kleine Popup-Hilfen).

infotext Textfarbe für Tooltips und Hints (kleine Popup-Hilfen).

menu Farbe für Menüleisten.

menutext Farbe für Menüeinträge.

scrollbar Farbe der Scroll-Leiste in Fenstern.

threeddarkshadow Dunkle Farbe bei Schatten von 3D-Elementen.

threedface Farbe von 3D-Elementen.

threedhighlight Farbe von gerade angeklickten 3D-Elementen.

threedlightshadow Helle Farbe bei Schatten von 3D-Elementen.

threedshadow Dunkle Farbe bei Schatten von 3D-Elementen.

window Hintergrundfarbe von Dokumentfenstern.

windowframe Farbe von Fensterrahmen.

windowtext Farbe von normalem Text in Dokumentfenstern.

Alternative Schreibweisen: h1 {color:rgb(0,255,0);} h1 {color:rgb(50%,50%,50%);} <font color="#000000">Schwarz/black</font>

Schriftarten .eot Embedded Open Type

Page 122: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 122 Author: A. Balogh

.pfr TrueDoc

.ttf TrueType

.pfa/.pfb PostScript

Schriftquelle src: local("Papyrus"), url("papyrus.pfr") url(http://www.a1-it.ch/fonts);

Pseudo-Formate :link entspricht body link="…" :visited entspricht body vlink="…" :active entspricht body alink="…" :hover .text unabhängiges Format :before Wird nicht von allen Browsern unterstützt z.B. h2.Tipp:before { content:"Tip:…"; } :after Wird nicht von allen Browsern unterstützt :first-child Wird nicht von allen Browsern unterstützt :first-letter Wird nicht von allen Browsern unterstützt

Medientypen @media aural Akustische Ausgabe braille Ausgabegeräte für Blinde embossed Mit dem "Hammer" geschrieben handheld Taschencomputer print Ausgabe auf Papier projection Darstellung auf Leinwand screen Farbmonitore/LCD's tty Teletyper/Telex tv Fernsehgeräte all Alle Medientypen zusammengefasst Example @media

@media print { body {font-size:10pt; font-family:Courier-New;} } @media screen { body {font-size:20pt; font-family:Arial;} } @media screen, print { body {line-height:1,2;} }

Page 123: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 123 Author: A. Balogh

Zentrale Standard CSS

css_a1.css BODY, P { font-family : Arial, Geneva, sans-serif; font-size: 10pt; }

FONT { font-family : Arial, Geneva, sans-serif; font-size: 10pt; }

TABLE, TD { font-family : Arial, Geneva, sans-serif; font-size: 10pt; }

H1 { font-family : Arial, Geneva, sans-serif; font-weight : bold; color : #1C4E84;

font-size : 13pt; }

H2 { font-family : Arial, Geneva, sans-serif; font-weight : bold; color : #1C4E84;

font-size : 12pt; }

H3 { font-family : Arial, Geneva, sans-serif; font-weight : bold; color : #1C4E84;

font-size : 10pt; }

INPUT, SELECT, Textarea { font-family : Courier-New, Courier; font-size : 10pt; color : #000070; }

FONT.headline { font-family : Arial, Geneva, sans-serif; font-size: 14pt; font-weight : bold; }

FONT.subhead { font-family : Arial, Geneva, sans-serif; font-size: 10pt; font-weight : bold; }

FONT.picture { font-family : Arial, Geneva, sans-serif; font-size: 9pt; font-weight : bold;

font-style : italic; }

FONT.error { font-family : Arial, Geneva, sans-serif; font-size: 14pt; font-weight : bold;

color : #000070; }

FONT.small { font-size: 8pt; }

FONT.big { font-size: 12pt; }

A { font-size : 10pt; font-weight : normal; color : #000080; text-decoration : none; }

A:Visited { font-size : 10pt; font-weight : normal; color : #000080; }

A:Active { font-size : 10pt; font-weight : normal; color : Red; }

A:Hover { font-size : 10pt; font-weight : normal; color : Red; text-decoration : underline; }

A:Hover.button { text-decoration: none; cursor: hand; }

A.STATISTIC:link {font-size: 8pt; color: #FFFFFF; font-weight: bold}

A.STATISTIC:visited {font-size: 8pt; color: #FFFFFF; font-weight: bold}

A.STATISTIC:Hover {font-size: 8pt; color: #FFFFFF; font-weight: bold; text-decoration: underline}

A.STATISTIC:ACTIVE {font-size: 8pt; color: #FFFFFF; font-weight: bold; text-decoration: underline}

A.COUNTER:link {font-size: 9pt; font-weight: bold; text-decoration : none;}

A.COUNTER:visited {font-size: 9pt; color : #000080; font-weight: bold}

A.COUNTER:Hover {font-size: 9pt; color : Red; font-weight: bold; text-decoration: underline}

A.COUNTER:ACTIVE {font-size: 9pt; color : Red; font-weight: bold; text-decoration: underline}

TD.head { font-weight : bold; background : #6379B3; color : #ffffff; font-size: 10pt; }

TD.note { font-weight : normal; background : #6379B3; color : #ffffff; font-size: 8pt; }

TD.content { font-family : Courier-New, Courier; color : #000070; font-weight : normal;

background : #efefef; color : #000000; font-size: 10pt; }

TD.content_small { color : #000070; font-weight : normal; background : #efefef; color : #000000;

font-size: 9pt; }

TD.tom { font-family : Courier-New, Courier; color : #000070; font-weight : bold;

background : #cccccc; color : #000000; font-size: 10pt; }

TD.info { font-weight : normal; background : #efefef; color : #000000; font-size: 10pt; }

TD.job { font-weight : normal; background : #ffffff; color : #000000; font-size: 10pt; }

TD.jobtiny { font-weight : normal; background : #ffffff; color : #000000; font-size: 8pt; }

TD.andi { font-weight : normal; background : #ffffff; color : #000000; font-size: 10pt; }

TD.statistic { font-weight : bold; background : #6379B3; color : #ffffff; font-size: 8pt; }

TD.counter { font-weight : bold; background : #efefef; color : #000000; font-size: 9pt; }

TD.level0 { font-weight : normal; background : #CCDFEA; color : #000000; font-size: 10pt; }

TD.level1 { font-weight : normal; background : #cccccc; color : #000000; font-size: 10pt; }

TD.level2 { font-weight : normal; background : #dddddd; color : #000000; font-size: 10pt; }

TD.level3 { font-weight : normal; background : #eeeeee; color : #000000; font-size: 10pt; }

.error { font-family : Arial, Geneva, sans-serif; font-size: 10pt; font-weight : bold;

color : red; }

.tiny { font-family : Arial, Geneva, sans-serif; font-size: 8pt; }

Tabellen { display:table; }

Document Object Model ( DOM )

Page 124: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 124 Author: A. Balogh

Remote Data Service (RDS) Anbindung an: Access, Oracle oder SQL-Server Schnittstelle: OLE-DB oder ODBC

Page 125: Internet HTML / PHP / CGI / VB HTML_PHP_CGI_JS_VBS-S… · CSS Cascading Style-Sheets (Ergänzungssprache) z.B. Festlegen, dass alle Überschriften 1. Ordnung = 24 Punkte gross usw.

SW HTML_PHP_CGI_JS_VBS-Syntax.docx 08.03.19 125 Author: A. Balogh

Abkürzungen BLOB Binary Large Object (binärer Datenblock)