infopop’s UBB.Threads™ software

Enabling Forum Digests and Automatic Thread Expiration with Cron Tasks

 

 

 

 

 

 

 

ă Infopop Corporation. All rights reserved.

 

112 Fifth Avenue North • Seattle WA 98109

Phone 206.283.5999 • Fax 206.283.6166

 

 

Document Last Revised: 11/19/03

 

 

Infopop, UBB, UBB.threads, UBBCode, UBBFriend, OpenTopic,

Wordlet, and other Infopop products/features referenced in this

document are trademarks of Infopop Corporation


Table of Contents


Enabling Forum Digests & Automatic Thread Expiration with Cron Tasks. 3

Which scripts should I use?. 3

Using the Perl Scripts. 3

1.     Make sure your server is ready  3

2.        Customize the Variables. 4

3.        Customize paths. Error! Bookmark not defined.

5.     Upload Files  4

6.     Change Permissions. 4

7.     Set a Cron Task – Subscriptions. 4

8.     Set a Cron Task – Thread Expiration. 5

Using the PHP Scripts. 5

1.        Customize Paths. 5

2.     Upload Files  6

3.     Change Permissions. 6

4.     Set up Cron Task – Subscriptions. 6

5.     Set up Cron Task – Thread Expiration. 6

Additional Information Resources. 7

Linux. 7

Win2K Servers - Using Task Scheduler7

Windows NT/ Windows 2000. 7


 

 


Enabling Forum Digests & Automatic Thread Expiration with Cron Tasks

UBB.threads™ software has a forum digest tool and automatic thread expiration features that require the setup of an automated cron task on your web server. A cron task is a command that is run on a timed basis (often, once a night) automatically by the server.

Please consult your web host for cron task availability and installation as most hosts differ greatly in their implementation methods.  Most web hosts will allow you to have at least a single cron task, scheduled to run once per night.

 

Which scripts should I use?

 

Within your UBB.threads zip file, you’ll see a “cron” folder that contains both a “Perl” and “PHP” folder.  You’ll need to use the information below to determine which set of scripts to use, and follow the specific instructions in this document to get them up and running.

If you’re hosted:

Ask your host if PHP is installed as a CGI binary and capable of running PHP scripts from a cron.  Your host will understand what this question means.  If the answer is yes, you can use the scripts in the PHP folder.  If the answer is no, use the Perl scripts.

If you run your own server:

Is PHP installed as an Apache module or as a CGI binary?  Or both?  If it’s a CGI binary or both, you can use the PHP cron scripts.  If it’s just Apache module, and can’t be run from command line, use the Perl versions.

 

Using the Perl Scripts

 

 

1.         Make sure your server is ready

The server must have Perl version 5.00404 or higher and a MySQL database.

If your web server doesn’t already have them installed, download and install the following modules, in the order shown.  Installation procedures are included in each of their respective packages.  If you are with a web hosting company, ask them if you have these modules on your particular server.

 

DBI-1.06+ : These are the perl modules used by UBB.threads to communicate with the SQL server.  http://search.cpan.org/search?dist=DBI

 

Data-Dumper-2.09+  : http://search.cpan.org/search?dist=Data-Dumper

Data-ShowTable-3.3+ : http://search.cpan.org/search?dist=Data-ShowTable

The DBI-MySQL driver  (If you are prompted for which modules you want to install, choose either MySQL or both. Be careful not to choose MySQL only.) http://search.cpan.org/search?dist=DBD-mysql

2.            Customize the Variables

Using NotePad or a suitable text editor, open the file called w3tvars.pm and look at all of the variables under “user defined variables”.  You’ll need to gather this information and then edit the values of these variables to fit your server configuration.

Example:

#Url to the main UBB.threads install

$config{‘cgiurl’} =    ‘http://www.wwwthreads.com/boards’;

In the example above, you would substitute your own URL for the default one highlighted in yellow.

If you have trouble finding the values you should use, take a look in your UBB.threads Admin panel, under “config settings”.

3.         Upload Files

Open your FTP program and upload all of the files in the Perl subfolder (within the cron folder of your zip) in ASCII mode.  Be sure to place them in the cron folder location you specified in the variables earlier.

4.            Change Permissions

Change the file permissions on doexpire.pl and subscriptions.pl files so that they can be read and executed by everyone (755).  No other permissions need to be set.

Either use telnet to issue the command chmod 755 *.pl, or use your FTP program to set the permissions.  For assistance with permissions, see the detailed explanation in the UBB.threads Installation Guide.

5.         Set a Cron Task – Subscriptions

If you wish to use the digest subscriptions feature (users can subscribe to daily digests of forum activity), then the file subscriptions.pl should be run nightly.  Tell your webhost the location where you have uploaded the file, and request that they set up a cron task for you to run the script.

If you’re doing it yourself, you need to edit your crontab so the script will run nightly.  Use the command “crontab –e” or “man crontab”.  DO NOT RUN THIS SCRIPT AS ROOT.

Something like the following will work on most systems.

0 1 * * * root /home/httpd/html/ubbthreads.com/cron/perl/subscriptions.pl

You might also need to change the path to the script or the user it runs as, but this example would run the script at 1 AM every morning.

Once the cron task is set up, you will need to go into your UBB.threads Admin control panel, click “config settings”, click “special functions/miscellaneous”, and select “allow subscriptions to forum”.  Click “update config.inc.php” and the digest notification feature will be enabled.

6.         Set a Cron Task – Thread Expiration

If you want to have automatic expiration of outdated threads, you will need to set up doexpire.pl to run as well.  If your web host will allow you to run more than one cron task, send the location of this file to your web host and request that they set up a second cron task to run this script.

If you’re doing it yourself, you need to edit your crontab so the script will run nightly.  Use the command “crontab –e” or “man crontab”.  DO NOT RUN THIS SCRIPT AS ROOT.

Something like the following will work on most systems.

0 2 * * * root /home/httpd/html/ubbthreads.com/cron/perl/doexpire.pl

You might need to change the path to the script or the user it runs as, but this would run the script at 2 AM every morning.

Once this cron task is set up, you will need to go into your UBB.threads Admin control panel, click “edit or delete a forum”, and choose the forum in which you want threads to expire (this must be enabled on a per-forum basis).  In the forum settings, under “expire threads after how many days”, select a number of days. 

For example, if you have this set to 30 days, any threads in that forum which have had no new posts in the last 30 days will be deleted (unless they’re “sticky” or “kept” threads).  It’s a good idea to have the cron task purge automatically every night, since otherwise, expired threads could build up.

Using the PHP Scripts

 

1.            Customize Paths

Using NotePad, or a suitable text editor, open doexpire.php and subscriptions.php and place the path to PHP in the top of the script.  For example, it might look like this:

#!/usr/bin/php

Also in subscriptions.php, you have to change line 22 of the script to reflect the location of your specific install. (i.e., the following line is hard-coded in the script, and needs to be edited:

 

<pre class="ip-ubbcode-code-pre">  require ("/home/www/html/ubbthreads/main.inc.php");</pre>

 

2.         Upload Files

Open your FTP program and upload the two files in the PHP subfolder (within the cron folder of your zip) in ASCII mode.  Be sure to maintain the same file structure on your server as is contained in the zip.

3.            Change Permissions

Change the file permissions on doexpire.php and subscriptions.php files so that they can be read and executed by everyone (755).  No other permissions need to be set.

Either use telnet to issue the command chmod 755 *.php, or use your FTP program to set the permissions.  For assistance with permissions, see the detailed explanation in the UBB.threads Installation Guide.

4.         Set up Cron Task – Subscriptions

If you wish to use the digest subscriptions feature (users can subscribe to daily digests of forum activity), then the file subscriptions.php should be run nightly.  Tell your webhost the location where you have uploaded the file, and request that they set up a cron task for you to run the script.

If you’re doing it yourself, you need to edit your crontab so the script will run nightly.  Use the command “crontab –e” or “man crontab”.  DO NOT RUN THIS SCRIPT AS ROOT.

Something like the following will work on most systems.

0 1 * * * root /home/httpd/html/ubbthreads.com/php/cron/subscriptions.php

You might also need to change the path to the script or the user it runs as, but this example would run the script at 1 AM every morning.

Once the cron task is set up, you will need to go into your UBB.threads Admin control panel, click “config settings”, click “special functions/miscellaneous”, and select “allow subscriptions to forum”.  Click “update config.inc.php” and the email digest feature will be enabled.

5.         Set up Cron Task – Thread Expiration

If you want to have nightly expiration of outdated threads, you will need to set up doexpire.php to run as well.  If your web host will allow you to run more than one cron task, send the location of this file to your web host and request that they set up a second cron task to run this script.

If you’re doing it yourself, you need to edit your crontab so the script will run nightly.  Use the command “crontab –e” or “man crontab”.  DO NOT RUN THIS SCRIPT AS ROOT.

Something like the following will work on most systems.

0 2 * * * root /home/httpd/html/ubbthreads.com/php/cron/doexpire.php

You might need to change the path to the script or the user it runs as, but this would run the script at 2 AM every morning.

Once this cron task is set up, you will need to go into your UBB.threads Admin control panel, click “edit or delete a forum”, and choose the forum in which you want threads to expire (this must be enabled on a per-forum basis).  In the forum settings, under “expire threads after how many days”, select a number of days. 

For example, if you have this set to 30 days, any threads in that forum which have had no new posts in the last 30 days will be deleted (unless they’re “sticky” or “kept” threads).  It’s a good idea to have the cron task purge automatically every night, since otherwise, expired threads could build up.

Additional Information Resources

 

Linux

 http://www.redhat.com/docs/manuals/linux/RHL-7.3-Manual/custom-guide/ch-autotasks.html#S1-AUTOTASKS-CRON

Win2K Servers - Using Task Scheduler

http://www.microsoft.com/windows2000/en/server/help/agent_idle_time.htm

Windows NT/ Windows 2000

HOW TO: Schedule a Server Process in Windows 2000 (Q300160)

http://support.microsoft.com/default.aspx?scid=kb;en-us;Q300160

HOW TO: Use the AT Command to Schedule Tasks (Q313565)

http://support.microsoft.com/default.aspx?scid=kb;en-us;Q313565