<?php

##########################################
#                                        #
# PHP Gallery                            #
# Copyright 2001 Stephen Ball            #
# You may not remove the copyright or    #
# redistribute the script in any form    #
# Visit www.aquonics.com for more top    #
# scripts, free and custom.              #
#                                        #
##########################################

error_reporting(0);
if(!include("./data/settings.inc.php")) $error = 1;
if(!$extfile = file("./data/files.ext.php")) $error = 1;

$message = "<font face=\"$font\" size=\"1\">$message</font>\n";



readfile ('http://skateclass.ru/header.shtml');

echo "        <TR valign=top>\n";
echo "	      <TD colspan=2 background=images/back_way_l.gif class=norepeat>\n";
echo "		    <table width=\"100%\" border=\"0\" cellspacing=\"10\" cellpadding=\"0\">\n";
echo "			  <tr>\n";
echo "				<td>\n";






if($stylesheet !== "None") echo "<link rel=\"stylesheet\" href=\"$stylesheet\" type=\"text/css\">\n";
echo "</head>\n";
echo "<body bgcolor=\"$bgcolor\" text=\"$text\">\n";
echo "<center>\n";

if($error == 1) {
		die ("<table border=\"0\" cellspacing=\"1\" cellpadding=\"4\" bgcolor=\"black\" width=\"75%\">\n
		<tr align=\"center\" bgcolor=\"white\">\n
		<td>\n
		<font face=\"Arial, Helvetica, sans-serif\" size=\"1\">There was an error loading a configuration file, please contact the site admin.</font><br>\n
		</td>
		</tr>\n
		</table>\n
		</body>\n
		</html>\n");
}


/*
A simple function used to display the form for uploading files
*/

function upload_form() {
	global $archive_dir, $PHP_SELF, $bgcolor, $text, $width, $headercell, $maincell, $border, $style, $font, $links;


	$data = "<table border=\"0\" cellspacing=\"1\" cellpadding=\"4\" bgcolor=\"$border\" width=\"$width\">\n";
	$data .= "<form method=\"post\" enctype=\"multipart/form-data\" action=\"$PHP_SELF\">\n";
	$data .= "<tr align=\"center\" bgcolor=\"$maincell\">\n";
	$data .= "<td><input type=\"hidden\" name=\"action\" value=\"upload\">\n";
	$data .= "<font face=\"$font\" size=\"1\">Upload File!</font><br>\n";
	$data .= "<input type=\"file\" name=\"userfile\"><br>\n";
	$data .= "<input type=\"submit\" name=\"submit\" value=\"Upload\">\n";
	$data .= "</td>\n";
	$data .= "</tr>\n";
	$data .= "</form>\n";
	$data .= "</table>\n";
	$data .= "<br><center>\n";
	$data .= "<font face=\"$font\" size=\"1\">$links<br><br>\n";
	$data .= "</font>\n";
	$data .= "</center>\n";

	template("$data");
}

/*
This function uploads the file to a temp directory & moves it to the archive folder.
It also checks to make sure the file to be uploaded exist on the user computer, that it is within the file size range,
that it is a correct image and that it doesn't already exist on the server
*/

function upload_file() {
	global $extfile, $archive_dir, $userfile, $userfile_name, $userfile_size, $maxupload, $userfile_type, $bgcolor, $text, $width, $links, $headercell, $maincell, $border, $style, $font;

$filename = basename($userfile_name);

if($userfile_size <= 0) {
	$data = "<table border=\"0\" cellspacing=\"1\" cellpadding=\"4\" bgcolor=\"$border\" width=\"$width\">\n";
	$data .= "<tr align=\"center\" bgcolor=\"$maincell\">\n";
	$data .= "<td>\n";
	$data .= "<font face=\"$font\" size=\"1\"><b>Error</b>: File does not exist.</font><br>\n";
	$data .= "</td>";
	$data .= "</tr>\n";
	$data .= "</table>";
}

elseif($userfile_size > $maxupload) {
	$data = "<table border=\"0\" cellspacing=\"1\" cellpadding=\"4\" bgcolor=\"$border\" width=\"$width\">\n";
	$data .= "<tr align=\"center\" bgcolor=\"$maincell\">\n";
	$data .= "<td>\n";
	$data .= "<font face=\"$font\" size=\"1\"><b>Error</b>: $filename is too big.</font><br>\n";
	$data .= "</td>";
	$data .= "</tr>\n";
	$data .= "</table>";
}

elseif(file_exists("./data/$archive_dir/$filename")) {
	$data = "<table border=\"0\" cellspacing=\"1\" cellpadding=\"4\" bgcolor=\"$border\" width=\"$width\">\n";
	$data .= "<tr align=\"center\" bgcolor=\"$maincell\">\n";
	$data .= "<td>\n";
	$data .= "<font face=\"$font\" size=\"1\"><b>Error</b>: $filename already exists, rename it and try again.</font><br>\n";
	$data .= "</td>";
	$data .= "</tr>\n";
	$data .= "</table>";
}

else {
		$extension_list = array ();

		foreach($extfile as $ext) {
			$ext = trim($ext);
			$ext = strtolower($ext);
			array_push($extension_list, $ext);
		}

		$file_extension = array_pop(explode(".", $filename));
		$file_extension = strtolower($file_extension);

		if(in_array($file_extension, $extension_list)) {
			if(!copy($userfile, "./data/$archive_dir/$filename")) {
				$data = "<table border=\"0\" cellspacing=\"1\" cellpadding=\"4\" bgcolor=\"$border\" width=\"$width\">\n";
				$data .= "<tr align=\"center\" bgcolor=\"$maincell\">\n";
				$data .= "<td>\n";
				$data .= "<font face=\"$font\" size=\"1\"><b>Error</b>: Can't copy $userfile_name to $filename.\n";
				$data .= "</font><br>\n";
				$data .= "</td>";
				$data .= "</tr>\n";
				$data .= "</table>";
				chmod("./data/$archive_dir/$filename", 0777);

			}

			else {
				if ($userfile_size >= 1073741824) {
					$userfile_size = round($userfile_size / 1073741824 * 100) / 100 . " GB";
				}
				elseif ($userfile_size >= 1048576) {
					$userfile_size = round($userfile_size / 1048576 * 100) / 100 . " MB";
				}
				elseif ($userfile_size >= 1024) {
					$userfile_size = round($userfile_size / 1024 * 100) / 100 . " KB";
				}
				else {
					$userfile_size = $userfile_size . " Bytes";
				}

				$data = "<table border=\"0\" cellspacing=\"1\" cellpadding=\"4\" bgcolor=\"$border\" width=\"$width\">\n";
				$data .= "<tr align=\"center\" bgcolor=\"$maincell\">\n";
				$data .= "<td>\n";
				$data .= "<font face=\"$font\" size=\"1\"><b>$filename</b> has been successfully uploaded.</a><br>";
				$data .= "<font face=\"$font\" size=\"1\"><b>Filesize</b>: $userfile_size</a><br>";
				$data .= "<font face=\"$font\" size=\"1\"><b>Filetype</b>: $userfile_type</a><br>";
				$data .= "</td>";
				$data .= "</tr>";
				$data .= "</table>";
			}
		}

		else {
			if ($userfile_size >= 1073741824) {
				$userfile_size = round($userfile_size / 1073741824 * 100) / 100 . " GB";
			}
			elseif ($userfile_size >= 1048576) {
				$userfile_size = round($userfile_size / 1048576 * 100) / 100 . " MB";
			}
			elseif ($userfile_size >= 1024) {
				$userfile_size = round($userfile_size / 1024 * 100) / 100 . " KB";
			}
			else {
				$userfile_size = $userfile_size . " Bytes";
			}

			$data = "<table border=\"0\" cellspacing=\"1\" cellpadding=\"4\" bgcolor=\"$border\" width=\"$width\">\n";
			$data .= "<tr align=\"center\" bgcolor=\"$maincell\">\n";
			$data .= "<td>\n";
			$data .= "<font face=\"$font\" size=\"1\"><b>Error</b>: Can't copy $userfile_name as it is not a valid image.</a><br>";
			$data .= "<font face=\"$font\" size=\"1\"><b>Filesize</b>: $userfile_size</a><br>";
			$data .= "<font face=\"$font\" size=\"1\"><b>Filetype</b>: $userfile_type</a><br>";
			$data .= "</td>";
			$data .= "</tr>";
			$data .= "</table>";
		}
	}

	$data .= "<br><center>\n";
	$data .= "<font face=\"$font\" size=\"1\">$links<br><br>\n";
	$data .= "</font>\n";
	$data .= "</center>\n";

	template("$data");
}

/*
This is a very long, very complex function. What is does is display the image index. But it needs firstly work out
the total number of files in the folder, but no . or .. It then need to work out what files to show on the page, to
do this it uses the current page number & the files to show per page. It then goes though the archive folder and
increments a counter, once the counter is in the range of files to display it prints out the data. Then it works out
if there are more than one pages and if so displays the correct footer.
*/

function view_files() {
	global $archive_dir, $PHP_SELF, $links, $curpage, $bgcolor, $text, $perpage, $width, $headercell, $maincell, $border, $style, $font;

	$data = "<table border=\"0\" cellspacing=\"1\" cellpadding=\"4\" bgcolor=\"$border\" width=\"$width\">\n";
	$data .= "<tr>\n";
	$data .= "<th bgcolor=\"$headercell\"><font face=\"$font\" size=\"2\">File Type</font></th>\n";
	$data .= "<th bgcolor=\"$headercell\"><font face=\"$font\" size=\"2\">File Name</font></a></th>\n";
	$data .= "<th bgcolor=\"$headercell\"><font face=\"$font\" size=\"2\">File Size</font></th>\n";
	$data .= "<th bgcolor=\"$headercell\"><font face=\"$font\" size=\"2\">Action</font></th>\n";
	$data .= "</tr>\n";

	$dir = opendir("./data/$archive_dir");
	$total = 0;
	while (false !== ($file = readdir($dir))) {
		if ($file != "." && $file != "..") {
			$total++;
		}

	}

	$dir = opendir("./data/$archive_dir");

	if(!readdir($dir)) {
		$data .= "<tr align=\"center\" bgcolor=\"$maincell\">\n";
		$data .= "<td colspan=\"4\"><font face=\"$font\" size=\"1\"><b>Error</b>: The image directory is missing.</font></td>\n";
		$data .= "</tr>\n";
	}

	else {
		$number = 0;

		if(!isset($curpage)) $curpage = 1;

		if($curpage == 1) {
			$firstfile = 1;
			$lastfile = $perpage;
		}

		elseif($curpage > 1) {
			$firstfile = (($curpage - 1) * $perpage) + 1;
			$lastfile = $curpage * $perpage;
		}

		while (false !== ($file = readdir($dir))) {
			if ($file != "." && $file != "..") {
				$number++;
				$filesize = filesize("./data/$archive_dir/$file");
				$extension = array_pop(explode(".", $file));
				$extension = strtoupper($extension);

				if ($filesize >= 1073741824) {
					$filesize = round($filesize / 1073741824 * 100) / 100 . " GB";
				}
				elseif ($filesize >= 1048576) {
					$filesize = round($filesize / 1048576 * 100) / 100 . " MB";
				}
				elseif ($filesize >= 1024) {
					$filesize = round($filesize / 1024 * 100) / 100 . " KB";
				}
				else {
					$filesize = $filesize . " Bytes";
				}

				$extension = strtolower($extension);
				if(file_exists("./icons/$extension.gif")) {
					$icon = "$extension";
				}
				else {
					$icon = "unknown";
				}

				if($number == $firstfile && $firstfile <= $lastfile) {
					$data .= "<tr align=\"center\" bgcolor=\"$maincell\">\n";
					$data .= "<td><img src=\"icons/$icon.gif\" alt=\"The file $file is a $extension\"></td>\n";
					$data .= "<td><font face=\"$font\" size=\"1\"><a title=\"View $file\" href=\"$PHP_SELF?action=viewimage&image=$file\">$file</a></font></td>\n";
					$data .= "<td><font face=\"$font\" size=\"1\">$filesize</font></td>\n";
					$data .= "<td><font face=\"$font\" size=\"1\"><a title=\"Rename $file\" href=\"$PHP_SELF?action=renameimage&image=$file\"><img src=\"icons/rename.gif\" border=\"0\"></a>&nbsp;<a title=\"Delete $file\" href=\"$PHP_SELF?action=deleteimage&image=$file\"><img src=\"icons/delete.gif\" border=\"0\"></a></font></td>\n";
					$data .= "</tr>\n";
					$firstfile++;
				}
		   	}
		}

		$pages = ceil($total / $perpage);

		if ($number == "0") {
			$data .= "<tr align=\"center\" bgcolor=\"$maincell\">\n";
			$data .= "<td colspan=\"4\"><font face=\"$font\" size=\"1\">The images directory is currently empty.</font></td>\n";
			$data .= "</tr>\n";
		}

		elseif ($number <= $perpage) {
			$data .= "<tr align=\"center\" bgcolor=\"$maincell\">\n";
			$data .= "<td colspan=\"4\"><font face=\"$font\" size=\"1\">There is only 1 page of images.</font></td>\n";
			$data .= "</tr>\n";
		}

		else {
			$data .= "<tr align=\"center\" bgcolor=\"$maincell\">\n";
			$data .= "<td colspan=\"4\"><font face=\"$font\" size=\"1\">\n";

			$prevpage = $curpage - 1;
			$nextpage = $curpage + 1;

			if($prevpage > 0) {
				$data .= "<a href=\"$PHP_SELF?action=view&curpage=$prevpage\" title=\"View page $prevpage\">&lt;&lt;</a>\n";
			}
			if(!(isset($counter))) $counter = 1;
			while($counter <= $pages) {

				if ($counter == $curpage) {
					$data .= "[$counter]\n";
				}
				else {
					$data .= "[<a href=\"$PHP_SELF?action=view&curpage=$counter\" title=\"View page $counter\">$counter</a>]\n";
				}
				$counter++;
			}
			if($nextpage <= $pages) {
				$data .= "<a href=\"$PHP_SELF?action=view&curpage=$nextpage\" title=\"View page $nextpage\">&gt;&gt;</a>\n";
			}
			$data .= "</font></td>\n";
			$data .= "</tr>\n";
		}
	}
	$data .= "</table>";
	$data .= "<br><center>\n";
	$data .= "<font face=\"$font\" size=\"1\">$links<br><br>\n";
	$data .= "</font>\n";
	$data .= "</center>\n";


	template("$data");
}

/*
A simple function to display the form asking for the admin pass to delete the file
*/

function delete_image() {
	global $PHP_SELF, $image, $bgcolor, $text, $width, $headercell, $maincell, $border, $style, $font, $links;

	$data = "<table border=\"0\" cellspacing=\"1\" cellpadding=\"4\" bgcolor=\"$border\" width=\"$width\">\n";
	$data .= "<form method=\"post\" action=\"$PHP_SELF\">\n";
	$data .= "<tr align=\"center\" bgcolor=\"$maincell\">\n";
	$data .= "<td><input type=\"hidden\" name=\"action\" value=\"removeimage\">\n";
	$data .= "<input type=\"hidden\" name=\"file\" value=\"$image\">\n";
	$data .= "<font face=\"$font\" size=\"1\">Enter Password</font><br>\n";
	$data .= "<input type=\"password\" name=\"password\"><br>\n";
	$data .= "<input type=\"submit\" name=\"submit\" value=\"Delete\">\n";
	$data .= "</td>";
	$data .= "</tr>\n";
	$data .= "</form>\n";
	$data .= "</table>\n";
	$data .= "<br><center>\n";
	$data .= "<font face=\"$font\" size=\"1\">$links<br><br>\n";
	$data .= "</font>\n";
	$data .= "</center>\n";

	template("$data");
}

/*
A slighty more complex function to display the form asking for the admin pass to rename the file, But it also
asks for the new file name without the extension. It strips away the old extension so the user CANNOT change it.
*/

function rename_image() {
	global $archive_dir, $PHP_SELF, $image, $bgcolor, $text, $width, $headercell, $maincell, $border, $style, $font, $links;

	$image = basename($image);
	$oldname = $image;
	$extension = array_pop(explode(".", $image));
	$image = str_replace(".$extension", "", $image);

	$data = "<table border=\"0\" cellspacing=\"1\" cellpadding=\"4\" bgcolor=\"$border\" width=\"$width\">\n";
	$data .= "<form method=\"post\" action=\"$PHP_SELF\">\n";
	$data .= "<tr align=\"center\" bgcolor=\"$maincell\">\n";
	$data .= "<td><input type=\"hidden\" name=\"action\" value=\"changename\">\n";
	$data .= "<input type=\"hidden\" name=\"file\" value=\"$image\">\n";
	$data .= "<font face=\"$font\" size=\"1\">Enter Password</font><br>\n";
	$data .= "<input type=\"password\" name=\"password\"><br>\n";
	$data .= "<font face=\"$font\" size=\"1\">New Name</font><br>\n";
	$data .= "<input type=\"text\" name=\"file\" maxlength=\"55\" value=\"$image\"><br>\n";
	$data .= "<input type=\"hidden\" name=\"oldname\" value=\"$oldname\">\n";
	$data .= "<input type=\"hidden\" name=\"extension\" value=\"$extension\">\n";
	$data .= "<input type=\"submit\" name=\"submit\" value=\"Rename\"><br>\n";
	$data .= "<font face=\"$font\" size=\"1\"><b>Note</b>: The file extension is $extension, which can not be changed.</font>\n";
	$data .= "</td>";
	$data .= "</tr>\n";
	$data .= "</form>\n";
	$data .= "</table>";
	$data .= "<br><center>\n";
	$data .= "<font face=\"$font\" size=\"1\">$links<br><br>\n";
	$data .= "</font>\n";
	$data .= "</center>\n";

	template("$data");
}

/*
The function that renames the file, it adds the extension to the new file name and makes sure the user isn't trying to
access files outside the archive folder, if they are an error is shown. It also checks for the correct adminpass BEFORE
doing any renaming.
*/

function change_image() {
	global $archive_dir, $file, $adminpass, $password, $extension, $oldname, $bgcolor, $text, $width, $headercell, $maincell, $border, $style, $font, $links;

	$file = ereg_replace("\.[\.]+", "", $file);
	$file = ereg_replace("^[\/]+", "", $file);

	$file = "$file" . "." . "$extension";

	if($password !== $adminpass) {
		$data = "<table border=\"0\" cellspacing=\"1\" cellpadding=\"4\" bgcolor=\"$border\" width=\"$width\">\n";
		$data .= "<tr align=\"center\" bgcolor=\"$maincell\">\n";
		$data .= "<td>\n";
		$data .= "<font face=\"$font\" size=\"1\"><b>Error</b>: Incorrect Password.</a><br>";
		$data .= "</td>";
		$data .= "</tr>";
		$data .= "</table>";
	}

	elseif(!rename("./data/$archive_dir/$oldname", "./data/$archive_dir/$file")) {
		$data .= "<table border=\"0\" cellspacing=\"1\" cellpadding=\"4\" bgcolor=\"$border\" width=\"$width\">\n";
		$data .= "<tr align=\"center\" bgcolor=\"$maincell\">\n";
		$data .= "<td>\n";
		$data .= "<font face=\"$font\" size=\"1\"><b>Error</b>: $oldname cannot be renamed.</a><br>";
		$data .= "</td>";
		$data .= "</tr>";
		$data .= "</table>";
	}

	else {
		$data .= "<table border=\"0\" cellspacing=\"1\" cellpadding=\"4\" bgcolor=\"$border\" width=\"$width\">\n";
		$data .= "<tr align=\"center\" bgcolor=\"$maincell\">\n";
		$data .= "<td>\n";
		$data .= "<font face=\"$font\" size=\"1\"><b>$oldname</b> was successfully renamed <b>$file</b>.</font><br>\n";
		$data .= "</td>";
		$data .= "</tr>\n";
		$data .= "</table>";
	}

	$data .= "<br><center>\n";
	$data .= "<font face=\"$font\" size=\"1\">$links<br><br>\n";
	$data .= "</font>\n";
	$data .= "</center>\n";


	template("$data");
}

/*
The function that deleted the file, it makes sure the user isn't trying to access files outside the archive folder,
if they are an error is shown. It also checks for the correct adminpass BEFORE deleting the file.
*/

function remove_image() {
	global $archive_dir, $file, $adminpass, $password, $bgcolor, $text, $width, $headercell, $maincell, $border, $style, $font, $links;

	$file = ereg_replace("\.[\.]+", "", $file);
	$file = ereg_replace("^[\/]+", "", $file);

	if($password !== $adminpass) {
		$data .= "<table border=\"0\" cellspacing=\"1\" cellpadding=\"4\" bgcolor=\"$border\" width=\"$width\">\n";
		$data .= "<tr align=\"center\" bgcolor=\"$maincell\">\n";
		$data .= "<td>\n";
		$data .= "<font face=\"$font\" size=\"1\"><b>Error</b>: Incorrect Password.</a><br>";
		$data .= "</td>";
		$data .= "</tr>";
		$data .= "</table>";
	}

	elseif(!unlink("./data/$archive_dir/$file")) {
		$data .= "<table border=\"0\" cellspacing=\"1\" cellpadding=\"4\" bgcolor=\"$border\" width=\"$width\">\n";
		$data .= "<tr align=\"center\" bgcolor=\"$maincell\">\n";
		$data .= "<td>\n";
		$data .= "<font face=\"$font\" size=\"1\"><b>Error</b>: $file cannot be deleted.</a><br>";
		$data .= "</td>";
		$data .= "</tr>";
		$data .= "</table>";
	}

	else {
		$data .= "<table border=\"0\" cellspacing=\"1\" cellpadding=\"4\" bgcolor=\"$border\" width=\"$width\">\n";
		$data .= "<tr align=\"center\" bgcolor=\"$maincell\">\n";
		$data .= "<td>\n";
		$data .= "<font face=\"$font\" size=\"1\"><b>$file</b> deleted successfully.</font><br>\n";
		$data .= "</td>";
		$data .= "</tr>\n";
		$data .= "</table>";
	}

	$data .= "<br><center>\n";
	$data .= "<font face=\"$font\" size=\"1\">$links<br><br>\n";
	$data .= "</font>\n";
	$data .= "</center>\n";

	template("$data");
}

/*
A simple function that displays the image it makes sure the user isn't trying to access files outside the archive folder,
if they are an error is shown.
*/

function view_image() {
	global $archive_dir, $image, $bgcolor, $text, $width, $headercell, $maincell, $border, $style, $font, $links;

	$image = ereg_replace("\.[\.]+", "", $image);
	$image = ereg_replace("^[\/]+", "", $image);

	if(file_exists("./data/$archive_dir/$image")) {
		$img = "<img src=\"./data/$archive_dir/$image\" alt=\"$image\">";
	}
	else {
		$img = "<font face=\"$font\" size=\"1\"><b>Error</b>: Image does not Exist.</font>";
	}

	$data .= "<table border=\"0\" cellspacing=\"1\" cellpadding=\"4\" bgcolor=\"$border\" width=\"$width\">\n";
	$data .= "<tr align=\"center\" bgcolor=\"$maincell\">\n";
	$data .= "<td>$img</td>\n";
	$data .= "</tr>\n";
	$data .= "</table>";
	$data .= "<br><center>\n";
	$data .= "<font face=\"$font\" size=\"1\">$links<br><br>\n";
	$data .= "</font>\n";
	$data .= "</center>\n";

	template("$data");
}


/*
The function used to set up the template
*/

function template($content) {
	global $message, $width, $maincell, $border, $font;

	$filename = "./data/template.dat";
	if(!$fd = fopen($filename, "r")) {
		$error = 1;
	}
	else {
		$template = fread ($fd, filesize ($filename));
		fclose ($fd);
		$template = stripslashes($template);
		$template = eregi_replace("<% message %>", "$message", $template);
		$template = eregi_replace("<% content %>", "$content", $template);
		echo "$template";
	}
	if($error == 1) {
		echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"4\" bgcolor=\"$border\" width=\"$width\">\n";
		echo "<tr align=\"center\" bgcolor=\"$maincell\">\n";
		echo "<td>\n";
		echo "<font face=\"$font\" size=\"1\">There was an error loading a configuration file, please contact the site admin.</font><br>\n";
		echo "</td>";
		echo "</tr>\n";
		echo "</table>";
	}
}

switch($action) {
	case "upload":
		$links = "<a href=\"$PHP_SELF\">Upload an image</a>";
		upload_file();
	break;
	case "view":
		$links = "<a href=\"$PHP_SELF\">Upload an image</a>";
		view_files();
	break;
	case "viewimage":
		$links = "<a href=\"$PHP_SELF?action=view\">View the image index</a> | <a href=\"$PHP_SELF\">Upload an image</a>";
		view_image();
	break;
	case "removeimage":
		$links = "<a href=\"$PHP_SELF?action=view\">View the image index</a> | <a href=\"$PHP_SELF\">Upload an image</a>";
		remove_image();
	break;
	case "deleteimage":
		$links = "<a href=\"$PHP_SELF?action=view\">View the image index</a> | <a href=\"$PHP_SELF\">Upload an image</a>";
		delete_image();
	break;
	case "renameimage":
		$links = "<a href=\"$PHP_SELF?action=view\">View the image index</a> | <a href=\"$PHP_SELF\">Upload an image</a>";
		rename_image();
	break;
	case "changename":
		$links = "<a href=\"$PHP_SELF?action=view\">View the image index</a> | <a href=\"$PHP_SELF\">Upload an image</a>";
		change_image();
	break;
	case "install";
		chmod("./install.php", 0755);
		if(unlink("./install.php")) {
			$links = "<a href=\"$PHP_SELF?action=view\">View the image index</a>";
			upload_form();
		}
		else {
			$links = "<a href=\"$PHP_SELF?action=view\">View the image index</a>";
			$message = "<font face=\"$font\" size=\"2\"><b>Warning</b>: Your install script could not be deleted, please delete it before you continue.</font>\n";
			upload_form();
		}
	break;
	default:
		$links = "<a href=\"$PHP_SELF?action=view\">View the image index</a>";
		upload_form();
	break;
}


echo "			</td>\n";
echo "              </tr>\n";
echo "		    </table>\n";
echo "          </TD>\n";
echo "        </TR>\n";


readfile ('http://skateclass.ru/footer.shtml');


?>