13
Feb
2008



Bookmark and Share

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.”;
?>


Tags: ,


Related ArticlesLatest Articles
.

Leave a Comment

If you want to show an image next to your comments, get your gravatar now!

This blog is moderated. Inappropriate comments will be edited or removed. Users posting offensive comments will be banned from this blog. Report Inappropriate Comments Here.

XHTML - You can use the following tags:  <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>




Copyright © 2007-2012 | Sitemap | Privacy | Back To Top
Best screen resolution 1280x800 or higher.
Web Talk is best viewed in Firefox.

Stat