How to get popular post from across a network?

simple list all last post about the network, not the popular posts; for popular posts you must use an plugin or track via Google Analytics etc.

<ul class="postlist no-mp">

<?php 
$blogs = $wpdb->get_results( 
    "SELECT blog_id,path FROM {$wpdb->blogs} 
    WHERE blog_id != {$wpdb->blogid} 
    AND site_id = '{$wpdb->siteid}' 
    AND spam = '0' 
    AND deleted = '0' 
    AND archived = '0' 
    order by blog_id", ARRAY_A
); 
if ( 0 < count( $blogs ) ) :
    foreach( $blogs as $blog ) : 
        switch_to_blog( $blog[ 'blog_id' ] );

        if ( get_theme_mod( 'show_in_home', 'on' ) !== 'on' ) {
            continue;
        }

        $description  = get_bloginfo( 'description' );
        $blog_details = get_blog_details( $blog[ 'blog_id' ] );
        ?>
        <li class="no-mp">

            <h2 class="no-mp blog_title">
                <a href="https://wordpress.stackexchange.com/questions/41284/<?php echo $blog_details->path ?>">
                    <?php echo  $blog_details->blogname; ?>
                </a>
            </h2>

            <div class="blog_description">
                <?php echo $description; ?>
            </div>

            <?php 
            query_posts( 'showposts=5' );
            if ( have_posts() ) :
                while( have_posts() ) :
                    the_post();
                    ?>
                    <div class="blog_post">
                        <div class="post_title">
                            <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                        </div>
                        <div class="post_excerpt">
                            <?php the_excerpt(); ?>
                        </div>
                    </div>
                <?php endwhile; ?>
            <?php endif; 
            restore_current_blog();
            ?>
        </li>
<?php endforeach;?>
</ul>

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)