|
WebKeystone Example 4: Creating a form with a rotating banner
Banners may be used as advertising space on websites. Many low-end websites support "static" banners, which means that the webmaster must manually modify the website to change the banner. Other sites display a different banner each time you access them; these sites are using "rotating" banners.
This example shows how to create a rotating banner using WebKeystone. It assumes that your site has "Server Side Include" support (ask your hosting company if you're not sure). Considerations on the security implications of SSI are described below.
... <!--#include virtual="/wkstone/webkeystone.py?UserID=biz_webkeystone&Profile=examples/example4.prof" --> ... |
SSI include statments look very much like comments, but they get interpreted and acted upon by your web server. This URL points to "/wkstone/webkeystone.py" and passes two fields to it: UserID and Profile.
Oftentimes you must name your webpage with a ".shtml" extension in order for SSI statements to work. This is the default behavior with Apache (the most popular web server software). Your web site administrator may also need to turn SSI on for your website in order for this to work. Note that this Startfile is named "example4.shtml".
# File : example4.prof
# Funciton : Example showing how to build rotating banners using WebKeystone.
#
# Define your list of URLs in the following format.
#
# (<website address>, <image address>)
#
adlist = [ +
('http://www.webkeystone.com/', 'http://www.webkeystone.com/wkimages/logoSmall.gif'), +
('http://www.python.org/', 'http://www.python.org/pics/pythonHi.gif'), +
('http://www.apache.org/', 'http://www.apache.org/foundation/images/asf_logo.gif'), +
]
#
# Select which advertisement
#
selection = f.random.choice(adlist)
website = selection[0]
image = selection[1]
#
# Create HTML for banner using substitution.
#
%banner = <a href="%(website)s"><img border="0" src="%(image)s"></a>
RETURN RAW banner
|
Some webserver administrators may be reluctant to enable SSI for customer pages because of security concerns. It is often believed that enabling SSI will allow customers to execute any command on the system. This is one of many reasons WebKeystone was developed, so we would not advocate exposing your system in this way.
There is a way of configuring Apache web servers to support SSI without compromising security. This example configuration illustrates how to enable SSI while still providing security:
<Directory /home/joeblogg/html> Options IncludesNoExec </Directory>
The "IncludesNoExec" statement will allow SSI but not allow any commands to be executed that are inaccessible from the web.
| Previous Example | Next Example | Table of Contents |
Updated 15-May-01
|
|
|
|
|
| WebKeystone is a product of Townsend Software, Inc. ©1998 - 2001 Townsend Software, Inc. All rights reserved. |