-    my $tpl = new Template;
-    $tpl->read_file($config->{'templates'}->{'confirm_replace'});
-
-    $tpl->fillin('FILE',encode_html($virtual));
-    $tpl->fillin('NEW_FILE',$new_virtual->{'html'});
-    $tpl->fillin('NEW_FILENAME',file_name($new_virtual->{'html'}));
-    $tpl->fillin('NEW_DIR',encode_html($new_dir));
-    $tpl->fillin('DIR',encode_html($dir));
-    $tpl->fillin('DIR_URL',escape($dir));
-
-    $tpl->fillin('COMMAND','copy');
-    $tpl->fillin('URL',equal_url($config->{'httproot'},$virtual));
-    $tpl->fillin('SCRIPT',$script);
-
-    my $output = header(-type => 'text/html');
-    $output   .= $tpl->get_template;
-
-    return \$output;
+    return error($config->{'errors'}->{'link_replace'},$new_dir)                                    if(-l $new_physical);
+    return error($config->{'errors'}->{'dir_replace'},$new_dir)                                     if(-d $new_physical);
+    return error($config->{'errors'}->{'exist_no_write'},$new_dir,{FILE => $new_virtual->{'html'}}) unless(-w $new_physical);
+
+    if(not $data->{'cgi'}->param('confirmed'))
+    {
+     my $tpl = new Template;
+     $tpl->read_file($config->{'templates'}->{'confirm_replace'});
+
+     $tpl->fillin('FILE',encode_html($virtual));
+     $tpl->fillin('NEW_FILE',$new_virtual->{'html'});
+     $tpl->fillin('NEW_FILENAME',file_name($new_virtual->{'html'}));
+     $tpl->fillin('NEW_DIR',encode_html($new_dir));
+     $tpl->fillin('DIR',encode_html($dir));
+     $tpl->fillin('DIR_URL',escape($dir));
+
+     $tpl->fillin('COMMAND','copy');
+     $tpl->fillin('URL',encode_html(equal_url($config->{'httproot'},$virtual)));
+     $tpl->fillin('SCRIPT',$script);
+
+     my $output = header(-type => 'text/html');
+     $output   .= $tpl->get_template;
+
+     return \$output;
+    }