Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

40 lines (32 sloc) 1.398 kb
<?php
////////////////////////////////////////////////////////////////////////////
// SAVED SCHEDULE PRUNER
//
// @author Ben Russell (benrr101@csh.rit.edu)
//
// @file tools/pruneSchedules.php
// @descrip A stand alone tool (that should be cronjobbed) to prune saved
// schedules that are older than 90 days.
////////////////////////////////////////////////////////////////////////////
// Make sure the working directory is correct
chdir(dirname($_SERVER['SCRIPT_FILENAME']));
// Bring in the database connection
require "../inc/databaseConn.php";
global $dbConn;
// Build a where clause that will be resued
$where = "WHERE (NOW() - datelastaccessed > (60 * 60 * 24 * 90))";
// Run the query to delete the courses of the schedule that are older than
// 90 days
$query = "DELETE FROM schedulecourses WHERE schedule = (SELECT id FROM schedules {$where})";
$result = mysql_query($query);
if(!$result) { echo(mysql_error() . "\n"); }
// Run the query to delete the non-course items of the schedule that are older
// than 90 days
$query = "DELETE FROM schedulenoncourses WHERE schedule = (SELECT id FROM schedules {$where})";
$result = mysql_query($query);
if(!$result) { echo(mysql_error() . "\n"); }
// Run the query to delete the schedules that are older than 90 days
$query = "DELETE FROM schedules {$where}";
$result = mysql_query($query);
if(!$result) { echo(mysql_error() . "\n"); }
?>
Jump to Line
Something went wrong with that request. Please try again.