Work the Shell - Displaying Image Directories in Apache, Part IV
With all of this tucked into the script, we can use a skeleton table to organize things neatly. In a rough form, it'll look like this:
<table border="0"><tr> <td align="center">image</td> <td align="center">image</td> <td align="center">image</td> </tr></table>
Dropping it into the script, the key block that both displays the image, scaled, and keeps track of when we need to produce a new row in the table is:
if [ $linecount -eq $maxperline ] ; then # new row of table echo "</tr><tr>" linecount=0 fi echo "<td align='center' valign='bottom'>" echo "<a href=$name><img src=$name border=0" echo " alt=$name height=$height width=$width />" echo "<br>$name</a><br>($height x $width)</td>" linecount=$(( $linecount + 1 ))
Now, because I want to write a highly readable script, it's worth highlighting that the top section lets you configure the heck out of this:
maxsize=150 # max thumbnail size, in pixels maxperline=3 # max images per table row
Both of these constants can be tweaked as needed. The result? See Figure 1. Sweet!
The full script is pretty cool. If you'd like to get a copy of it, please pop over to my site: www.intuitive.com/wicked/imagedir.txt. Save it as index.cgi in an image directory on your Web server.
Dave Taylor is a 26-year veteran of UNIX, creator of The Elm Mail System, and most recently author of both the best-selling Wicked Cool Shell Scripts and Teach Yourself Unix in 24 Hours, among his 16 technical books. His main Web site is at www.intuitive.com, and he also offers up tech support at AskDaveTaylor.com.
Dave Taylor has been hacking shell scripts for over thirty years. Really. He's the author of the popular "Wicked Cool Shell Scripts" and can be found on Twitter as @DaveTaylor and more generally at www.DaveTaylorOnline.com.
Fast/Flexible Linux OS Recovery
On Demand Now
In this live one-hour webinar, learn how to enhance your existing backup strategies for complete disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible full-system recovery solution for UNIX and Linux systems.
Join Linux Journal's Shawn Powers and David Huffman, President/CEO, Storix, Inc.
Free to Linux Journal readers.Register Now!
- Server Hardening
- EnterpriseDB's EDB Postgres Advanced Server and EDB Postgres Enterprise Manager
- The Death of RoboVM
- BitTorrent Inc.'s Sync
- The Humble Hacker?
- The US Government and Open-Source Software
- Open-Source Project Secretly Funded by CIA
- New Container Image Standard Promises More Portable Apps
- ACI Worldwide's UP Retail Payments
- Canonical and BQ's Aquaris M10 Ubuntu Edition Tablet
In modern computer systems, privacy and security are mandatory. However, connections from the outside over public networks automatically imply risks. One easily available solution to avoid eavesdroppers’ attempts is SSH. But, its wide adoption during the past 21 years has made it a target for attackers, so hardening your system properly is a must.
Additionally, in highly regulated markets, you must comply with specific operational requirements, proving that you conform to standards and even that you have included new mandatory authentication methods, such as two-factor authentication. In this ebook, I discuss SSH and how to configure and manage it to guarantee that your network is safe, your data is secure and that you comply with relevant regulations.Get the Guide