13
Feb
2008

Copying php.ini in each folder of your blog

WebmasterComments Off on Copying php.ini in each folder of your blog





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




Related Articles Latest Articles
.

Comments are closed.


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

Stat