function modify_file($file_source, $file_dest, $modify_hash) { $file_content = read_file($file_source); foreach ($modify_hash as $param => $val) { $file_content = str_replace($param, php_quote($val), $file_content); } write_file($file_dest, $file_content); }
print "configure.php install: Unable to write file {$file}.\n"; exit(1); } // Create empty directory that will be used by software to store uploaded documents print "Create directory " . $datadir . "\n"; @mkdir($datadir); chmod($datadir, 0775); // Create install.forced.php into htdocs/install directory with value. // This will set parameters of install for web installer wizard. $file_source = $rootdir . '/../build/aps/install.forced.php.install'; $file = $rootdir . '/install/install.forced.php'; print "Create file " . $file . ' from ' . $file_source . "\n"; $modify_hash = array('WEB___DIR' => $rootdir, 'DB_' . $db_id . '_HOST' => $db_address, 'DB_' . $db_id . '_PORT' => $db_port, 'DB_' . $db_id . '_LOGIN' => $dblogin, 'DB_' . $db_id . '_PASSWORD' => $dbpassword, 'DB_' . $db_id . '_NAME' => $dbname); $file_content = fread(fopen($file_source, 'r'), filesize($file_source)); foreach ($modify_hash as $param => $val) { $file_content = str_replace($param, php_quote($val), $file_content); } $fp = fopen($file, 'wb'); if ($fp) { fputs($fp, $file_content); fputs($fp, "\n"); fclose($fp); chmod($file, 0775); } else { print "configure.php install: Unable to write file {$file}.\n"; exit(2); } exit(0); } if ($command == "remove") { //Code to be executed on invoking configure with the remove argument