Jump to content

another upload script problem...


richardjh

Recommended Posts

...I cannot suss :(

 

This script worked fine before i moved my site to a new host. it is a phpnuke module from version 6.0 so it's old but when it worked it was great to use. i wonder if i could ask for some expert help on getting this script working again please?

 

The first page of this script is this:

 

global $lang, $newlang;
$modname = "Members_Sound_Upload";
if (isset($newlang)) {
    $language = $newlang;
} elseif (isset($lang)) {
    $language = $lang;
}

if(file_exists("modules/$modname/language/$language.php")) {
include("modules/$modname/language/$language.php");
} else {
include("modules/$modname/language/lang-english.php");
}

$index = 0;
if(!IsSet($mainfile)) { include ("mainfile.php"); }
//if (!$user) { include("modules.php?name=Your_Account&op=new_user"); }
if (!eregi("modules.php", $PHP_SELF)) { die ("You can't access this file directly..."); }
include("header.php");
echo "<br><br>";
OpenTable();
cookiedecode($user);
$check = $cookie[1];
$result = mysql_query("SELECT uname, email FROM $prefix"._users." WHERE uname='$check'");
list($uname, $email) = mysql_fetch_row($result);
echo "<form action=\"modules.php\" method=\"post\" ENCTYPE=\"multipart/form-data\">\n";
echo "<INPUT TYPE=\"hidden\" name=\"op\" value=\"modload\">\n";
echo "<INPUT TYPE=\"hidden\" name=\"name\" value=\"$modname\">\n";
echo "<INPUT TYPE=\"hidden\" name=\"file\" value=\"upload\">\n";
echo "<INPUT TYPE=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"6291456\">\n";
echo "<INPUT TYPE=\"hidden\" name=\"sid\" value=\"$sid\">\n";
echo "<INPUT TYPE=\"hidden\" name=\"email\" value=\"$email\">\n";
echo "<center><table border=\"0\" cellpadding=\"2\">\n";
echo "<tr><td align=\"center\"><font class=\"title\"><b>"._MEMUP."</b></font></td></tr>\n";
echo "<tr><td>"._MEMFILE.": <input type=\"file\" size=\"40\" name=\"uploadfile1\"></td></tr>\n";
echo "<tr><td>\n";
echo "File type: <select name=\"type\">\n";
echo "<option value=\"mp3\">format</option>\n";
echo "<option value=\"wav\">wav</option>\n";
echo "<option value=\"wma\">wma</option>\n";
echo "<option value=\"wmv\">wmv</option>\n";
echo "<option value=\"mp3\">mp3</option>\n";
echo "</select>\n";
echo "</td></tr>\n";
echo "<tr><td><input type=\"submit\" value=\"Upload\">  <input type=\"reset\" value=\"Clear\"></td></tr>\n";
echo "</table></center>\n";
echo "</form>\n";
echo "<center><table><td> Hello $uname,<p>"._INFO.".\n"; 
echo "<br>Files must be "._MEMSIZE." or less in size.\n";
#echo "<br>To change your photo(s) simply upload a new one.\n";
#echo "<p>Names: (<b>$cookie[1].jpg</b>) and (<b>$cookie[1].gif</b>)<br>Location: "._MEMLOC."</td></table></center>";

#echo "<p><b>This file</b> will be uploaded to "._MEMLOC." <br><b>This file</b> will be renamed [ $sid ]</b><br></td></table></center>";
echo "<p><b><br></td></table></center>";
CloseTable();
include("footer.php");

echo "<form action=\"modules.php\" method=\"post\" ENCTYPE=\"multipart/form-data\">\n";
echo "<INPUT TYPE=\"hidden\" name=\"name\" value=\"$modname\">\n";
echo "<INPUT TYPE=\"hidden\" name=\"file\" value=\"thanks\">\n";
echo "<INPUT TYPE=\"hidden\" name=\"sid\" value=\"$sid\">\n";
echo "</form>\n";

 

and that form is posted here:

 

global $lang, $newlang, $adminmail;
$modname = "Members_Sound_Upload";
if(!IsSet($mainfile)) { include ("mainfile.php"); }
if (!$user) { include("user.php"); }
if (!eregi("modules.php", $PHP_SELF)) { die ("You can't access this file directly..."); }

if (isset($newlang)) {
    $language = $newlang;
} elseif (isset($lang)) {
    $language = $lang;
}

if(file_exists("modules/$modname/language/$language.php")) {
include("modules/$modname/language/$language.php");
} else {
include("modules/$modname/language/lang-english.php");
}

$index = 0;
// Set server Directory (NO TRAILING SLASH) 
// $server_dir = "/home/uka/public_html/sound"; 
$server_dir = "/var/www/html/sound"; 
// Your email 
$youremail=$adminmail; 
// Thank you page: 
$thankspage="modules.php?op=modload&name=$modname&file=thanks"; 
// Email message on or off ? 1 = on, 0 = off 
$emailmessages = "0"; 

global $uploadfile1; 
global $uploadfile1_name; 
global $upload_dir, $thetime, $user, $sid, $designname; 

//If they don't specify a file to upload, die.
if (! $uploadfile1_name) { 
echo "No file specified or file outside guidelines.\n 
<a href=javascript:history.back(-1)>Return to the form</a>
";
exit;
} 


cookiedecode($user);
$check = $cookie[1];
$result = mysql_query("SELECT uname, email FROM $prefix"._users." WHERE uname='$check'");
list($uname, $email) = mysql_fetch_row($result);

$user = $uname;
if ($user == ""){ // If no name, then return error. 

echo _MEMNAME; 
exit; 
} else { 

// Check for valid email address 

$x = eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,3}$",$email); 

if($x==0) 

//if no valid email address entered, display no email message 
{ 
echo _MEMEMAIL; 
exit; 
} 
else { 

// This sets the time and creates a directory to upload to 
$startdate = time(); 
$thetime = date("m-d-Y_H-i-s", $startdate);

// Wherever you have write permission below... 
$upload_dir = "$server_dir"; 

// Gets the temp_name in to a string variable 
$uploadtemp1 = $uploadfile1; 

// Gets those names into an array to be called later 
$original = array( 
"$uploadtemp1" 
); 

// Same as above except gets the real file name 
$uploadreal1 = $uploadfile1_name; 

$file = array( 
"$uploadreal1" 
); 

// Copy handler for the above arrays
for($I = 0; $I <=6; $I++){ 
$file[$I] = ereg_replace(" ", "_", $file[$I]); 
$file[$I] = ereg_replace("%20", "_", $file[$I]); 
$copyfile = "$upload_dir/$file[$I]"; 
@move_uploaded_file($original[$I], $copyfile); 
@unlink($original[$I]); 


// This will rename the uploaded file to the submission number, no matter what file name they use.
// You can change $user.jpg to $user.gif or whatever you want.
rename ("$upload_dir/$file[$I]", "$upload_dir/$sid.$type");
chmod("$upload_dir/$sid.$type", 0644);

//return thank you page 
Header("Location: $thankspage"); 

} 
} 

// Set Upload email thanks message for USER 
$uptymessage="$user, thank you for uploading your photo.\n\nYour image will automatically be added to your articles."; 
// Set Upload email thanks message for OWNER 
$ownermessage="Username: $user\nEmail: $email\nDirectory: $upload_dir\nPhoto: $uploadreal1\n"; 

// Send Email 
if ($emailmessages == "1") { 
//mail you to let you know a new uploaded file 
mail("$youremail", "Uploaded photo", "$ownermessage", "From: $email\nX-Mailer: PHP/" . phpversion()); 
//mail user to thank them 
mail("$email", "Uploaded photo", "$uptymessage", "From: $youremail\nX-Mailer: PHP/" . phpversion()); 
} 

} 

 

I thought it might be something to do with POST so I added lines like this to the top:

 

$sid = isset($_POST['sid']) ? $_POST['sid'] : "" ;

I did this will all the form variables but alas no good. when the script is run, it fails to get past this:

if (! $uploadfile1_name) { 
echo "No file specified or file outside guidelines.\n 
<a href=javascript:history.back(-1)>Return to the form</a>
";
exit;
}

and thus just tells me "No file specified or file outside guidelines.".

 

any ideas please?

 

thanks

R

Link to comment
https://forums.phpfreaks.com/topic/134793-another-upload-script-problem/
Share on other sites

anyone offer any help on the above? I'm really stuck.

 

 

I've noticed that the script says that an upload was successful (but it is not) and even if I change the $server_dir to an none existant one it still says 'success'. Shouldn't the script error out if it can't find the correct directory?

 

Really appreciate some help with this. It's really frustrating me.

 

thanks

R

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.