#!/usr/bin/php \n"; die(); } // See if the customer really exists if(!is_dir('/var/www/php-fcgi-scripts/' . $customer . '/')) { echo "Please enter a valid customer\n"; die(); } // Open the directory with the dirs holding php.inis $dir = '/var/www/php-fcgi-scripts/' . $customer . '/'; if ($dh = opendir($dir)) { // Walk through the dir while (($file = readdir($dh)) !== false) { $configdir = $dir . $file; $filetype = filetype($configdir); // We need a directory and is should not be '.' or '..' ;) if($filetype == 'dir' && $file != '.' && $file != '..') { // Let's change the value changeValue($configdir . '/php.ini', $setting, $value); } } closedir($dh); } function changeValue($configfile, $setting, $value) { // Show where we are currently echo "Working on $configfile ->"; // Get the content of the current php.ini $phpini = file_get_contents($configfile); $search[0] = "/$setting = .*/i"; $replace[0] = "$setting = $value"; // Replace the requested value $phpini2 = preg_replace($search, $replace, $phpini); // Write the modified php.ini $config_file_handler = fopen($configfile, 'w'); fwrite($config_file_handler, $phpini2); fclose($config_file_handler); // Correct the permissions exec('chown root:0 ' . escapeshellarg($configfile)); exec('chmod 0644 ' . escapeshellarg($configfile)); echo " done\n"; }