error_reporting(0);
include("functions.php");
include("fonts.php");
$h1 = "DJ Mike's Image Maker 2";
$h2 = "Font Viewer";
######################### 9
# Sweep font directory every time this page viewed
### Directory Sweeper ###
# create directory resource and read it
$directory = opendir("temp_fonts/");
while (true == ($file = readdir($directory)))
{
# but don't read the links to directories
if ( is_file("temp_fonts/$file") )
{
# find out when it was created 20
$created_time = filemtime("temp_fonts/$file");
# $age = present time-$created_time
$age = time()-filemtime("temp_fonts/$file");
# delete if more than 8 hours old.
# 8 hr = 28800 seconds; 24 hr= 86400 sec
# don't delete the indexes or .htaccess or fonts
if ( $age > 28800 && !preg_match("@\.htaccess|index\.ttf@i", $file, $x) )
{ unlink("temp_fonts/$file"); }
# sweeps out any files that don't belong 33
if ( !preg_match("@(.htaccess|index|\.ttf)$@i", $file, $x) )
{ unlink("temp_fonts/$file"); }
}
}
closedir($directory);
################################## End Sweeper
if ( $_GET[display_font] )
{
$_SESSION[font] = $_GET[display_font];
header("location:$self");
exit;
}
# is font submitted?
if ( $new_font = trim($_GET[new_font]) )
{
# does font start with http:// and end in .ttf?
if ( preg_match( "@^http://.*\.ttf$@i", "$new_font", $match ) )
{
# get file name
$name = explode( "/", $new_font );
$name = array_pop($name);
# replace invalid characters
$name = preg_replace( "@[^\w\.]@i", "_", $name);
# try to copy font
if ( @copy( $new_font, "temp_fonts/$name") )
{
$_SESSION[sucess] = "$name has been uploaded";
# save settings
$_SESSION[font] = "temp_fonts/$name";
header("location:$self"); exit;
}
else
{
$_SESSION[error] = "Could not upload $new_font.
Must start with http:// and end in .ttf";
header("location:$self"); exit;
}
}
else
{
$_SESSION[error] = "$new_font is not a font.";
header("location:$self"); exit;
}
}
?>