⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 100.php

📁 使用PHP+MySQL编写的一个图片上传共享系统.
💻 PHP
字号:
<?
	if ( $_COOKIE[auth] == "") 
	{
  	 	header( "Location: http://82.39.116.47/reg/err_login.html");
   		exit;
	}



$basedir = "/Program Files/Apache Group/Apache2/htdocs/Reg/$_COOKIE[auth]";
$fileeditdir = "/reg/";
$textrows = "20";
$textcols = "85";
if(!$wdir) $wdir="/";

function html_header(){
	global $basedir;
	global $wdir;
	global $lastaction;
	echo "<HEAD>";
	echo "<TITLE>Photo Upload Service</TITLE>";
	echo "</HEAD>";
	echo "<BODY bgcolor=\"#ccccff\" link=\"#4C4C99\" vlink=\"#4C4C99\" alink=\"#4C4C99\">";
	echo "<table border=\"0\" align=\"center\" cellspacing=\"3\" cellpadding=\"3\" width=\"600\">";
	echo "<tr>";
	echo "<th colspan=\"2\" width=\"100%\" bgcolor=\"#00bfff\">";
	echo "&nbsp;<font size=\"6\" color=\"white\" face=\"arial, helvetica\">File Edit System</font> &nbsp";
	echo "&nbsp;<font size=\"3\" color=\"white\" face=\"arial, helvetica\">---$_COOKIE[auth]</font>";
	echo "</th>";
	echo "</tr>";

	echo "<tr>";
	echo "<td colspan=\"2\"><hr><td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td colspan=\"2\">";
}

function display_size($file){
$file_size = filesize($file);
if($file_size >= 1073741824)
 	{
        $file_size = round($file_size / 1073741824 * 100) / 100 . "g";
	}
elseif($file_size >= 1048576)
	{
        $file_size = round($file_size / 1048576 * 100) / 100 . "m";
	}
elseif($file_size >= 1024)
	{
        $file_size = round($file_size / 1024 * 100) / 100 . "k";
	}
else{
        $file_size = $file_size . "b";
	}
return $file_size;
}

function displaydir()
	{
	global $basedir;
	global $wdir;	

	echo "<TABLE BORDER=\"0\" cellspacing=\"1\" cellpadding=\"1\" width=\"100%\">";
	echo "<tr>";
	echo "<th bgcolor=\"#b0c4de\"><font color=\"white\" face=\"arial, helvetica\">Type</font></th>";
	echo "<th bgcolor=\"#b0c4de\"><font color=\"white\" face=\"arial, helvetica\">Name</font></th>";
	echo "<th bgcolor=\"#b0c4de\"><font color=\"white\" face=\"arial, helvetica\">Size</font></th>";
	echo "<th bgcolor=\"#b0c4de\"><font color=\"white\" face=\"arial, helvetica\">Create Time</font></th>";
	echo "<th bgcolor=\"#b0c4de\"><font color=\"white\" face=\"arial, helvetica\">Operation</font></th>";
	echo "</tr>";

	chdir($basedir . $wdir);
	$handle=opendir(".");

	while ($file = readdir($handle))
		{
		if(is_dir($file)) $dirlist[] = $file;
		if(is_file($file)) $filelist[] = $file;
		}
	closedir($handle);
		
	if($dirlist)
	{

		asort($dirlist);

		while (list ($key, $file) = each ($dirlist))
		{
			//
			if (!($file == "."))
			{
				$filename=$basedir.$wdir.$file;
				$fileurl=rawurlencode($wdir.$file);
				$lastchanged = filectime($filename);
				$changeddate = date("d-m-Y H:i:s", $lastchanged);
				echo "<TR>";
			}
		}
	}

	if($filelist)
	{

		asort($filelist);
		while (list ($key, $file) = each ($filelist))
		{

			if (ereg(".gif|.jpg|.JPG|.bmp|.BMP",$file))
			{
				$icon = "<IMG SRC=\"image.gif\" alt=\"Image\" border=\"0\">";
				$browse = "1";
				$raw = "0";
				$image = "1";
			}


			$filename=$basedir.$wdir.$file;
			$fileurl=rawurlencode($wdir.$file);
			$lastchanged = filectime($filename);
			$changeddate = date("d-m-Y H:i:s", $lastchanged);
			echo "<TR>";
			echo "<TD align=\"center\" nobreak>";

			echo "<A HREF=\"$PHP_SELF?action=show&wdir=$wdir&$file=$fileurl&image=$image\">";
			echo "$icon</TD>\n";
			echo "<TD nobreak><font size =\"-1\" face=\"arial, helvetica\">" . htmlspecialchars($file) . "</font></TD>\n";
			echo "<TD align=\"right\" nobreak><font size =\"-1\" face=\"arial, helvetica\">" . display_size($filename) . "</font></TD>";

			echo "<TD align=\"right\" nobreak><font size =\"-1\" face=\"arial, helvetica\">" . $changeddate . "</font></TD><TD align=\"right\">";

			echo " <A HREF=\"$PHP_SELF?action=move&wdir=$wdir&file=$fileurl\"><img src=\"move.gif\" alt=\"Move,rename or copy $file\" border=\"0\"></A> ";
			
			echo "<A HREF=\"$PHP_SELF?action=del&wdir=$wdir&file=$fileurl\"><img src=\"delete.gif\" alt=\"Delete $file\" border=\"0\"></A> ";


			if($browse == "1")
			{
				echo " <A HREF=\"$fileeditdir$_COOKIE[auth]/$file\"><img src=\"browse.gif\" alt=\"Browse\" border=\"0\"></A> ";
			}
		}
	}
	echo "</TD></TR>\n";
	echo "</TABLE>";


	echo "<table border=\"0\" width=\"100%\">";
	echo "<TR><TD colspan=\"2\"><hr></td>";

	echo "<TR><TD><font size =\"-1\" face=\"arial, helvetica\">File Upload</font></td><td>";
	echo "<FORM ENCTYPE=\"multipart/form-data\" METHOD=\"POST\" ACTION=\"upload.php\">";
	echo "<INPUT TYPE=\"HIDDEN\" NAME=\"action\" VALUE=\"upload\">";
	echo "<INPUT NAME=\"filename\" TYPE=\"file\" size=\"40\">";
	echo "<INPUT TYPE=\"SUBMIT\" NAME=\"upload\" VALUE=\"Go!\"></TD></TR>";

	echo "<TR><TD><a href=\"index.php\"><font size =\"-1\" face=\"arial, helvetica\">Back</font></a></td><td>";

}

################################################################################

switch ($action)
{

	case "":
		$lastaction = "$basedir";
		html_header();
		displaydir();
		echo $html_ender;
		break;


	case "del":

		if ($confirm)
		{
			$delfile = $basedir.$file;
			unlink ($delfile);
			html_header();
			displaydir();
		}

		else
		{

			html_header();
			echo "<b><font size = \"6\" face = \"arial\", helvetica\">Are you sure to delete file<br>$file</font></b>";
			echo "<br><br>";
			echo "<center><b><font size =\"5\" face=\"arial, helvetica\"><A HREF=\"$PHP_SELF?action=del&wdir=$wdir&file=$file&confirm=1\">YES!</A></font><br>";
			echo "<p><font size =\"5\" face=\"arial, helvetica\"><A HREF=\"$PHP_SELF?wdir=$wdir\">NO!</A></font><br><b></center>";
		}
		echo $html_ender;
		break;


	case "move":

		if($confirm && $newfile)
 		{

    			if(file_exists($basedir.$newfile))
			{
				$lastaction = "Destination file already exists. Aborted.";
			}
			else
			{
				if($do == copy)
				{
					copy($basedir.$file,$basedir.$newfile);
					$lastaction = "Copied\n$file to $newfile";
				}
				else
				{
					rename($basedir.$file,$basedir.$newfile);
					$lastaction = "Moved/renamed\n$file to $newfile";
				}
			}
			html_header();
			displaydir();
    			echo $html_ender;
			}

		else
			{
			$lastaction = "Moving/renaming or copying<br>$file";
			html_header();
			echo "<FORM METHOD=\"POST\" ACTION=\"$PHP_SELF\">\n";
			echo "<font size =\"5\" face=\"arial, helvetica\">$_COOKIE[auth] do you want to </font>";
			echo "<input type=\"radio\" name=\"do\" value=\"rename\" Checked>Rename";
			echo "<font size =\"5\" face=\"arial, helvetica\"> or </font>";
			echo "<input type=\"radio\" name=\"do\" value=\"copy\">Copy";
			echo " ($file) file";
			echo "<h4>To</h4>";
			echo "<INPUT TYPE=\"TEXT\" NAME=\"newfile\" value=\"$file\" size=\"40\">\n";
			echo "<INPUT TYPE=\"HIDDEN\" NAME=\"wdir\" VALUE=\"$wdir\">\n";			
			echo "<INPUT TYPE=\"HIDDEN\" NAME=\"action\" VALUE=\"move\">\n";
			echo "<INPUT TYPE=\"HIDDEN\" NAME=\"file\" VALUE=\"$file\">\n";
			echo "<p>";
			echo "<INPUT TYPE=\"SUBMIT\" NAME=\"confirm\" VALUE=\"Do\">\n";
			echo "<INPUT TYPE=\"SUBMIT\" NAME=\"cancel\" VALUE=\"Cancel\">\n";
			echo "</FORM>";
			echo $html_ender;
			}
		break;


	case "show":


		if($image == "1")
		{
			echo "<center><img src=\"$file\"></center>";
		}
		echo $html_ender;
		break;


}
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -