refactor server_replication.php 1. render HTML at once 2. split long functions

1. render HTML at once
2. split long functions