Windows 7 and DirectX 11
Happy Birthday Opera!
13
Feb
2008

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
BoringOKNiceInterestingCool! (Rate it now!)


Related Articles Latest Articles

Leave a Comment

Did I speak about you, your website, your blog, your device or software? Write a comment to let Web Talk readers know more about it. If instead you want to report an inaccuracy or an error in the article, fill out this form. Thanks!

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>




All contents are licenced under a Creative Commons Licence.
Best screen resolution 1280x800 or higher.
Web Talk is best viewed in Firefox.
Creative Commons License