|
|
|
New: 31-May-2004
|
|
Creates a single-page web site using Treeview (a Javascript menu) and a text file, via MySQL.
|
|
Source:
|
|
|
|
|
|
|
|
|
*
|
|
|
|
Updated: 2-May-2004
|
|
myadmin.cgi V 2.02 is the latest public version of a replacement for myadmin.cgi (Tut 35).
|
|
This version handles log in and user options per log in.
|
|
Source:
|
|
|
|
|
*
|
|
|
|
14-Jun-2001. Updated: 12-Dec-2001
|
|
name-download-[12].pl show 2 ways to specify the HTTP header to try to control the name of the file being downloaded.
|
|
This code ignores the question of what application/x-* type statements are in your web server's config file, and whether or not these statements interact with the code used here. Specifically:
|
|
name-download-1.pl uses
|
print $q -> header('application/x-octet-stream');
|
|
name-download-2.pl uses
|
print "Content-Disposition: attachment; filename = $file_name\n\n";
|
|
For Apache, this config file is called httpd.conf, and under Windows you'll find it at /Program Files/Apache Group/Apache/conf/httpd.conf.
|
|
Method 1 has the drawback of saving the *.xyz file with the name of 'method-1.xyz..xyz'.
|
|
Although method 2 looks simpler, since the script is entered only twice, compared to three times with method 1, there is a catch: Method 2 has the effect of outputting a file called *.xyz.txt rather than *.xyz.
|
|
Method 3 is a variation of method 1 which works for binary files.
|
|
name-download-1.pl uses the header 'application/x-octet-stream', and runs foul of IE's and Opera's habit of displaying a *.txt file in the browser's window, rather than offering you a Save As dialog box. For the other 2 suffixes, the files are saved as expected. For Netscape 6.01, all 3 file suffixes as saved as expected.
|
|
name-download-2.pl uses the 'Content-Disposition' header, and circumvents that behaviour of IE and Opera, and gets a Save As box, even for *.txt files. However, for Netscape 6.01, all 3 file suffixes result in the file being displayed in the browser's window.
|
|
The 'file' being downloaded by scripts 1 and 2 is not a real file; it is fabricated from data read from the DATA filehandle.
|
|
A completely different way of downloading is described here: http://www.de-srv.com/pub/namegame.html
|
|
Source:
|
|
|
|
|
*
|
|
|
|
27-May-2001
|
|
onfocus.pl shows how to use JavaScript event handlers to read and write form field values, and how to set style sheet attributes.
|
|
Using JavaScript event handlers, onFocus, onMouseOver and onMouseOut
|
|
Using JavaScript to change the name of the script associated with the form's action attribute
|
|
Using JavaScript to move values from one field on the form to another, i.e. using it to read and write form field values
|
|
Using Perl to attach a style sheet to a page
|
|
Using JavaScript to change the values of attributes on the style sheet
|
|
Using CGI.pm's 'force' option on some form fields, but not on others, to override the default 'sticky' behaviour
|
|
Source:
|
|
|
|
|
*
|
|
|
|
27-May-2001
|
|
cgi-popup.pl has a main window and a pop-up window. Communication between the windows is done via JavaScript.
|
|
Using various JavaScript event handlers, onBlur, onClick and onSubmit
|
|
Using Perl to specify the JavaScript to run when a link is clicked
|
|
Using JavaScript to open a new browser window when a link is clicked
|
|
Using JavaScript to run a script when a new browser window is opened
|
|
Using Perl and JavaScript to pass parameters to the script in the window
|
|
Using JavaScript to set the focus, and hence the cursor, to specific fields when the script runs and when a popup window is opened
|
|
Using JavaScript's autovivified array 'elements' to read out the values of fields within a form
|
|
Using JavaScript to validate a field when focus leaves that field. In production quality code, you always assume such validation has been circumvented, and redo the validation on the server side
|
|
Using the JavaScript function 'replace', which corresponds to Perl's s/old string/new string/
|
|
Using the JavaScript functions 'escape' and 'unescape', which, for example, encode CRLF into %0D%0A and back
|
|
Using the 'elements' array to pass data back from the popup window to the main window
|
|
Demonstrate how to design a script which can neatly display database records, and can let the user edit fields in one record at a time
|
|
Source:
|
|
|
|
|
*
|
|
|
|
13-Apr-2001. Updated 23-May-2001
|
|
upload-1-file.pl (the script) and upload-1-file-lib.pl (the OS-independent library) show you how to make file uploading painless.
|
|
Source:
|
|
|
|
|
*
|
|
|
|
25-Mar-2001
|
|
generic_edit.pl is a CGI script which can add/change/delete any record in any table in any database.
|
|
generic_edit.pl, with the help of MySQL and generic_bootstrap.pl, displays a form for any record, and allows you to edit it.
|
|
Source:
|
|
|
|
|
*
|
|
|
|
Different versions of Perl have different ideas about what data is tainted, so the backup option may or may not work with your version.
|
|
Features:
|
Operating System-level features
o Runs under Linux
o Runs under Windows NT, by changing the she-bang line
Perl-level features:
o Runs under -T
o Runs under $ENV{'PATH'} = '';
Database-level features:
o Create database
o Drop database
o Backup database via browser download
o Restore database
o Display the schema, ie column attrs, of all tables
Table-level features
o Create table
o Drop table
o Backup table via browser download
o Restore table
o Rename table
o Display table schema, ie column and index attrs
o 1-click Select *
o 1-click Equi-join (assumes 1:1 relationship between
tables)
o Display all foreign keys, here defined as columns
with the same name in 2 or more tables. This
feature makes my previous program in this area -
myschema.pl, in tutorial # 27 - obsolete.
All foreign keys are linked with hrefs, so by
clicking on a key in table A you are taken to the
definition of any other table B which has a
column of the same name
Index-level features
o Create index
o Drop index
Column-level features
o Add column
o Drop column
o Rename column
o Edit column attributes
o 1-click list all column attributes and cross-check
them (different tables, same column name).
Assumes 2 columns with the same name, in
different tables!, are meant to be the same.
SQL-level features
o Run any SQL command
|
|
See also mydiff.pl in tutorial # 26.
|
|
Source:
|
|
|
|
|
*
|
|
|
|
26-Jun-2001: Updated to use Class::MakeMethods
|
|
5-Dec-2000: Original
|
|
cob.pl uses Class::MakeMethods to automatically generate Perl source code for an object hierarchy, loads data into the objects, and then asks the objects to print themselves.
|
|
The difference with tutorial # 33 is that here the data is first loaded into a MySQL database, and then the object hierarchy is populated from 3 database tables.
|
|
See also tutorial # 33.
|
|
Source:
|
|
|
|
|
*
|
|
|
|
26-Jun-2001: Updated to use Class::MakeMethods
|
|
5-Dec-2000: Original
|
|
sob.pl uses Class::MakeMethods to automatically generate Perl source code for an object hierarchy, loads (hard-coded) data into the objects, and then asks the objects to print themselves.
|
|
All major steps along the way are explained in commentary in the source.
|
|
Class::MakeMethods is a rather amazing module which, given only 3 or 4 lines of Perl, will generate all the source code for a class and its methods. All you have to do is specify the name of the class, and the names of any scalars and objects in the class, and Class::MakeMethods will create a complete class, including a constructor and methods to get and set values for each scalar attribute. You class can have lists of nested objects, too.
|
|
I'd go so far as to say Class::MakeMethods should be compulsory for anyone learning object oriented programming in Perl.
|
|
See also tutorial # 34, which loads objects from a MySQL db.
|
|
Source:
|
|
|
|
|
*
|
|
|
|
30-Oct-2000
|
|
xml-2-image.pl reads the XML output by text-2-image.pl, or any XML file in the same format, and generates a set of buttons, where each button contains one line of text as returned by sub get_button_text
|
|
Source:
|
|
|
|
|
*
|
|
|
|
30-Oct-2000
|
|
text-2-image.pl is a CGI script which demonstrates how to use Image::Magick to design an image containing a string of text.
|
|
You can, via a menu, create an image from scratch, with the 'Text onto image' option, or put text onto an existing image, with 'Text onto button'.
|
|
The image is written to a disk file in your chosen format, eg png, and the attributes are written to a disk file in XML. Another program in this series, xml-2-image.pl, can read this XML and generate a set of images. Eg: It can read the attributes and output a set of images (buttons), each one with different text but otherwise identical to the image you designed using this script.
|
|
Source:
|
|
|
|
|
*
|
All Programs of mine are 'OSI Certified Open Source Software';
you can redistribute them and/or modify them under the terms of
The Artistic License, a copy of which is available at:
http://www.opensource.org/licenses/index.html
|
*
|