Esempio n. 1
0
    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));
            $mutual_friends = $fd->getMutualFriends($user['user_id'], $i->twitter_user_id);
            $s->assign('mutual_friends', $mutual_friends);
            $s->assign('total_mutual_friends', count($mutual_friends));
Esempio n. 2
0
chdir("..");
require_once 'config.webapp.inc.php';
ini_set("include_path", ini_get("include_path") . PATH_SEPARATOR . $INCLUDE_PATH);
require_once "init.php";
$tu = $_POST['twitter_username'];
$tp = $_POST['twitter_password'];
$db = new Database($THINKTANK_CFG);
$conn = $db->getConnection();
$od = new OwnerDAO($db);
$owner = $od->getByEmail($_SESSION['user']);
$api = new TwitterAPIAccessor($tu, $tp);
$twitter_id = $api->doesAuthenticate();
if ($twitter_id > 0) {
    echo "Twitter authentication successful.<br />";
    $id = new InstanceDAO($db);
    $i = $id->getByUsername($tu);
    $oid = new OwnerInstanceDAO($db);
    if (isset($i)) {
        echo "Instance already exists.<br />";
        $id->updatePassword($tu, $tp);
        echo "Updated existing instance's password.<br />";
        $oi = $oid->get($owner->id, $i->id);
        if ($oi != null) {
            echo "Owner already has this instance, no insert or update.<br />";
        } else {
            $oid->insert($owner->id, $i->id);
            echo "Added owner instance.<br />";
        }
    } else {
        echo "Instance does not exist.<br />";
        $id->insert($twitter_id, $tu, $tp);
Esempio n. 3
0
// 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);
        $public_replies = $td->getPublicRepliesToTweet($status_id);
        $public_replies_count = count($public_replies);
        $private_replies_count = $all_replies_count - $public_replies_count;
        $tweet = $td->getTweet($status_id);
        $s->assign('tweet', $tweet);
        $s->assign('replies', $all_replies);
Esempio n. 4
0
    die;
} else {
    require_once "common/init.php";
    $od = new OwnerDAO($db);
    $owner = $od->getByEmail($_SESSION['user']);
    $id = new InstanceDAO($db);
    $s = new SmartyThinkTank();
    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 {
            $i = $id->getByUsername($username);
        }
    } else {
        $i = $id->getFreshestByOwnerId($owner->id);
        if (!isset($i) && $i == null) {
            $s->assign('msg', 'You have no Twitter accounts configured. <a href="' . $THINKTANK_CFG['site_root_path'] . 'account/?p=twitter">Set up a Twitter account here</a>');
            $s->display('message.tpl');
            $db->closeConnection($conn);
            die;
        }
    }
    // save the session instance network username to the current instance
    $_SESSION['network_username'] = $i->network_username;
    $_SESSION['instance'] = serialize($i);
    if (!$s->is_cached('index.tpl', $i->network_username . "-" . $_SESSION['user'])) {
        $cfg = new Config($i->network_username, $i->network_user_id);
Esempio n. 5
0
    header("Location: ../session/login.php");
}
// set up
chdir("..");
require_once "common/init.php";
$od = new OwnerDAO($db);
$ud = new UserDAO($db);
$fd = new FollowDAO($db);
$id = new InstanceDAO($db);
$pd = new PostDAO($db);
$s = new SmartyThinkTank();
if (isset($_REQUEST['u']) && $ud->isUserInDBByName($_REQUEST['u']) && isset($_REQUEST['i'])) {
    $user = $ud->getUserByName($_REQUEST['u']);
    $owner = $od->getByEmail($_SESSION['user']);
    // let's use the session variable to guarantee a value rather than the $i POST value, which can be blank
    $i = $id->getByUsername($_SESSION['network_username']);
    //$i = $id->getByUsername($_SESSION['i']);
    if (isset($i)) {
        $cfg = new Config($i->network_username, $i->network_user_id);
        if (!$s->is_cached('user.index.tpl', $i->network_username . "-" . $user->username)) {
            $s->assign('instances', $id->getByOwner($owner));
            $s->assign('profile', $user);
            $s->assign('user_statuses', $pd->getAllPosts($user->user_id, 20));
            $s->assign('sources', $pd->getStatusSources($user->user_id));
            $s->assign('cfg', $cfg);
            $s->assign('instance', $i);
            $s->assign('i', $i);
            // HATE TO DO THIS BUT SOME TEMPLATES LOOKING FOR $i AND NOT $instance
            $exchanges = $pd->getExchangesBetweenUsers($cfg->twitter_user_id, $user->user_id);
            $s->assign('exchanges', $exchanges);
            $s->assign('total_exchanges', count($exchanges));
Esempio n. 6
0
}
// 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";
$pd = new PostDAO($db);
if (isset($_REQUEST['t']) && is_numeric($_REQUEST['t']) && $pd->isPostInDB($_REQUEST['t'])) {
    $status_id = $_REQUEST['t'];
    $s = new SmartyThinkTank();
    if (!$s->is_cached('status.index.tpl', $status_id)) {
        $post = $pd->getPost($status_id);
        $u = new Utils();
        // BUG: THIS ISN'T GOING TO WORK WHEN LOOKING AT POSTS OF OTHER USERS BECAUSE THEY DON'T HAVE INSTANCES
        $id = new InstanceDAO($db);
        $i = $id->getByUsername($post->author_username);
        if (isset($i)) {
            $s->assign('likely_orphans', $pd->getLikelyOrphansForParent($post->pub_date, $i->network_user_id, $post->author_username, 15));
            $s->assign('all_tweets', $pd->getAllPosts($i->network_user_id, 15));
        }
        $cfg = new Config($i->network_username, $i->network_user_id);
        // instantiate data access objects
        $ud = new UserDAO($db);
        $all_replies = $pd->getRepliesToPost($status_id);
        $all_replies_count = count($all_replies);
        $all_retweets = $pd->getRetweetsOfPost($status_id);
        $retweet_reach = $pd->getPostReachViaRetweets($status_id);
        $public_replies = $pd->getPublicRepliesToPost($status_id);
        $public_replies_count = count($public_replies);
        $private_replies_count = $all_replies_count - $public_replies_count;
        $post = $pd->getPost($status_id);
Esempio n. 7
0
// set up
chdir("..");
require_once 'config.webapp.inc.php';
ini_set("include_path", ini_get("include_path") . ":" . $INCLUDE_PATH);
require_once "init.php";
$db = new Database();
$conn = $db->getConnection();
$td = new TweetDAO();
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();
        $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();
        $all_replies = $td->getRepliesToTweet($status_id);
        $all_replies_count = count($all_replies);
        $public_replies = $td->getPublicRepliesToTweet($status_id);
        $public_replies_count = count($public_replies);
        $private_replies_count = $all_replies_count - $public_replies_count;
        $tweet = $td->getTweet($status_id);
        $s->assign('tweet', $tweet);
        $s->assign('replies', $all_replies);