If you are a webmaster sooner or later you will have to copy the php.ini in each folder of your ftp site, to apply the changes you made in the mentioned file or to give a better protection to the whole structure of your website. A hard solution is to copy this file by hand in each folder, but why to do so when there is a nice piece of code that makes this work for you? Here is the trick
- - Start Script Here - -
<?php
// set this value to Y if you only want to overwrite old php.ini files
// set this value to N if you want to put a php.ini file in every directory
$overwriteOnly = “Y”;
if ($overwriteOnly == “Y”) echo “Operating in Overwrite Only Mode<br><br>”;
$path = “/home/” . get_current_user() . “/public_html”;
$source = $path . “/php.ini”;
if (!file_exists($source)) die(’Error - no source php.ini file’);
function search($dir) {
global $source;
global $overwriteOnly;
$dh = opendir($dir);
while (($filename = readdir($dh)) !== false) {
if ( $filename !== ‘.’ AND $filename !== ‘..’ AND $filename !== ‘cgi-bin’ AND is_dir(”$dir/$filename”) ) {
$path = $dir.”/”.$filename;
$target = $path . “/php.ini”;
if (!file_exists($target) AND $overwriteOnly == “Y”) {
echo “$path <b>skipped - no php.ini file</b><br>”;
} else {
echo “$target <br>”;
if (!copy($source,$target)) echo “<b>Write failed for $target </b><br>”;
if (file_exists($target)) chmod($target,0600);
}
search($path);
}
}
closedir($dh);
}
search($path);
echo “<br>Done.”;
?>
|
If you're new to Webtlk.com and like what you read, you may want to subscribe to my RSS feed or press CTRL+D to bookmark me. Thanks and keep reading! |
Tags: security, trick
Leave a Comment
Best screen resolution 1280x800 or higher.
Web Talk is best viewed in Firefox.


Comments
How to recover damaged Zip files: With problem can solve with help this tool-zip recover,this tool helped me lately,as...
How to open Google Chrome in Incognito mode…reloaded!: in chrome properties, change target to...
How to remove or uninstall GoogleUpdate.exe: Glad it helped you! I too used this porcedure (lol!!!) and I got rid of...
How to remove or uninstall GoogleUpdate.exe: Probably one of the best written uninstall procedure for the annoying...
Asus Eee S101: I also have an eeepc1000hd. Too bad Linux wasn’t on it but I flushed it. Installed a combination...
Asus Eee S101: I agree with you. I bought my Asus Eee 901 just because of the price ($399) and because it was small...
Asus Eee S101: Perhaps they targeting the people getting the U.S. corporate bailouts. Too expensive, underpowered, 8...