function ds_domains_admin()
{
    global $wpdb;
    if (false == ds_site_admin()) {
        // paranoid? moi?
        return false;
    }
    ds_maybe_create_db();
    echo '<h2>' . __('Domain Sync cPanel: cPanel Configuration', 'wp-domain-sync-cpanel') . '</h2>';
    if (empty($_POST['action'])) {
        //initial sync whenever user entering this page
        $sync_status = ds_domain_sync_wp_cpanel();
        if (!empty($sync_status)) {
            ?>
 <div id="message" class="updated fade"><p><strong><?php 
            _e('Sync finished. Everything is now synced.', 'wp-domain-sync-cpanel');
            ?>
</strong></p></div> <?php 
        }
        if (empty($sync_status)) {
            ?>
 <div id="message" class="updated fade"><p><strong><?php 
            _e('Sync finished. But nothing need to be synced.', 'wp-domain-sync-cpanel');
            ?>
</strong></p></div> <?php 
        }
    }
    if (!empty($_POST['action'])) {
        check_admin_referer('domain_sync');
        $cpanel_host = strtolower($_POST['cpanel_host']);
        switch ($_POST['action']) {
            case "sync":
                //ds_create_all_obj(); //moved to every looping action
                $sync_status = ds_domain_sync_wp_cpanel();
                //print_r($sync_status); exit;
                if (!empty($sync_status)) {
                    ?>
 <div id="message" class="updated fade"><p><strong><?php 
                    _e('Sync finished. Everything is now synced.', 'wp-domain-sync-cpanel');
                    ?>
</strong></p></div> <?php 
                }
                if (empty($sync_status)) {
                    ?>
 <div id="message" class="updated fade"><p><strong><?php 
                    _e('Sync finished. But nothing need to be synced.', 'wp-domain-sync-cpanel');
                    ?>
</strong></p></div> <?php 
                }
                break;
            case "edit":
                $row = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->dstable} WHERE cpanel_host = %s", $cpanel_host));
                if ($row) {
                    ds_edit_cpanel($row);
                } else {
                    echo "<h3>" . __('cPanel not found', 'wp-domain-sync-cpanel') . "</h3>";
                }
                break;
            case "save":
                if (!empty($_POST['cpanel_host']) and !empty($_POST['cpanel_user']) and !empty($_POST['cpanel_pass']) and !empty($_POST['cpanel_port']) and !empty($_POST['cpanel_theme'])) {
                    $check = new domain($_POST['cpanel_host'], $_POST['cpanel_user'], $_POST['cpanel_pass'], $_POST['cpanel_port'], true, $_POST['cpanel_theme'], '');
                    if (!$check->checkLogin()) {
                        ?>
 <div id="message" class="updated-nag"><p><strong><?php 
                        _e('The cPanel config you have entered is invalid. Please check and enter again.');
                        ?>
</strong></p></div> <?php 
                    } else {
                        if ($_POST['orig_cpanel_host'] == '' and null == $wpdb->get_var($wpdb->prepare("SELECT cpanel_host FROM {$wpdb->dstable} WHERE cpanel_host = %s", $cpanel_host))) {
                            $wpdb->query($wpdb->prepare("INSERT INTO {$wpdb->dstable} ( `cpanel_host`, `cpanel_user`, `cpanel_pass`, `cpanel_port`, `cpanel_theme` ) VALUES ( %s, %s, %s, %d, %s )", $cpanel_host, $_POST['cpanel_user'], $_POST['cpanel_pass'], $_POST['cpanel_port'], $_POST['cpanel_theme']));
                            //sync immediately when added
                            ds_alias_sync_wp_cpanel($check);
                            echo "<p><strong>" . __('cPanel Added and Synced', 'wp-domain-sync-cpanel') . "</strong></p>";
                        } else {
                            $wpdb->query($wpdb->prepare("UPDATE {$wpdb->dstable} SET cpanel_host = %s, cpanel_user = %s, cpanel_pass = %s, cpanel_port = %d, cpanel_theme = %s WHERE cpanel_host = %s", $cpanel_host, $_POST['cpanel_user'], $_POST['cpanel_pass'], $_POST['cpanel_port'], $_POST['cpanel_theme'], $_POST['orig_cpanel_host']));
                            //sync immediately when edited
                            ds_alias_sync_wp_cpanel($check);
                            echo "<p><strong>" . __('cPanel Updated and Synced', 'wp-domain-sync-cpanel') . "</strong></p>";
                        }
                    }
                }
                break;
            case "del":
                $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->dstable} WHERE cpanel_host = %s", $cpanel_host));
                echo "<p><strong>" . __('cPanel Deleted', 'wp-domain-sync-cpanel') . "</strong></p>";
                break;
        }
    }
    ds_edit_cpanel();
    $rows = $wpdb->get_results("SELECT * FROM {$wpdb->dstable} ORDER BY cpanel_id DESC LIMIT 0,20");
    ds_cpanel_listing($rows);
    //echo '<p>' . sprintf( __( '<strong>Note:</strong> %s', 'wp-domain-sync-cpanel' ), ds_idn_warning() ) . "</p>";
}