...

View Full Version : pleas look at this, PLEAS !



spamyboy
06-15-2006, 11:49 PM
<?php


include("./config.php");
include("./header.php");

$filename = $_FILES['upfile']['name'];
$filesize = $_FILES['upfile']['size'];
$filecrc = md5_file($_FILES['upfile']['tmp_name']);

$bans=file("./bans.txt");
foreach($bans as $line)
{
if ($line==$filecrc."\n"){
echo "That file is not allowed to be uploaded.";

die();
}
if ($line==$_SERVER['REMOTE_ADDR']."\n"){
echo "You are not allowed to upload files.";

die();
}
}

$checkfiles=file("./files.txt");
foreach($checkfiles as $line)
{
$thisline = explode('|', $line);
if ($thisline[0]==$filecrc){
echo "Pleas rename file and try again.";

die();
}
}

if(isset($allowedtypes)){
$allowed = 0;
foreach($allowedtypes as $ext) {
if(substr($filename, (0 - (strlen($ext)+1) )) == ".".$ext)
$allowed = 1;
}
if($allowed==0) {
echo "That file type is not allowed to be uploaded.";

die();
}
}

if(isset($categorylist)){
$validcat = 0;
foreach($categories as $cat) {
if($_POST['category']==$cat || $_POST['category'] = ""){ $validcat = 1; }
}
if($validcat==0) {
echo "Invalid category was chosen..";

die();
}
$cat = $_POST['category'];
} else { $cat = ""; }

if($filesize==0) {
echo "You didn't pick a file to upload.";
include("./footer.php");
die();
}

$filesize = $filesize / 1048576;

if($filesize > $maxfilesize) {
echo "The file you uploaded is too large.";
include("./footer.php");
die();
}

$userip = $_SERVER['REMOTE_ADDR'];
$time = time();

if($filesize > $nolimitsize) {

$uploaders = fopen("./uploaders.txt","r+");
flock($uploaders,2);
while (!feof($uploaders)) {
$user[] = chop(fgets($uploaders,65536));
}
fseek($uploaders,0,SEEK_SET);
ftruncate($uploaders,0);
foreach ($user as $line) {
@list($savedip,$savedtime) = explode("|",$line);
if ($time < $savedtime + ($uploadtimelimit*60)) {
fputs($uploaders,"$savedip|$savedtime\n");
}
}
fputs($uploaders,"$userip|$time\n");

}

$passkey = rand(100000, 999999);

if($emailoption && isset($_POST['myemail']) && $_POST['myemail']!="") {
$uploadmsg = "Your file (".$filename.") was uploaded.\n Your download link is: ". $scripturl . "download.php?file=" . $filecrc . "\n Thank you for using our service!";
mail($_POST['myemail'],"Your Uploaded File",$uploadmsg,"From: admin@yoursite.com\n");
}

if($passwordoption && isset($_POST['pprotect'])) {
$passwerd = md5($_POST['pprotect']);
} else { $passwerd = md5("");}

if($descriptionoption && isset($_POST['descr'])) {
$description = strip_tags($_POST['descr']);
} else { $description = ""; }

$filelist = fopen("./files.txt","a+");
fwrite($filelist, $filecrc ."|". basename($_FILES['upfile']['name']) ."|". $passkey ."|". $userip ."|". $time."|0|".$description."|".$passwerd."|".$cat."|\n");

$movefile = "./storage/" . $filecrc;
move_uploaded_file($_FILES['upfile']['tmp_name'], $movefile);

echo "Your file was uploaded!<br />";
echo "Your download link is: <input style=\"width:240;\" type=\"text\" value=\"" . $scripturl . "download.php?file=" . $filecrc . "\">";
include("./footer.php");
?>

& this is error, that i get


Fatal error: [] operator not supported for strings in C:\appache\www\upload\upload.php on line 86

Kid Charming
06-16-2006, 12:02 AM
Please read the posting guidelines and use more descriptive thread titles.

Which is line 86?

spamyboy
06-16-2006, 12:05 AM
here:

$user[] = chop(fgets($uploaders,65536));

Kid Charming
06-16-2006, 12:09 AM
Somewhere before that line, $user is being set as a string variable. You should probably just use a different name for that array.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum