Exemplo n.º 1
0
/**
* Show All Top Images, Videos or Text
*/
require dirname(__FILE__) . '/includes/bootstrap.php';
$userID = buckys_is_logged_in();
$type = isset($_GET['type']) ? strtolower($_GET['type']) : '';
//If the url param is not correct, go to index page
if (!$type || !in_array($type, array('image', 'text', 'video'))) {
    buckys_redirect('/index.php');
}
//Perios = Today, This Week, This Month, All Time
$period = isset($_GET['period']) ? strtolower($_GET['period']) : 'all';
//Default all
if (!in_array($period, array('today', 'this-week', 'this-month', 'all'))) {
    $period = 'all';
}
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$totalCount = BuckysPost::getNumberOfPosts(BuckysPost::INDEPENDENT_POST_PAGE_ID, $period, $type);
//Init Pagination Class
$pagination = new Pagination($totalCount, BuckysPost::${COUNT_PER_PAGE . strtoupper("_{$type}")}, $page);
$page = $pagination->getCurrentPage();
//Getting Results
$results = BuckysPost::getTopPosts(BuckysPost::INDEPENDENT_POST_PAGE_ID, $period, $type, $page);
buckys_enqueue_stylesheet('index.css');
$BUCKYS_GLOBALS['content'] = "tops";
$typeString = array('image' => 'Images ', 'video' => 'Videos ', 'text' => 'Posts ');
$periodString = array('today' => 'Today ', 'this-month' => 'This Month ', 'all' => '');
//Page title
$BUCKYS_GLOBALS['title'] = "Most Popular " . $typeString[$type] . $periodString[$period] . '- BuckysRoom';
require DIR_FS_TEMPLATE . $BUCKYS_GLOBALS['template'] . "/" . $BUCKYS_GLOBALS['layout'] . ".php";
Exemplo n.º 2
0
/**
 * Show All Top Images, Videos or Text
 */
require dirname(__FILE__) . '/includes/bootstrap.php';
$userID = buckys_is_logged_in();
$type = isset($_GET['type']) ? strtolower($_GET['type']) : '';
//If the url param is not correct, go to index page
if (!$type || !in_array($type, ['image', 'text', 'video'])) {
    buckys_redirect('/index.php');
}
//Perios = Today, This Week, This Month, All Time
$period = isset($_GET['period']) ? strtolower($_GET['period']) : 'all';
//Default all
if (!in_array($period, ['today', 'this-week', 'this-month', 'all'])) {
    $period = 'all';
}
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$totalCount = BuckysPost::getNumberOfPosts($period, $type);
$pageLimit = "COUNT_PER_PAGE_" . strtoupper($type);
//Init Pagination Class
$pagination = new Pagination($totalCount, BuckysPost::${$pageLimit}, $page);
$page = $pagination->getCurrentPage();
//Getting Results
$results = BuckysPost::getTopPosts($period, $type, $page, BuckysPost::${$pageLimit});
buckys_enqueue_stylesheet('index.css');
$TNB_GLOBALS['content'] = "tops";
$typeString = ['image' => 'Images ', 'video' => 'Videos ', 'text' => 'Posts '];
$periodString = ['today' => 'Today ', 'this-week' => 'This Week ', 'this-month' => 'This Month ', 'all' => ''];
//Page title
$TNB_GLOBALS['title'] = "Most Popular " . $typeString[$type] . $periodString[$period] . '- ' . TNB_SITE_NAME;
require DIR_FS_TEMPLATE . $TNB_GLOBALS['template'] . "/" . $TNB_GLOBALS['layout'] . ".php";
<?php

require dirname(__FILE__) . '/includes/bootstrap.php';
$periods = array('today', 'this-week', 'this-month', 'all');
$types = array('image', 'text', 'video');
$counts = array('image' => 12, 'text' => 10, 'video' => 8);
foreach ($types as $type) {
    $result = array();
    foreach ($periods as $period) {
        $tResult = BuckysPost::getTopPosts(BuckysPost::INDEPENDENT_POST_PAGE_ID, $period, $type, 1, $counts[$type] - count($result));
        $result = array_merge($result, $tResult);
        if (count($result) >= $counts[$type]) {
            break;
        }
    }
    //Delete Old Data From DB
    $db->query("DELETE FROM " . TABLE_STATS_POST . " WHERE postType='" . $type . "'");
    //Insert New Data To DB
    foreach ($result as $idx => $row) {
        $db->insertFromArray(TABLE_STATS_POST, array('postID' => $row['postID'], 'postType' => $type, 'sortOrder' => $idx + 1, 'createdDate' => date('Y-m-d H:i:s')));
    }
}
//Send Email for Testing
//buckys_sendmail('*****@*****.**', 'Eric So', 'cronjob test', 'cronjob test');