Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 1st, 2014, 11:19 AM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default old php script needs register_globals=on

hello,
I have a small up/downloader script that works fine on older versions of php, the servers were upgraded and now it does not work................any help would be appreciated

<body link="#FFFF00" vlink="#FF0000" alink="#FFFF00"><?
$extlimit = "yes"; //Do you want to limit the extensions of files uploaded
$limitedext = array(".zip",".sim",".car",".jpg",".gif"); //Extensions you want files uploaded limited to.
$sizelimit = "no"; //Do you want a size limit, yes or no?
$sizebytes = "30033000"; //size limit in bytes
$dl = "http:"; //url where files are uploaded
$absolute_path = ""; //Absolute path to where files are uploaded
$websiteurl = ""; //Url to you website
$websitename = "Car File Manger";

if (!isset($action)) {
$action = "";
}

switch($action) {
default:
echo"
<html>
<head>
<title>Upload Or Download</title>
</head>
<body>
<a href=$PHP_SELF?action=upload>Upload </a> |
<a href=$PHP_SELF?action=download>Download </a> |
<a href=$websiteurl>Return to $websitename</a>
<br><br>

</body>
</html>";
break;
case "download":
echo "
<html>
<head>
<title>File Download</title>
</head>
<body><a href=$PHP_SELF?action=upload>Upload File</a> | <a href=$websiteurl>Return to $websitename</a>";
$list = "<table width=500 border=0 bordercolor=#000000 style=\"border-collapse: collapse\">";
$list .= "<tr><td width=500><center><b>Click To Download</b></center></td></tr>";
$dir = opendir($absolute_path);
while($file = readdir($dir)) {
if (($file != "..") and ($file != ".")) {
//Download files with spaces fix by Kokesh
$list .= "<tr><td width=700><a href='$dl/$file'>$file</a></center></td></tr>";
}
}
$list .= "</table>";
echo $list;
echo"
<br><br>

</body>
</html>";
break;

case "upload":
echo"
<html>

<head>
<title>File Upload</title>
</head>

<body>

<form method=POST action=$PHP_SELF?action=doupload enctype=multipart/form-data>
<p>File to upload:<br>
<input type=file name=file size=30>
<p><button name=submit type=submit>
Upload
</button>
</form>
<br><br>

</body>

</html>";
break;


//File Upload
case "doupload":
$dir = "dir";
if ($file != "") {

if (file_exists("$absolute_path/$file_name")) {
die("File already exists");
}

if (($sizelimit == "yes") && ($file_size > $sizebytes)) {
die("File is to big. It must be $sizebytes bytes or less.");
}

$ext = strrchr($file_name,'.');
if (($extlimit == "yes") && (!in_array($ext,$limitedext))) {
die("The file you are uploading doesn't have the correct extension.");
}

@copy($file, "$absolute_path/$file_name") or die("The file you are trying to upload couldn't be copied to the server");

} else {
die("Must select file to upload");
}
echo "
<html>
<head>
<title>File Uploaded</title>
</head>
<body>";
echo $file_name." was uploaded";
echo "<br>
<a href=$PHP_SELF?action=upload></a> |
<a href=$PHP_SELF?action=download> </a> |
<a href=$websiteurl> Return to $websitename</a><br><br>

</body>
</html>";
break;
Reply With Quote
  #2 (permalink)  
Old September 23rd, 2014, 10:09 AM
Friend of Wrox
Points: 651, Level: 9
Points: 651, Level: 9 Points: 651, Level: 9 Points: 651, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Location: North East UK
Posts: 125
Thanks: 0
Thanked 24 Times in 24 Posts
Default

Greetings,

Replace this;
Code:
if (!isset($action)) {
$action = "";
}
with this;
Code:
// Setup array of limited actions
$actions = array('doupload', 'download', 'upload');

// Grab action from either POST or GET array
$action = ( isset($_GET['action']) ? $_GET['action'] : ( isset($_POST['action']) ? $_POST['action'] : ''));

// Check to see if the supplied action is in the allowed list...
$action = ( in_array($action, $actions) ? $action : '');
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
pass user input of php to another php script iswariyas Pro PHP 5 May 6th, 2010 12:16 AM
php script m_29 Beginning PHP 2 October 5th, 2008 06:53 PM
PHP - register_globals off/on Tachyon Beginning PHP 2 May 18th, 2004 07:38 PM
register_globals lunadellest Beginning PHP 1 September 20th, 2003 11:33 AM
Call and run CGI script from a PHP script ... how? dbruins BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 June 10th, 2003 03:09 PM



All times are GMT -4. The time now is 03:43 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.