|
| 1 | +<?php |
| 2 | +################################################################################ |
| 3 | +# Program Name: Delete_Temporary_Files.php |
| 4 | +# Description: Deletes temporary files created by LaTeX_Converter.pl. |
| 5 | +# Usage: Delete_Temporary_Files.php?dir=name |
| 6 | +# Causes directory "/temporary/name" and all of its contents to |
| 7 | +# be deleted. |
| 8 | +# History: v.1.0 written in 12/9/06 by Philip Stevenson (initial version) |
| 9 | +# |
| 10 | +# Copyright (C) 2007 Tyler A. Davis |
| 11 | +# Copyright (C) 2007 Philip Stevenson |
| 12 | +# |
| 13 | +# This program is free software; you can redistribute it and/or |
| 14 | +# modify it under the terms of the GNU General Public License |
| 15 | +# as published by the Free Software Foundation; either version 2 |
| 16 | +# of the License, or (at your option) any later version. |
| 17 | +# |
| 18 | +# This program is distributed in the hope that it will be useful, |
| 19 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 | +# GNU General Public License for more details. |
| 22 | +# |
| 23 | +# You should have received a copy of the GNU General Public License |
| 24 | +# along with this program; if not, write to the Free Software |
| 25 | +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 26 | +################################################################################ |
| 27 | + |
| 28 | +#Microsoft Word will not make the call to this PHP script if the URL has already |
| 29 | +#been called since Word was started. This shouldn't be a problem, since the |
| 30 | +#directory name should be unique each time a PNG is generated, but Word appears |
| 31 | +#to apply its URL-checking incorrectly. The following line guarantees that this |
| 32 | +#script will be called every time. |
| 33 | +header("Cache-Control: no-cache, must-revalidate" ); |
| 34 | + |
| 35 | +#The name of the directory should only be a string of numbers. Return an error |
| 36 | +#if any other argument is used or if the string is too short or too long. |
| 37 | +$Directory_Name = $_GET['dir']; |
| 38 | + |
| 39 | +if ( (preg_match('/\D/', $Directory_Name)) |
| 40 | + || (strlen($Directory_Name) > 10) |
| 41 | + || (strlen($Directory_Name) < 1) ) |
| 42 | + {echo 'Invalid directory name.';} |
| 43 | +else |
| 44 | +{ |
| 45 | + system("/usr/local/bin/rm -r /tmp/$Directory_Name"); |
| 46 | + system("/usr/local/bin/rm -r temporary/$Directory_Name"); |
| 47 | +} |
| 48 | + # {system("rm -r temporary/$Directory_Name");} |
| 49 | +?> |
0 commit comments