function sendgrid_sga_data_api()
{
    header("Content-Type: application/json");
    if ($_POST['api_key'] != get_option("sendgrid_sga_apikey")) {
        $output = array("error" => true, "message" => "Unauthenticated.");
        echo json_encode($output);
        die;
    }
    $period_start = create_start_time($_POST['period_start'], true);
    $period_end = create_end_time($_POST['period_end'], true);
    create_table($period_start, $period_end);
    $output = array("error" => true, "message" => "Unknown error.");
    $body = array();
    if ($_POST['data'] == "users") {
        $top_users = get_top_users();
        foreach ($top_users as $rank => $user_info) {
            $formatted_user_info = format_user_info($user_info);
            $body[] = array("raw" => array("post_author" => get_post_author($user_info->post_author), "mantime" => (int) $user_info->mantime, "visits" => (int) $user_info->visits, "pageviews" => (int) $user_info->pageviews, "avg_time_on_page" => (double) $user_info->avg_time_on_page, "entrance_rate" => (double) $user_info->entrance_rate, "exit_rate" => (double) $user_info->exit_rate), "formatted" => $formatted_user_info);
        }
        $output = array("error" => false, "body" => $body, "period_start" => $period_start, "period_end" => $period_end);
    } elseif ($_POST['data'] == "posts") {
        $top_posts = get_top_posts();
        foreach ($top_posts as $rank => $post_info) {
            $formatted_post_info = format_post_info($post_info);
            $body[] = array("raw" => array("guid" => $post_info->guid, "post_title" => $post_info->post_title, "post_author" => get_post_author($post_info->post_author), "mantime" => (int) $post_info->mantime, "visits" => (int) $post_info->visits, "pageviews" => (int) $post_info->pageviews, "avg_time_on_page" => (double) $post_info->avg_time_on_page, "entrance_rate" => (double) $post_info->entrance_rate, "exit_rate" => (double) $post_info->exit_rate), "formatted" => $formatted_post_info);
        }
        $output = array("error" => false, "body" => $body, "period_start" => $period_start, "period_end" => $period_end);
    } else {
        $output = array("error" => true, "message" => "Data attribute not understood, please provide either users or posts");
    }
    echo json_encode($output);
    die;
}
Example #2
0
				<div class="bar right"></div>
			</div>
			<?php 
$feed = new NowFeed();
$feed->getNowFeed(array('limit' => 12, 'ad' => true, 'image_cutoff' => 4, 'unique_class' => 'top-home-nowfeed'));
?>
		</div>

		<div class="col-offset-center">
			<div class="row">
				<div class="col-xs-12 home-center-content">

					<div class="row post-wrapper top-post-wrapper full-width-wrapper">
						<?php 
$args = array('list_post_title' => '<i class="svg-trending"></i>RECENT HEADLINES');
get_top_posts($args);
?>
					</div>

					<div class="row post-wrapper full-width-wrapper video-wrapper">
						<?php 
get_video_post();
?>
					</div>

					<div class="row post-wrapper rr-wrapper">
						<div class="col-xs-12">		
							<div class="trending-topic"><span class="svg svg-icon svg-rafting-icon-color"></span><span class="trending-slogan rr">Raver Rafting<span>WE ARE THE SCENE</span></span></div>
						</div>

						<?php 
Example #3
0
</div>
</div>
<div class='frontpage_tab2'>
<div class='tab_padding'>
<?php 
$papers = get_top_papers($safe_category, $last_fortnight);
if ($config['collect_papers'] && sizeof($papers)) {
    print "<div class='tab_title'>Popular books &amp; papers this week</div>";
    foreach ($papers as $paper) {
        print_paper($paper, array("display" => "minimal", "show_byline" => true));
    }
    print "<div class='read_more'><a href='" . linkto("papers.php", $page_vars, array("order_by" => "cited", "timeframe" => "1m")) . "'>read more recently popular papers...</a></div>";
    print "</div>";
} else {
    print "<div class='tab_title'>Popular posts this month</div>";
    $posts = get_top_posts($safe_category, $last_month, 5);
    print "<div class='popular'>";
    foreach ($posts as $post) {
        print_post($post, array("image" => true));
    }
    print "<div class='read_more'><a href='" . linkto("posts.php", $page_vars, array("order_by" => "cited", "timeframe" => "1w")) . "'>read more recently popular posts...</a></div>";
    print "</div>";
}
?>
</div>
</div>
</div>	
<div class='frontpage_footer'>&nbsp;</div>
</div>
<?php 
include "footer.php";
<?php

require_once SENDGRID_SGA_PATH . "inc/support/leaderboard.php";
$period_start = create_start_time($_GET['period_start'], true);
$period_end = create_end_time($_GET['period_end'], true);
create_table($period_start, $period_end);
$top_users = get_top_users();
$top_posts = get_top_posts();
?>
<div class="wrap sendgrid_sga leaderboard">
	<div id="icon-segmented-google-analyzer" class="icon32"><br /></div><h2>Leaderboard</h2>
	<div class="clear"></div>

	<form class="timeframe">
		<input type="text" name="period_start" value="<?php 
echo $period_start;
?>
" class="datepicker">
		-
		<input type="text" name="period_end" value="<?php 
echo $period_end;
?>
" class="datepicker">
		<input type="hidden" name="page" value="<?php 
echo $_GET['page'];
?>
">
		<input type="submit" class="button button-primary">
	</form>
	
	<div class="clear"></div>