remove old files

This commit is contained in:
reinerj 2004-05-05 08:30:48 +00:00
parent caefc24438
commit 6c8396e79c
3 changed files with 4 additions and 121 deletions

View File

@ -1,12 +1,12 @@
#!/usr/bin/php -q
<?php
/**************************************************************************\
* phpGroupWare API - Timed Asynchron Services for phpGroupWare *
* eGroupWare API - Timed Asynchron Services for eGroupWare *
* Written by Ralf Becker <RalfBecker@outdoor-training.de> *
* Class for creating cron-job like timed calls of phpGroupWare methods *
* Class for creating cron-job like timed calls of eGroupWare methods *
* -------------------------------------------------------------------------*
* This library is part of the phpGroupWare API *
* http://www.phpgroupware.org/ *
* This library is part of the eGroupWare API *
* http://www.egroupware.org/ *
* ------------------------------------------------------------------------ *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by *

View File

@ -1,33 +0,0 @@
<?php
/**************************************************************************\
* phpGroupWare *
* http://www.phpgroupware.org *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
// stalesession.php - to use instead of stalesession.pl
// may be invoked via cron with "php stalesession.php"
// config start
$purgedelay = "3600"; // define allowed idle time before deletion in seconds
$purgetime = time() - $purgedelay;
$db_user = $ARGV[1];
$db_pwd = "my_pass";
$db_server = "localhost";
$db_db = "phpGroupWare";
// config end - do not edit after here unless you really know what you do!
// establish link:
$link = mysql_connect("$db_server","$db_user","$db_pwd");
mysql_query("use $db_db", $link);
// delete old (timed out) sessions
$query = sprintf("delete from phpgw_sessions where session_dla <= '$purgetime'");
$res = mysql_query($query, $link);
?>

View File

@ -1,84 +0,0 @@
#!/usr/bin/perl
# /**************************************************************************\
# * phpGroupWare *
# * http://www.phpgroupware.org *
# * Written by Joseph Engo <jengo@phpgroupware.org> *
# * -------------------------------------------- *
# * This program is free software; you can redistribute it and/or modify it *
# * under the terms of the GNU General Public License as published by the *
# * Free Software Foundation; either version 2 of the License, or (at your *
# * option) any later version. *
# \**************************************************************************/
# $Id$
use DBI;
# Config section
$db_host = 'localhost';
$db_name = 'phpGroupWare';
$db_user = 'phpgroupware';
$db_pass = 'my_password';
# Email users when they don't log out ?
# If you are selecting this option. You might want to customize the message
# below.
# Note: This takes much longer to clean out the database each time. Since it
# must go select each user and then email them.
$email_user = 'Y';
$sendmail_location = '/usr/sbin/sendmail';
# Where should the message be comming from ?
$message_from = "webmaster\@mydomain.com";
# This is how long a user can be at idle before being deleted. Look at the
# SECURITY file for more information.
# The default is set to 2 hours.
$secs_to_stale = '3600';
# uncomment the line for your database.
# mysql
$dbase = DBI->connect("DBI:mysql:$db_name;$db_host",$db_user,$db_pass);
# postgresql
#$dbase = DBI->connect("DBI:Pg:dbname=$db_name;host=$db_host",$db_user,$db_pass);
# End of config section
$staletime = time() - $secs_to_stale;
if ($email_user eq 'Y') {
$command = $dbase->prepare("select session_lid,session_logintime,session_ip,session_id from "
. "phpgw_sessions where session_dla <= '$staletime'");
$command->execute();
while (@session_data = $command->fetchrow_array()) {
send_message($session_data[0],$session_data[1],$session_data[2]);
$command2 = $dbase->do("delete from phpgw_sessions where session_id='$session_data[3]'");
}
} else {
$command = $dbase->do("delete from phpgw_sessions where session_dla <= '$staletime'");
}
#$command->finish();
$dbase->disconnect();
sub send_message($$$)
{
my($loginid, $logintime,$IP)=@_;
open ( SENDMAIL, "|$sendmail_location -t" ) || warn "Can't open sendmail";
print SENDMAIL "To: $loginid\@localhost\n";
print SENDMAIL "Subject: Important account information\n";
print SENDMAIL "From: $message_from\n\n";
print SENDMAIL "According to our records, you have not logged out during ";
print SENDMAIL "your recent session. It is important to that you click ";
print SENDMAIL "on the logout icons when done with your session. ";
print SENDMAIL "\nFor more information, contact your system admin.\n\n";
print SENDMAIL "Session information:\n";
print SENDMAIL "logintime: " . localtime( $logintime ) . "\n";
print SENDMAIL "IP Address: " . $IP . "\n.\n";
close ( SENDMAIL );
}