<?php
$ratings = get_post_meta($post->ID, '_ratings', true);
$anonymous = get_post_meta($post->ID, '_anonymous', true);
$ratings = unserialize($ratings);
$votesup = (int)get_post_meta($post->ID, '_ratings_up', true);
$votesdown = (int)get_post_meta($post->ID, '_ratings_down', true);
$notloggedin = 0;
if(is_user_logged_in() ) { 
    $current_user = wp_get_current_user();
    if(is_array($ratings) && array_key_exists($current_user->ID, $ratings) ) {
        $voted = 1;
        $vote = $ratings[$current_user->ID][0];
    }
}
else {
    $notloggedin = 1;
}
?>
<div class="article-top">
    <h1><a href="<?php the_permalink();?>"><?php the_title();?></a></h1>
    <hr />
    <div class="counters-line">
        <div class="pull-left">
            <div class="date"><i class="icon-date"></i> <?php the_time("d/m");?> </div>
            <div class="user"><i class="icon-user"></i> <?php if(!$anonymous || $anonymous == '0') the_author_posts_link(); else _e('Anonymous', 'Aruna');?></div>
            <div class="comments"><i class="icon-comments"></i> <?php comments_popup_link('0', '1', '%'); ?></div>
        </div>
        <?php if(!is_page() ) { ?>
            <div class="pull-right">
                <div class="like">
                    <a <?php if($notloggedin == 1) echo 'href="#registerModal" data-toggle="modal"'; else echo 'href="javascript:void(0)"';?> data-vote="1" data-id="<?php echo $post->ID;?>" data-voted="<?php if(isset($voted) && $vote == 1) echo '1'; else echo '0';?>">
                        <i class="icon-like <?php if(isset($voted) && $vote == 1) echo 'icon-liked';?>"></i> 
                        <span class="countnumber"><?php echo $votesup;?></span>
                    </a>
                </div>
                <div class="dislike">
                    <a <?php if($notloggedin == 1) echo 'href="#registerModal" data-toggle="modal"'; else echo 'href="javascript:void(0)"';?> data-vote="0" data-id="<?php echo $post->ID;?>" data-voted="<?php if(isset($voted) && $vote == 0) echo '1'; else echo '0';?>">
                        <i class="icon-dislike <?php if(isset($voted) && $vote == 0) echo 'icon-disliked';?>"></i> 
                        <span class="countnumber"><?php echo $votesdown;?></span>
                    </a>
                </div>
            </div>
        <?php } ?>
    </div>
</div>