/**
  * Copy .example files and replace Variables
  * Example files have to be in GWF_CORE_PATH/inc/install/data
  * @param string $file the filename without extension
  * @param string $path the destination path
  * @param string $ext file extension (e.g. .php)
  */
 public static function CopyExampleFile($file, $path, $ext = '.php', &$output)
 {
     $copied = $path . $file . $ext;
     if (false === Common::isFile($copied)) {
         if (false === GWF_File::isWriteable($copied)) {
             $output .= GWF_InstallWizard::wizard_error('err_copy', array($copied));
             return false;
         }
         # Load skeleton.
         $example = GWF_CORE_PATH . 'inc/install/data/' . $file . '.example' . $ext;
         if (false === ($content = file_get_contents($example))) {
             $output .= GWF_HTML::err('ERR_FILE_NOT_FOUND', array($example));
             return false;
         }
         # Replacements
         $replace = array('%%GWFPATH%%' => GWF_DETECT_PATH, '%%DB%%' => escapeshellarg(GWF_DB_DATABASE), '%%USER%%' => escapeshellarg(GWF_DB_USER), '%%PASS%%' => escapeshellarg(GWF_DB_PASSWORD), '%%SALT%%' => escapeshellarg(GWF_Random::randomKey(16)));
         $content = str_replace(array_keys($replace), array_values($replace), $content);
         # Write custom file.
         if (false === file_put_contents($copied, $content)) {
             $output .= GWF_HTML::err('ERR_WRITE_FILE', array($copied));
             return false;
         }
         if (false === chmod($copied, GWF_CHMOD)) {
             $output .= GWF_InstallWizard::wizard_error('err_copy', array($example));
             return false;
         }
         $output .= GWF_InstallWizard::wizard_message('msg_copy', array($copied));
     } else {
         $output .= GWF_InstallWizard::wizard_message('msg_copy_untouched', array($copied));
     }
     return true;
 }