-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
36 lines (27 loc) · 882 Bytes
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
include_once 'functions.php';
// <!-- TWIG SETUP -->
require_once './lib/Twig/Autoloader.php';
Twig_Autoloader::register();
$loader = new Twig_Loader_Filesystem('./tpl/');
$twig = new Twig_Environment($loader, array(
'cache' => './cache/',
'auto_reload' => true
));
$template = $twig->loadTemplate('main.html');
// <! -- END TWIG -->
// <!-- MAIN -->
$db = new database(DB_HOST,DB_USER,DB_PASS);
// Poll Twitter, Push to Database if too much time has elapsed since last push.
$last_updated = $db->getLatestTweetTimestamp(); // in epoch time
$time = time(); // grab time now (epoch)
if (($time - $last_updated ) > TWEET_POLL)
{
$tweet_array = pollTwitter($TWEET_SEARCH, TWEET_MAX_DISPLAY);
$db->pushTweets($tweet_array);
}
$vars["page"] = "index";
// Pull set of Tweets from DB to Display.
$vars["tweets"] = $db->getTweets();
$template->display($vars);
?>