Okay so have a script that edits files.
But i want to restrict it so it only allows it to edit .inc?
I know i have to use a if statement but i dont know how to come about it.
File extension..
Started by Whitey, Mar 02 2008 06:14 PM
4 replies to this topic
#1
Posted 02 March 2008 - 06:14 PM
|
|
|
#2
Posted 02 March 2008 - 07:10 PM
Untested:
Note: Unless you have modified your php.ini file to not display .inc files, its a good idea to use the php extension to prevent them from being displayed in the browser; config.inc.php is a better idea that just config.inc
$filename = "config.inc";
$parts = explode(".", $filename);
$size = count($parts);
if($parts[$size-1] == "inc") {
//edit the file
}
Note: Unless you have modified your php.ini file to not display .inc files, its a good idea to use the php extension to prevent them from being displayed in the browser; config.inc.php is a better idea that just config.inc
#3
Posted 02 March 2008 - 09:52 PM
I got it to work with that.. Thanks
#4
Posted 02 March 2008 - 11:18 PM
#5
Guest_Jordan_*
Posted 04 March 2008 - 05:04 AM
Guest_Jordan_*
Here are two other functions that will return the proper file extension:
and
Notice the end() surrounding the explode()?
function file_extension($filename)
{
$path_info = pathinfo($filename);
return $path_info['extension'];
}
and
function file_extension($filename)
{
return end(explode(".", $filename));
}
Notice the end() surrounding the explode()?
Quote
end — Set the internal pointer of an array to its last element


Sign In
Create Account


Back to top









