shuffle.cgi Utility Script


A commonly requested feature was the ability to mix up the gallery database so that galleries from the same sponsor that you imported together were not all lumped together with each other. When galleries are imported into the database, they are imported in order from the text file or data that you provide. If you do an import that has galleries all from the same sponsor, they will be lumped together in the database with ascending ID numbers. Many of the MySQL algorithms are optimized to pull galleries from the database in the order they were inserted. This shuffling script will randomize your database of galleries to provide a more random selection of galleries.

Before you Shuffle

The shuffle.cgi utility script is currently experimental, and therefore it is highly recommended that you make a backup of your gallery database and preview thumbnails before you run this script. You can backup your gallery database using the software's built in database backup utility. For your thumbnails, it is recommended that you create a tar archive of the entire directory where your thumbnails are stored.

Running the Shuffle Script

The shuffle.cgi script must be run from the command line of your server, it cannot be accessed through a browser. You will need SSH or telnet access to your server in order to use this script. The first step is to upload the shuffle.cgi script to your server. It should be uploaded in ASCII mode to the same directory as the file. Once uploaded, set it's permissions to 755.

You can now login to the server through telnet or SSH and change into the directory where the shuffle.cgi script is located. Make sure that no other software functions are running (page rebuilding, gallery scanner, etc). The shuffle script must be executed while no other scripts have an open connection to the database. It is also recommended that you run the shuffle script during a period of low server load, as it can cause a temporary spike in the CPU usage. Execute the following command to begin the shuffling process:

perl shuffle.cgi

On some servers you may need to specify the full path to perl, which might look like this (where /usr/local/bin is the directory where perl is located):

/usr/local/bin/perl shuffle.cgi

When you execute this command, the shuffle script will output some text to let you know that it is running. You should allow several minutes for the shuffle process to be completed, depending on how many galleries you have in the database. When the script is done it will print "The shuffling process has been completed." to the screen. You can now login to the AutoGallery SQL control panel and use the Display Galleries interface to view the galleries and make sure they are showing up properly.