offline
- kostolac

- Građanin
- Pridružio: 21 Dec 2005
- Poruke: 228
- Gde živiš: Kostolac
|
Dali mi neko moze reci u cemu je problem sa ovom skriptom ?
Postavio sam je na server i kada hocu da uploaduje neki fajl ne dozvoljava mi a tom folderu gde zelim da upload-uje sam dodao permision 666. Kada hocu samo link da dodam radi ali kada pokusam neki fajl nece. Ako neko zna u cemu je greska neka posalje.
Hvala
<?php
## da promjenite text u emailu koji vas obavjestava o uploadu, pogledajte kraj ovog fajla
$the_path = "home/stop/public_html/folder/"; # upload dir -> chmod 666
$my_max_file_size = "5048000"; # max. velicina fajla u bajtima (5048000 = 5 MB)
$contacthost = "info@mail.rs"; # vasa email adresa
#################################################################################################
$registered_types = array(
"application/x-gzip-compressed" => ".tar.gz, .tgz",
"application/x-zip-compressed" => ".zip",
"application/x-tar" => ".tar",
"application/x-rar-compressed" => ".rar",
"application/x-ace-compressed" => ".ace",
"application/x-arj-compressed" => ".arj",
"text/plain" => ".html, .php, .txt, .inc , .php3, .phtml",
"image/bmp" => ".bmp, .ico",
"image/gif" => ".gif",
"image/pjpeg" => ".jpg, .jpeg",
"image/jpeg" => ".jpg, .jpeg",
"application/x-shockwave-flash" => ".swf",
"application/msword" => ".doc",
"application/vnd.ms-excel" => ".xls",
"application/octet-stream" => ".exe"
); # vise primjera imate na: http://www.spinnaker.de/mutt/mime.types
## modificirajte ovu varijablu ($allowed_types) da odredite koje
## ekstenzije fajlova se smiju uplodovati na server. pripazite dobro !
## trenutno dozvoljeni su: .bmp, .gif, .pjpeg, .jpeg, .zip, .gzip, .arj, .tar, .ace
$allowed_types = array("image/bmp","image/gif","image/pjpeg","image/jpeg","application/x-zip-compressed","application/x-gzip-compressed","application/x-arj-compressed","application/x-tar","application/x-rar-compressed","application/x-ace-compressed");
$ip = getenv('REMOTE_HOST');
if(!$ip)
{
$ip = getenv('REMOTE_ADDR');
}
if(!$ip)
{
$ip = $REMOTE_ADDR;
}
if(!$ip)
{
$ip = $REMOTE_HOST;
}
$mxsize = $my_max_file_size / 5024000;
$backbutton1 = "<form><table width=300 border=1 bordercolor=#333333 cellspacing=0 cellpadding=3 align=center><tr><td><table align=center border=0 cellspacing=0 cellpadding=1 width=300><tr><td align=left valign=top width=15%><font color=#666666 size=2 face=Tahoma>Status:</font></td><td align=left valign=top><font color=#999999 size=2 face=Tahoma>";
$backbutton2 = "<br><br></td></tr><tr><td align=center valign=bottom colspan=2><input type=button value=\" Idite nazad! \" onClick=\"history.back()\"></td></tr></table></td></tr></table><br></form>";
php?>
<html>
<title>upload</title>
<head>
<SCRIPT LANGUAGE="JavaScript">
function checkFooterLenght(field,maxlength) {
var anz = field.value.length;
if (anz > maxlength )
{
field.value = field.value.substring(0,maxlength-1);
frei = 0;
}
else
{
frei = maxlength-anz;
}
document.forms["qmform"].footerlenght.value = frei;
}
</SCRIPT>
<script language="JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>
<p align="center"><font face="Verdana" size="2" color="#999999"><b>UPLOAD</b></font><font face="Verdana" size="2"><br><br>
</font><font size="2" face="Verdana" color="#666666">upload fajlova (max.velicina = <?php echo $mxsize; php?> MB).<br>Ako ne zelite da uplodujete fajl, nego samo da nam link date,<br>upisite Vas link u za to predvidjeno polje. Hvala</font></p>
<body bgcolor=#DCE9E8>
<font face="Verdana" size="2">
<?php
if ($SubmitAdd)
{
global $the_path,$the_file_name,$the_file_type,$the_file_type,$allowed_types,$registered_types,$message,$uploader,$added,$the_file,$link,$ip,$my_max_file_size,$mxsize;
if (!$uploader)
{
print $backbutton1;
echo "Zaboravili ste upisati Vas nick!";
print $backbutton2;
}
elseif (!$email)
{
print $backbutton1;
echo "Zaboravili ste upisati Vasu email adresu";
print $backbutton2;
}
elseif (!$message)
{
print $backbutton1;
echo "Zaboravili ste upisati Vas poruku!";
print $backbutton2;
}
else
{
if ($the_file_name)
{
if (!in_array($the_file_type,$allowed_types))
{
print $backbutton1;
echo"Nije dozvoljen uplodovati tu ekstenziju fajlova. Dozvoljene ekstenzije::<br>";
while ($type = current($allowed_types))
{
$error = "\n<img src=../index/strelica.gif width=5 height=10> " . $registered_types[$type] . " (" . $type . ")";
print $error . "<br>";
next($allowed_types);
print ("\n");
}
print $backbutton2;
}
elseif ($the_file_size > $my_max_file_size)
{
$sizeexceed = ($the_file_size - $my_max_file_size) / 1024;
$sizeexceed = ceil($sizeexceed);
print $backbutton1;
echo "Velicina Vaseg fajla je presla $mxsize MB za $sizeexceed KB.<br>Pokusajte da smanjite velicinu fajla koristeci WinZip/RAR/Ace ... i pokusajte ponovo.<br>Hvala.";
print $backbutton2;
}
else
{
if (!@copy($the_file, $the_path . "/" . $the_file_name))
{
print $backbutton1;
echo "Nastupila je nepoznata greska.<br>Vas fajl vjerovatno nije validan. Pokusajte ponovo. Hvala";
print $backbutton2;
}
else
{
saveupload($message,$uploader,$added,$the_file_name);
}
}
}
elseif ($link)
{
$the_file_name=&$link;
saveupload($message,$uploader,$added,$the_file_name);
}
else
{
print $backbutton1;
echo "Zaboravili ste da upisete path ili link do fajla";
print $backbutton2;
}
}
}
else
{
$servertime = time();
$second = date("s", ($servertime));
$minute = date("i", ($servertime));
$hour = date("G", ($servertime));
$day = date("j", ($servertime));
$month = date("n", ($servertime));
$year = date("y", ($servertime))+2000;
$time = "$year-$month-$day $hour:$minute:$second";
php?>
</font>
<table width=300 border="1" bordercolor="#333333" cellspacing="0" cellpadding="3" align=center><tr><td>
<table align=center border="0" cellspacing="0" cellpadding="1" width=300>
<form ENCTYPE=multipart/form-data action="<?php echo $PHP_SELF; ?>" name=qmform method=post>
<tr>
<td width=87 valign=center align=left>
<font color=#666666 size=2 face=Verdana>Nick:</font></td>
<td><font face="Verdana"><input type=text name=uploader size=25 maxlength=25></font></td>
</tr><tr>
<td width=87 valign=center align=left>
<font color=#666666 size=2 face=Verdana>Email:</font></td>
<td><font face="Verdana"><input type=text name=email size=25></font></td>
</tr><tr>
<td width=87 valign=center align=left>
<font color=#666666 size=2 face=Verdana>Link:</font></td>
<td><font face="Verdana"><input type=text name=link size=25></font></td>
</tr><tr>
<td width=87 valign=center align=left>
<font color=#666666 size=2 face=Verdana>Upload:</font></td>
<td><font face="Verdana"><input name=the_file type=file size=14></font></td>
</tr><tr>
<td colspan=2 valign=bottom align=left>
<font face="Verdana">
<textarea name=message wrap=vitual onFocus="checkFooterLenght(this,600)" onBlur="checkFooterLenght(this,600)" onKeyDown="checkFooterLenght(this,600)" onKeyUp="checkFooterLenght(this,600)" cols=34 rows=9></textarea></font></td>
</tr><tr height=10>
<td>
<font face="Verdana">
<input type=hidden name=added value="<?php echo $time; php?>">
</font>
<font color=#666666 size=2 face=Verdana>Counter:</font><font color=#000000 size=2 face="Verdana">..</font><font face="Verdana"><input class=messageHiMInput type=TEXT size=3 maxlength=3 name=footerlenght value=600 align=bottom></font></td>
<td align=right>
<font face="Verdana">
<input type=hidden name=host value="<?php echo $ip; php?>">
<INPUT type=hidden name=MAX_FILE_SIZE value="<?php echo $my_max_file_size; php?>">
</font><font face="Verdana"><font size="2">";
</font>
<input type=submit name=SubmitAdd value=" Upload ! "><font size="2">
</font></font>
</td></tr></form></table></td></tr></table>
<?php
}
function saveupload($message,$uploader,$added,$the_file_name)
{
global $contacthost,$email,$host, $backbutton1, $backbutton2;
$message = nl2br ($message);
$message = ereg_replace ("<br />", "\n", $message);
$message = "IME FAJLA: $the_file_name\n" .
"UPLOADER: $uploader <$email>\n" .
"IP ADRESA: $host\n" .
"VRIJEME UPLOADA: $added\n" .
"OPIS: $message";
$headers = "From: $contacthost\n" .
"Reply-To: $email\n"."X-Mailer: PHP\n" .
"Return-Path: <$contacthost>\n";
$messageG = "Hvala za upload.";
$headersG = "From: $contacthost\n" .
"Reply-To: $contacthost\n"."X-Mailer: PHP\n" .
"Return-Path: <$contacthost>\n";
@mail($contacthost, "Upload fajla na Vasoj stranici", $message, $headers);
@mail($email, "Hvala za Upload", $messageG, $headersG);
print $backbutton1;
echo "Upload je bio uspesan. Hvala puno.";
print $backbutton2;
}
php?>
|