예제 #1
0
파일: index.php 프로젝트: got80s/twitalytic
session_start();
if (!isset($_SESSION['user'])) {
    header("Location: /session/login.php");
}
// set up
chdir("..");
require_once 'config.webapp.inc.php';
ini_set("include_path", ini_get("include_path") . PATH_SEPARATOR . $INCLUDE_PATH);
require_once "init.php";
$db = new Database($TWITALYTIC_CFG);
$conn = $db->getConnection();
$ud = new UserDAO($db);
$fd = new FollowDAO($db);
$id = new InstanceDAO($db);
$td = new TweetDAO($db);
if (isset($_REQUEST['u']) && $ud->isUserInDBByName($_REQUEST['u']) && isset($_REQUEST['i'])) {
    $user = $ud->getUserByName($_REQUEST['u']);
    $i = $id->getByUsername($_REQUEST['i']);
    if (isset($i)) {
        $cfg = new Config($i->twitter_username, $i->twitter_user_id);
        $s = new SmartyTwitalytic();
        if (!$s->is_cached('user.index.tpl', $i->twitter_username . "-" . $user['user_name'])) {
            $s->assign('profile', $user);
            $s->assign('user_statuses', $td->getAllTweets($user['user_id'], 20));
            $s->assign('sources', $td->getStatusSources($user['user_id']));
            $s->assign('cfg', $cfg);
            $s->assign('instance', $i);
            $exchanges = $td->getExchangesBetweenUsers($cfg->twitter_user_id, $user['user_id']);
            $s->assign('exchanges', $exchanges);
            $s->assign('total_exchanges', count($exchanges));
예제 #2
0
<?php

// set up
require_once 'config.webapp.inc.php';
ini_set("include_path", ini_get("include_path") . PATH_SEPARATOR . $INCLUDE_PATH);
require_once "init.php";
$db = new Database($TWITALYTIC_CFG);
$conn = $db->getConnection();
$td = new TweetDAO($db);
$s = new SmartyTwitalytic();
// show tweet with public replies
if (isset($_REQUEST['t']) && $td->isTweetByPublicInstance($_REQUEST['t'])) {
    if (!$s->is_cached('public.tpl', $_REQUEST['t'])) {
        $tweet = $td->getTweet($_REQUEST['t']);
        $public_tweet_replies = $td->getPublicRepliesToTweet($tweet->status_id);
        $s->assign('tweet', $tweet);
        $s->assign('replies', $public_tweet_replies);
        $s->assign('site_root', $TWITALYTIC_CFG['site_root_path']);
    }
    $s->display('public.tpl', $_REQUEST['t']);
} else {
    if (!$s->is_cached('public.tpl')) {
        $s->assign('tweets', $td->getTweetsByPublicInstances());
        $s->assign('site_root', $TWITALYTIC_CFG['site_root_path']);
    }
    $s->display('public.tpl');
}
예제 #3
0
<?php

session_start();
if (!isset($_SESSION['user'])) {
    header("Location: /session/login.php");
}
// set up
chdir("..");
require_once 'config.webapp.inc.php';
ini_set("include_path", ini_get("include_path") . PATH_SEPARATOR . $INCLUDE_PATH);
require_once "init.php";
$db = new Database($TWITALYTIC_CFG);
$conn = $db->getConnection();
$td = new TweetDAO($db);
if (isset($_REQUEST['t']) && is_numeric($_REQUEST['t']) && $td->isTweetInDB($_REQUEST['t'])) {
    $status_id = $_REQUEST['t'];
    $s = new SmartyTwitalytic();
    if (!$s->is_cached('status.index.tpl', $status_id)) {
        $tweet = $td->getTweet($status_id);
        $u = new Utils();
        $id = new InstanceDAO($db);
        $i = $id->getByUsername($tweet->author_username);
        if (isset($i)) {
            $s->assign('likely_orphans', $td->getLikelyOrphansForParent($tweet->pub_date, $i->twitter_user_id, $tweet->author_username, 15));
            $s->assign('all_tweets', $td->getAllTweets($i->twitter_user_id, 15));
        }
        $cfg = new Config($i->twitter_username, $i->twitter_user_id);
        // instantiate data access objects
        $ud = new UserDAO($db);
        $all_replies = $td->getRepliesToTweet($status_id);
        $all_replies_count = count($all_replies);
예제 #4
0
<?php

session_start();
if (!isset($_SESSION['user'])) {
    header("Location: /session/login.php");
}
// set up
chdir("..");
require_once 'config.webapp.inc.php';
ini_set("include_path", ini_get("include_path") . PATH_SEPARATOR . $INCLUDE_PATH);
require_once "init.php";
$db = new Database($THINKTANK_CFG);
$conn = $db->getConnection();
$od = new OwnerDAO($db);
$owner = $od->getByEmail($_SESSION['user']);
$td = new TweetDAO($db);
$id = new InstanceDAO($db);
if (isset($_REQUEST['u']) && $id->isUserConfigured($_REQUEST['u'])) {
    $username = $_REQUEST['u'];
    $oid = new OwnerInstanceDAO($db);
    if (!$oid->doesOwnerHaveAccess($owner, $username)) {
        echo 'Insufficient privileges. <a href="/">Back</a>.';
        $db->closeConnection($conn);
        die;
    } else {
        $tweets = $td->getAllTweetsByUsername($username);
    }
} else {
    echo 'No access';
    $db->closeConnection($conn);
    die;
예제 #5
0
 function fetchStrayRepliedToTweets($lurl, $fa)
 {
     $td = new TweetDAO($this->db, $this->logger);
     $strays = $td->getStrayRepliedToTweets($this->owner_object->id);
     $status_message = count($strays) . ' stray replied-to tweets to load.';
     $this->logger->logStatus($status_message, get_class($this));
     foreach ($strays as $s) {
         if ($this->api->available && $this->api->available_api_calls_for_crawler > 0) {
             $this->fetchAndAddTweetRepliedTo($s['in_reply_to_status_id'], $td, $lurl, $fa);
         }
     }
 }
예제 #6
0
echo $_GET["pid"];
echo "<br />";
$pid = $_GET["pid"];
$oid = $_GET["oid"];
$template = $_GET["t"];
$cache_key = $_GET["ck"];
foreach ($oid as $o) {
    echo $o;
    echo "<br />";
}
// set up
chdir("..");
require_once 'config.webapp.inc.php';
ini_set("include_path", ini_get("include_path") . PATH_SEPARATOR . $INCLUDE_PATH);
require_once "init.php";
$cfg = new Config();
$db = new Database($TWITALYTIC_CFG);
$conn = $db->getConnection();
$td = new TweetDAO($db);
foreach ($oid as $o) {
    echo "<br />";
    if (isset($_GET["fp"])) {
        $td->assignParent($pid, $o, $_GET["fp"]);
    } else {
        $td->assignParent($pid, $o);
    }
}
$db->closeConnection($conn);
$s = new SmartyTwitalytic();
$s->clear_cache($template, $cache_key);
echo 'Assignment complete.<br /><a href="' . $TWITALYTIC_CFG['site_root_path'] . '?u=' . $_GET['u'] . '#replies">Back home</a>.';
예제 #7
0
<?php

// set up
chdir("..");
require_once 'config.webapp.inc.php';
ini_set("include_path", ini_get("include_path") . PATH_SEPARATOR . $INCLUDE_PATH);
require_once "init.php";
$cfg = new Config();
$db = new Database($THINKTANK_CFG);
$s = new SmartyThinkTank();
$c = new Crawler();
$conn = $db->getConnection();
// instantiate data access objects
$ud = new UserDAO($db);
$fd = new FollowDAO($db);
$td = new TweetDAO($db);
$c->init();
//TODO error checking here, is tweet in db, etc
$status_id = $_REQUEST['t'];
$s->assign('tweet', $td->getTweet($status_id));
$s->assign('replies', $td->getPublicRepliesToTweet($status_id));
$s->assign('cfg', $cfg);
# clean up
$db->closeConnection($conn);
echo $s->fetch('replies.public.tpl');
/*
$root_path			=  "../uar/includes/";
include $root_path.'environment.php';				# Determine relevant paths
include $root_path.'status_messages.php';			# Turn error code into message
include $root_path.'validate_data.php';				# Validate application data
include $root_path.'api_config.php';				# Configuring the API connection
예제 #8
0
파일: public.php 프로젝트: BenBtg/thinktank
<?php

// set up
require_once 'config.webapp.inc.php';
ini_set("include_path", ini_get("include_path") . PATH_SEPARATOR . $INCLUDE_PATH);
require_once "init.php";
$db = new Database($THINKTANK_CFG);
$conn = $db->getConnection();
$cfg = new Config();
$td = new TweetDAO($db);
$id = new InstanceDAO($db);
$s = new SmartyThinkTank();
$s->assign('cfg', $cfg);
$i = $id->getInstanceFreshestOne();
$s->assign('crawler_last_run', $i->crawler_last_run);
// show tweet with public replies
if (isset($_REQUEST['t']) && $td->isTweetByPublicInstance($_REQUEST['t'])) {
    if (!$s->is_cached('public.tpl', $_REQUEST['t'])) {
        $tweet = $td->getTweet($_REQUEST['t']);
        $public_tweet_replies = $td->getPublicRepliesToTweet($tweet->status_id);
        $public_retweets = $td->getRetweetsOfTweet($tweet->status_id, true);
        $s->assign('tweet', $tweet);
        $s->assign('replies', $public_tweet_replies);
        $s->assign('retweets', $public_retweets);
        $rtreach = 0;
        foreach ($public_retweets as $t) {
            $rtreach += $t->author->follower_count;
        }
        $s->assign('rtreach', $rtreach);
        $s->assign('site_root', $THINKTANK_CFG['site_root_path']);
    }
예제 #9
0
 function fetchStrayRepliedToTweets($cfg, $api, $logger)
 {
     $td = new TweetDAO();
     $strays = $td->getStrayRepliedToTweets($cfg->twitter_user_id);
     $status_message = count($strays) . ' stray replied-to tweets to load.';
     $logger->logStatus($status_message, get_class($this));
     foreach ($strays as $s) {
         if ($api->available && $api->available_api_calls_for_crawler > 0) {
             $this->fetchAndAddTweetRepliedTo($s['in_reply_to_status_id'], $td, $api, $logger);
         }
     }
 }
예제 #10
0
} else {
    $db->closeConnection($conn);
    die;
}
if (!isset($_REQUEST['d'])) {
    $_REQUEST['d'] = "all-tweets";
}
$s = new SmartyThinkTank();
if (!$s->is_cached('inline.view.tpl', $i->twitter_username . "-" . $_SESSION['user'] . "-" . $_REQUEST['d'])) {
    $cfg = new Config($i->twitter_username, $i->twitter_user_id);
    $s->assign('cfg', $cfg);
    $s->assign('i', $i);
    $u = new Utils();
    // instantiate data access objects
    $ud = new UserDAO($db);
    $td = new TweetDAO($db);
    $fd = new FollowDAO($db);
    $ld = new LinkDAO($db);
    $s->assign('display', $_REQUEST['d']);
    // pass data to smarty
    switch ($_REQUEST['d']) {
        case "tweets-all":
            $s->assign('header', 'All Tweets');
            $s->assign('all_tweets', $td->getAllTweets($cfg->twitter_user_id, 15));
            break;
        case "tweets-mostreplies":
            $s->assign('header', 'Most Replied-To Tweets');
            $s->assign('most_replied_to_tweets', $td->getMostRepliedToTweets($cfg->twitter_user_id, 15));
            break;
        case "tweets-mostretweeted":
            $s->assign('header', 'Most Retweeted');
<?php

//GET -> /tweets/
//GET -> /tweets/:id
//POST -> /tweets/
//POST -> /tweets/
//DELETE -> /tweets/:id
//PUT -> /tweets/:id
//GET -> /tweets/tags/:tag => alle tweets met een specifieke hashtag ophalen
$tweetDAO = new TweetDAO();
$app->get('/tweets/?', function () use($tweetDAO) {
    header("Content-Type: application/json");
    echo json_encode($tweetDAO->selectAll(), JSON_NUMERIC_CHECK);
    exit;
});
$app->get('/tweets/:id/?', function ($id) use($tweetDAO) {
    header("Content-Type: application/json");
    echo json_encode($tweetDAO->selectById($id), JSON_NUMERIC_CHECK);
    exit;
});
$app->post('/tweets/?', function () use($app, $tweetDAO) {
    header("Content-Type: application/json");
    $post = $app->request->post();
    if (empty($post)) {
        $post = (array) json_decode($app->request()->getBody());
    }
    echo json_encode($tweetDAO->insert($post), JSON_NUMERIC_CHECK);
    exit;
});
$app->delete('/tweets/:id/?', function ($id) use($tweetDAO) {
    header("Content-Type: application/json");