This file emulates the bahaviour shown when register_globals is turned on. It is useful when you need to support code that requires automatic global variable creation without enabling it for a server or particular folder (using .htaccess). Any POST or GET variables are automatically created. Further global arrays can be added to the $methodsToParse table to allow for further support. Support for $_FILE uploads recently added.
By : wmfwlr
<?
//** June 8, 2004 (wmfwlr<AT>cogeco<DOT>ca)
//** ============================================
//** Added support for uploaded file variables.
//** May 31, 2004 (wmfwlr<AT>cogeco<DOT>ca)
//** ============================================
//** Hack to act as though register_globals setting is enabled
//** on server. Unsupported code.
if(isset($GLOBALS["registerglobalsproxy"])) return;
$GLOBALS["registerglobalsproxy"] = true;
$oldErrorLevel = error_reporting(0);
//**HANDLE_FILE_VARIABLES_SEPARATELY******************************************
//** loop over the uploaded file array. Files need to be handled differently
//** due the the fact that values returned are in an array, where as with
//** register globals enabled they are not.
foreach($_FILES as $fileVar => $fileArray)
{
if(is_array($fileArray))
{
//** for each uploaded file create a variable for each value in the
//** upload array named 'filevarname_uploadedfilevalue'.
foreach($fileArray as $fileKey => $fileValue)
{
if(!is_numeric($fileKey))
{
//** construct the name of the variable to create.
$newVarName = $fileVar . "_" . $fileKey;
//** dynamically set the variable value.
$$newVarName = $fileValue;
//** the server file path needs to be stored as this fileVar to support
//** conventions of old version.
if($fileKey == "tmp_name") //** path to uploaded file.
$$fileVar = $fileValue; //** store full server path.
}
}
}
}
//**HANDLE_OTHER_SERVER_VARIABLES*********************************************
//** arrays of variable storage methods to be parsed, in order of
//** increasing trustworthyness.
$methodsToParse = array($_GET, $_POST);
foreach($methodsToParse as $method)
{
//** if the method is an array of variables attempt to set each
//** associative key to its appropriate value.
if(is_array($method))
{
foreach($method as $key => $value)
{
//** do not try to create any variables from indexes of arrays.
if(!is_numeric($key))
$$key = $value;
}
}
}
//** restore the error reporting when entered.
error_reporting($oldErrorLevel);
?>
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More Miscellaneous Code Articles
More By Codewalkers
developerWorks - FREE Tools! |
Build secure Web services with transport-level security using IBM Rational Application Developer V7 and IBM WebSphere Application Server V6.1. Follow this three-part series for step-by-step instructions about how to develop Web services and clients, configure HTTP basic authentication, and configure HTTP over SSL (HTTPS). This first part of the series walks you through building a Web service for a simple calculator application. You generate and test two different types of Web services clients: a Java Platform, Enterprise Edition (Java EE) client and a stand-alone Java client. You also handle user-defined exceptions in Web services. FREE! Go There Now!
|
|
|
|
Visit IBM developerWorks to download a free trial version of Lotus Quickr 8.0, which enables collaboration by transforming the way everyday business content such as documents, rich media, photos, and video can be shared. Lotus Quickr makes it faster and easier to share content of all types (not just documents) within virtual teams. It is designed to make it easier to collaborate across organizational boundaries, while continuing to work within the context of familiar desktop applications. FREE! Go There Now!
|
|
|
|
Learn from the best! Find out how developers use Rational ClearCase to be more flexible, innovative and deliver higher quality code in the Rational ClearCase Power Users eKit. This complimentary eKit provides a collection of materials, like articles, whitepapers, and demos that can help you become a power user of Rational ClearCase. FREE! Go There Now!
|
|
|
|
Learn how to implement a build management system that uses and extends your existing automation technologies. This tutorial shows, step-by-step, how to install and configure IBM Rational Build Forge to manage builds for Jakarta Tomcat from source code. FREE! Go There Now!
|
|
|
|
Learn how Rational Build Forge can extend a simple compile and package build process by adding customization and deployment capability. Go from a manual method to automating: checking for code changes; getting the latest source; compiling and packaging; customizing; copying to and restarting a deployment server; and sending e-mail notification that a new version is available. FREE! Go There Now!
|
|
|
|
Listen to this webcast to get an overview of Info 2.0 and a technical demo of how to quickly build an enterprise mashup. IBM's Info 2.0 technology leverages emerging Web 2.0 technologies such as mashups, feeds, AJAX, and JSON in order to simplify assembly of information using feeds and services. Come learn about the technical elements of Info 2.0 including the Feed Generation framework, Mashup Engine, and mashup assembly components. Learn how to pull information from databases, departmental information, and the Web to create mashups critical to your company’s success. We will also discuss best practices to help you get started. FREE! Go There Now!
|
|
|
|
Learn how to do more with your reusable assets with the free Rational Asset Manager eKit. The eKit includes demos on how Rational Asset Manager tracks and audits your assets in order to utilize them for reuse. Plus you’ll find white papers and a Webcast that discuss the challenges of a Service Oriented Architecture and how Rational Asset Manager can provide quick and effective solutions. FREE! Go There Now!
|
|
|
|
Rational Modeling Extension for Microsoft .NET enhances usability for code generation supporting a more intelligent refactoring. The latest enhancements enable organizations with Java and .NET systems and software development maintain architectural integrity across heterogeneous platforms. FREE! Go There Now!
|
|
|
|
Try the latest version of IBM Rational Manual Tester V7.0.1 by downloading a free trial from IBM developerWorks. This manual test authoring and execution tool promotes test step reuse to reduce the impact of software change on testers and business analysts and addresses the needs of teams performing at least a portion of their testing manually. FREE! Go There Now!
|
|
|
|
As businesses grow increasingly dependent upon Web applications, these complex entities grow more difficult to secure. Most companies equip their Web sites with firewalls, Secure Sockets Layer (SSL), and network and host security, but the majority of attacks are on applications themselves – and these technologies cannot prevent them. This paper explains what you can do to help protect your organization, and it discusses an approach for improving your organization’s Web application security. FREE! Go There Now!
|
|
|
|
All FREE IBM® developerWorks Tools! |