Пример #1
0
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));
        }
        $db->closeConnection($conn);
        $s->display('user.index.tpl', $i->twitter_username . "-" . $user['user_name']);
    }
} else {
    echo 'This user is not in the system.<br /><a href="' . $TWITALYTIC_CFG['site_root_path'] . '">back home</a>';
Пример #2
0
 function fetchInstanceUserMentions($lurl, $fa)
 {
     $status_message = "";
     // Get owner's mentions
     if ($this->api->available_api_calls_for_crawler > 0) {
         $got_newest_mentions = false;
         $continue_fetching = true;
         while ($this->api->available && $this->api->available_api_calls_for_crawler > 0 && $continue_fetching) {
             # Get the most recent mentions
             $mentions = str_replace("[id]", $this->owner_object->username, $this->api->cURL_source['mentions']);
             $args = array();
             $args['count'] = 200;
             if ($got_newest_mentions) {
                 $this->last_page_fetched_mentions++;
                 $args['page'] = $this->last_page_fetched_mentions;
             }
             list($cURL_status, $twitter_data) = $this->api->apiRequest($mentions, $this->logger, $args);
             if ($cURL_status > 200) {
                 $continue_fetching = false;
             } else {
                 try {
                     $count = 0;
                     $tweets = $this->api->parseXML($twitter_data);
                     if (count($tweets) == 0 && $got_newest_mentions) {
                         # you're paged back and no new tweets
                         $this->last_page_fetched_mentions = 1;
                         $continue_fetching = false;
                         $this->instance->is_archive_loaded_mentions = true;
                         $status_message = 'Paged back but not finding new mentions; moving on.';
                         $this->logger->logStatus($status_message, get_class($this));
                         $status_message = "";
                     }
                     $td = new TweetDAO($this->db, $this->logger);
                     if (!isset($recentTweets)) {
                         $recentTweets = $td->getAllTweets($this->owner_object->id, 15);
                     }
                     $count = 0;
                     foreach ($tweets as $tweet) {
                         // Figure out if the mention is a retweet
                         if (RetweetDetector::isRetweet($tweet['tweet_text'], $this->owner_object->username)) {
                             $this->logger->logStatus("Retweet found, " . substr($tweet['tweet_text'], 0, 50) . "... ", get_class($this));
                             $originalTweetId = RetweetDetector::detectOriginalTweet($tweet['tweet_text'], $recentTweets);
                             if ($originalTweetId != false) {
                                 $tweet['in_retweet_of_status_id'] = $originalTweetId;
                                 $this->logger->logStatus("Retweet original status ID found: " . $originalTweetId, get_class($this));
                             }
                         }
                         if ($td->addTweet($tweet, $this->owner_object, $this->logger) > 0) {
                             $count++;
                             //expand and insert links contained in tweet
                             $this->processTweetURLs($tweet, $lurl, $fa);
                             if ($tweet['user_id'] != $this->owner_object->id) {
                                 //don't update owner info from reply
                                 $u = new User($tweet, 'mentions');
                                 $this->ud->updateUser($u, $this->logger);
                             }
                         }
                     }
                     $status_message .= count($tweets) . " mentions found and {$count} saved";
                     $this->logger->logStatus($status_message, get_class($this));
                     $status_message = "";
                     $got_newest_mentions = true;
                     $this->logger->logStatus($status_message, get_class($this));
                     $status_message = "";
                     if ($got_newest_mentions && $this->instance->is_archive_loaded_replies) {
                         $continue_fetching = false;
                         $status_message .= 'Retrieved newest mentions; Reply archive loaded; Stopping reply fetch.';
                         $this->logger->logStatus($status_message, get_class($this));
                         $status_message = "";
                     }
                 } catch (Exception $e) {
                     $status_message = 'Could not parse mentions XML for $this->owner_object->username';
                     $this->logger->logStatus($status_message, get_class($this));
                     $status_message = "";
                 }
             }
         }
     } else {
         $status_message = 'Crawler API call limit exceeded.';
     }
     $this->logger->logStatus($status_message, get_class($this));
     $status_message = "";
 }
Пример #3
0
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);
        $s->assign('public_reply_count', $public_replies_count);
        $s->assign('private_reply_count', $private_replies_count);
        $s->assign('reply_count', $all_replies_count);
Пример #4
0
require_once "init.php";
$db = new Database($THINKTANK_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 SmartyThinkTank();
        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));
        }
        $db->closeConnection($conn);
        $s->display('user.index.tpl', $i->twitter_username . "-" . $user->user_name);
    }
} else {
    echo 'This user is not in the system.<br /><a href="' . $THINKTANK_CFG['site_root_path'] . '">back home</a>';