Exemplo n.º 1
0
 /**
  * Test assigned variables don't get saved when debug is false
  */
 function testSmartyThinkTankAssignedValuesDebugOff()
 {
     $cfg = Config::getInstance();
     $cfg->setValue('debug', false);
     $smtt = new SmartyThinkTank();
     $smtt->assign('test_var_1', "Testing, testing, 123");
     $this->assertEqual($smtt->getTemplateDataItem('test_var_1'), null);
     $test_var_1 = $smtt->getTemplateDataItem('test_var_1');
     $this->assertTrue(!isset($test_var_1));
 }
Exemplo n.º 2
0
 /**
  * Add data to view template engine for rendering
  *
  * @param string $key
  * @param mixed $value
  */
 protected function addToView($key, $value)
 {
     $this->view_mgr->assign($key, $value);
 }
Exemplo n.º 3
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($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;
}
$s = new SmartyThinkTank();
$s->assign('tweets', $tweets);
$s->display('status.export.tpl', $username);
Exemplo n.º 4
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($THINKTANK_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 SmartyThinkTank();
$s->clear_cache($template, $cache_key);
echo 'Assignment complete.<br /><a href="' . $THINKTANK_CFG['site_root_path'] . '?u=' . $_GET['u'] . '#replies">Back home</a>.';
Exemplo n.º 5
0
<?php

session_start();
isset($_SESSION['user']) ? $_u = $_SESSION['user'] : ($_u = '');
isset($_SESSION['instance']) ? $_i = $_SESSION['instance'] : ($_i = '');
//Print_r  ($_i);
require_once "common/init.php";
$db = new Database($THINKTANK_CFG);
$conn = $db->getConnection();
$cfg = new Config();
$pd = new PostDAO($db);
$id = new InstanceDAO($db);
$s = new SmartyThinkTank();
//Pagination
$count = 15;
if (isset($_REQUEST['page'])) {
    $page = $_REQUEST['page'];
} else {
    $page = 1;
}
if ($page > 1) {
    $s->assign('prev_page', $page - 1);
}
$s->assign('cfg', $cfg);
$i = $id->getInstanceFreshestOne();
$s->assign('crawler_last_run', $i->crawler_last_run);
$s->assign('i', $_i);
// show tweet with public replies
if (isset($_REQUEST['t']) && $pd->isPostByPublicInstance($_REQUEST['t'])) {
    if (!$s->is_cached('public.tpl', $_REQUEST['t'])) {
        $post = $pd->getPost($_REQUEST['t']);
Exemplo n.º 6
0
session_start();
// 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";
$session = new Session();
if ($session->isLoggedIn()) {
    header("Location: ../index.php");
}
$db = new Database($THINKTANK_CFG);
$conn = $db->getConnection();
$od = new OwnerDAO($db);
$user_email = mysql_real_escape_string($_POST['email']);
$s = new SmartyThinkTank();
$s->caching = false;
if ($_POST['Submit'] == 'Login') {
    $result = $od->getForLogin($user_email);
    if (!$result) {
        header("Location: login.php?emsg=Invalid+email+or+password");
    } elseif (!$session->pwdCheck($_POST['pwd'], $result['pwd'])) {
        header("Location: login.php?emsg=Incorrect+email+or+password");
    } else {
        // this sets variables in the session
        $session->completeLogin($result);
        $od->updateLastLogin($user_email);
        if (isset($_GET['ret']) && !empty($_GET['ret'])) {
            header("Location: {$_GET['ret']}");
        } else {
            header("Location: " . $THINKTANK_CFG['site_root_path']);
Exemplo n.º 7
0
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();
$td = new TweetDAO($db);
if (isset($_REQUEST['t']) && is_numeric($_REQUEST['t']) && $td->isTweetInDB($_REQUEST['t'])) {
    $status_id = $_REQUEST['t'];
    $s = new SmartyThinkTank();
    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);
        $all_retweets = $td->getRetweetsOfTweet($status_id);
Exemplo n.º 8
0
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();
$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']);
Exemplo n.º 9
0
    if (!$session->pwdCheck($_POST['oldpass'], $origpass)) {
        $errormsg = "Old password does not match or empty.";
    } elseif ($_POST['pass1'] != $_POST['pass2']) {
        $errormsg = "New passwords did not match. Your password has not been changed.";
    } elseif (strlen($_POST['pass1']) < 5) {
        $errormsg = "New password must be at least 5 characters. Your password has not been changed.";
    } else {
        $cryptpass = $session->pwdcrypt($_POST['pass1']);
        $od->updatePassword($_SESSION['user'], $cryptpass);
        $successmsg = "Your password has been updated.";
    }
}
$id = new InstanceDAO($db);
$od = new OwnerDAO($db);
$cfg = new Config();
$s = new SmartyThinkTank();
$s->caching = 0;
$owner = $od->getByEmail($_SESSION['user']);
$owner_instances = $id->getByOwner($owner);
$to = new TwitterOAuth($cfg->oauth_consumer_key, $cfg->oauth_consumer_secret);
/* Request tokens from twitter */
$tok = $to->getRequestToken();
$token = $tok['oauth_token'];
$_SESSION['oauth_request_token_secret'] = $tok['oauth_token_secret'];
/* Build the authorization URL */
$oauthorize_link = $to->getAuthorizeURL($token);
if ($owner->is_admin) {
    $owners = $od->getAllOwners();
    foreach ($owners as $o) {
        $instances = $id->getByOwner($o, true);
        $o->setInstances($instances);
Exemplo n.º 10
0
<?php

session_start();
// set up
chdir("..");
require_once 'init.php';
$session = new Session();
if ($session->isLoggedIn()) {
    header("Location: ../index.php");
}
$od = DAOFactory::getDAO('OwnerDAO');
$s = new SmartyThinkTank();
$s->caching = false;
if (isset($_POST['Submit']) && $_POST['Submit'] == 'Log In') {
    $user_email = mysql_real_escape_string($_POST['email']);
    $result = $od->getForLogin($user_email);
    if (!$result) {
        $emsg = "Incorrect email or password";
    } elseif (!$session->pwdCheck($_POST['pwd'], $result['pwd'])) {
        $emsg = "Incorrect email or password";
    } else {
        // this sets variables in the session
        $session->completeLogin($result);
        $od->updateLastLogin($user_email);
        if (isset($_GET['ret']) && !empty($_GET['ret'])) {
            header("Location: {$_GET['ret']}");
        } else {
            header("Location: " . $config->getValue('site_root_path'));
        }
        exit;
    }
Exemplo n.º 11
0
if (isset($_POST['changepass']) && $_POST['changepass'] == 'Change Password') {
    $originalpass = $od->getPass($_SESSION['user']);
    $origpass = $originalpass['pwd'];
    if (!$session->pwdCheck($_POST['oldpass'], $origpass)) {
        $errormsg = "Old password does not match or empty.";
    } elseif ($_POST['pass1'] != $_POST['pass2']) {
        $errormsg = "New passwords did not match. Your password has not been changed.";
    } elseif (strlen($_POST['pass1']) < 5) {
        $errormsg = "New password must be at least 5 characters. Your password has not been changed.";
    } else {
        $cryptpass = $session->pwdcrypt($_POST['pass1']);
        $od->updatePassword($_SESSION['user'], $cryptpass);
        $successmsg = "Your password has been updated.";
    }
}
$s = new SmartyThinkTank();
$s->caching = 0;
$cfg = new Config();
$id = new InstanceDAO($db);
$od = new OwnerDAO($db);
$oid = new OwnerInstanceDAO($db);
$owner = $od->getByEmail($_SESSION['user']);
$s->assign('cfg', $cfg);
$s->assign('owner', $owner);
if ($owner->is_admin) {
    $owners = $od->getAllOwners();
    foreach ($owners as $o) {
        $instances = $id->getByOwner($o, true);
        $o->setInstances($instances);
    }
    $s->assign('owners', $owners);
Exemplo n.º 12
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($THINKTANK_CFG);
$conn = $db->getConnection();
$td = new TweetDAO($db);
$s = new SmartyThinkTank();
// 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', $THINKTANK_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', $THINKTANK_CFG['site_root_path']);
    }
    $s->display('public.tpl');
}
Exemplo n.º 13
0
    if (!$oid->doesOwnerHaveAccess($owner, $username)) {
        echo 'Insufficient privileges. <a href="/">Back</a>.';
        $db->closeConnection($conn);
        die;
    } else {
        $i = $id->getByUsernameOnNetwork($username, $_REQUEST['n']);
    }
} else {
    $db->closeConnection($conn);
    die;
}
if (!isset($_REQUEST['d'])) {
    $_REQUEST['d'] = "all-tweets";
}
$webapp->setActivePlugin($i->network);
$s = new SmartyThinkTank();
// instantiate data access objects
$ud = DAOFactory::getDAO('UserDAO');
$pd = DAOFactory::getDAO('PostDAO');
$fd = DAOFactory::getDAO('FollowDAO');
$ld = DAOFactory::getDAO('LinkDAO');
// pass data to smarty
$view_template = $webapp->loadRequestedTabData($_GET["d"], $i);
if (!$s->is_cached($view_template, $i->network_username . "-" . $_SESSION['user'] . "-" . $_REQUEST['d'])) {
    $s->assign('site_root_path', $config->getValue('site_root_path'));
    $s->assign('i', $i);
    $u = new Utils();
    $s->assign('display', $_REQUEST['d']);
}
# clean up
$db->closeConnection($conn);
Exemplo n.º 14
0
<?php

session_start();
if (!isset($_SESSION['user'])) {
    header("Location: /session/login.php");
}
// set up
chdir("..");
require_once "common/init.php";
$s = new SmartyThinkTank();
$cfg = new Config();
$request_token = $_GET['oauth_token'];
$request_token_secret = $_SESSION['oauth_request_token_secret'];
/*
echo "DEBUG:"
echo "URL Request Token: ".$request_token."<br />";
echo "Session Request Token: ".$request_token_secret."<br />";
*/
$to = new TwitterOAuth($cfg->oauth_consumer_key, $cfg->oauth_consumer_secret, $request_token, $request_token_secret);
$tok = $to->getAccessToken();
if (isset($tok['oauth_token']) && isset($tok['oauth_token_secret'])) {
    $api = new TwitterAPIAccessorOAuth($tok['oauth_token'], $tok['oauth_token_secret'], $THINKTANK_CFG['oauth_consumer_key'], $THINKTANK_CFG['oauth_consumer_secret']);
    $u = $api->verifyCredentials();
    //	echo "User ID: ". $u['user_id'];
    //	echo "User name: ". $u['user_name'];
    $twitter_id = $u['user_id'];
    $tu = $u['user_name'];
    $od = new OwnerDAO($db);
    $owner = $od->getByEmail($_SESSION['user']);
    if ($twitter_id > 0) {
        $msg = "<h2 class=\"subhead\">Twitter authentication successful!</h2>";
Exemplo n.º 15
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";
$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']);
    $i = $id->getByUsername($_REQUEST['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->user_name)) {
            $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);
Exemplo n.º 16
0
     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) {
         echo 'You have no Twitter accounts configured. <a href="' . $THINKTANK_CFG['site_root_path'] . 'account/">Set up a Twitter account here</a>';
         $db->closeConnection($conn);
         die;
     }
 }
 $s = new SmartyThinkTank();
 if (!$s->is_cached('index.tpl', $i->twitter_username . "-" . $_SESSION['user'])) {
     $cfg = new Config($i->twitter_username, $i->twitter_user_id);
     $u = new Utils();
     // instantiate data access objects
     $ud = new UserDAO($db);
     $td = new TweetDAO($db);
     $fd = new FollowDAO($db);
     // pass data to smarty
     $owner_stats = $ud->getDetails($cfg->twitter_user_id);
     $s->assign('owner_stats', $owner_stats);
     $s->assign('instance', $i);
     $s->assign('instances', $id->getByOwner($owner));
     $s->assign('cfg', $cfg);
     $total_follows_with_errors = $fd->getTotalFollowsWithErrors($cfg->twitter_user_id);
     $s->assign('total_follows_with_errors', $total_follows_with_errors);
Exemplo n.º 17
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($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']);
    }
Exemplo n.º 18
0
    $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 {
    $db->closeConnection($conn);
    die;
}
if (!isset($_REQUEST['d'])) {
    $_REQUEST['d'] = "all-tweets";
}
$s = new SmartyThinkTank();
if (!$s->is_cached('inline.view.tpl', $i->network_username . "-" . $_SESSION['user'] . "-" . $_REQUEST['d'])) {
    $cfg = new Config($i->network_username, $i->network_user_id);
    $s->assign('cfg', $cfg);
    $s->assign('i', $i);
    $u = new Utils();
    // instantiate data access objects
    $ud = new UserDAO($db);
    $pd = new PostDAO($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 Posts');
Exemplo n.º 19
0
<?php

session_start();
if (!isset($_SESSION['user'])) {
    header("Location: /session/login.php");
}
// set up
chdir("..");
require_once "common/init.php";
$od = new OwnerDAO($db);
$owner = $od->getByEmail($_SESSION['user']);
$pd = new PostDAO($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>.';
        die;
    } else {
        $tweets = $pd->getAllPostsByUsername($username);
    }
} else {
    echo 'No access';
    $db->closeConnection($conn);
    die;
}
$db->closeConnection($conn);
$s = new SmartyThinkTank();
$s->assign('tweets', $tweets);
$s->display('post.export.tpl', $username);
Exemplo n.º 20
0
$session = new Session();
if ($session->isLoggedIn()) {
    header("Location: ../index.php");
}
$db = new Database($THINKTANK_CFG);
$conn = $db->getConnection();
$od = new OwnerDAO($db);
$s = new SmartyThinkTank();
$s->caching = false;
if ($_POST['Submit'] == 'Send') {
    if ($od->doesOwnerExist($_POST['email'])) {
        $newpwd = rand(10000, 99999);
        $server = $_SERVER['HTTP_HOST'];
        $cryptpass = $session->pwdcrypt($newpwd);
        $od->updatePassword($_POST['email'], $cryptpass);
        $es = new SmartyThinkTank();
        $es->caching = false;
        $es->assign('apptitle', $THINKTANK_CFG['app_title']);
        $es->assign('email', $_POST['email']);
        $es->assign('newpwd', $newpwd);
        $es->assign('server', $server);
        $es->assign('site_root_path', $THINKTANK_CFG['site_root_path']);
        $message = $es->fetch('_email.forgotpassword.tpl');
        Mailer::mail($_POST['email'], "The " . $THINKTANK_CFG['app_title'] . " Account Details You Requested", $message);
        $successmsg = "Password recovery information has been sent to your email address. <a href=\"login.php\">Sign in.</a>";
    } else {
        $errormsg = "Account does not exist";
    }
}
if (isset($errormsg)) {
    $s->assign('errormsg', $errormsg);
Exemplo n.º 21
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
Exemplo n.º 22
0
 $captcha = new Captcha();
 if (isset($_POST['Submit']) && $_POST['Submit'] == 'Register') {
     if (strlen($_POST['email']) < 5) {
         $errormsg = "Incorrect email. Please enter valid email address.";
     }
     if (strcmp($_POST['pass1'], $_POST['pass2']) || empty($_POST['pass1'])) {
         if (!isset($errormsg)) {
             $errormsg = "Password does not match or empty.";
         }
     } elseif (!$captcha->check()) {
         // Captcha not valid, captcha handles message...
     } else {
         if ($od->doesOwnerExist($_POST['email'])) {
             $errormsg = "User account already exists.";
         } else {
             $es = new SmartyThinkTank();
             $es->caching = false;
             $activ_code = rand(1000, 9999);
             $cryptpass = $session->pwdcrypt($_POST['pass2']);
             $server = $_SERVER['HTTP_HOST'];
             $od->create($_POST['email'], $cryptpass, $_POST['country'], $activ_code, $_POST['full_name']);
             $es->assign('apptitle', $config->getValue('app_title'));
             $es->assign('server', $server);
             $es->assign('site_root_path', $config->getValue('site_root_path'));
             $es->assign('email', urlencode($_POST['email']));
             $es->assign('activ_code', $activ_code);
             $message = $es->fetch('_email.registration.tpl');
             Mailer::mail($_POST['email'], "Activate Your " . $config->getValue('app_title') . " Account", $message);
             // echo $message; // debug
             unset($_SESSION['ckey']);
             $successmsg = "Success! Check your email for an activation link.";
Exemplo n.º 23
0
<?php

session_start();
if (!isset($_SESSION['user'])) {
    header("Location: ../session/login.php");
}
// set up
chdir("..");
require_once 'init.php';
$od = DAOFactory::getDAO('OwnerDAO');
$ud = DAOFactory::getDAO('UserDAO');
$fd = DAOFactory::getDAO('FollowDAO');
$id = DAOFactory::getDAO('InstanceDAO');
$pd = DAOFactory::getDAO('PostDAO');
$s = new SmartyThinkTank();
if (isset($_REQUEST['u']) && $ud->isUserInDBByName($_REQUEST['u']) && isset($_REQUEST['i'])) {
    $user = $ud->getUserByName($_REQUEST['u']);
    $owner = $od->getByEmail($_SESSION['user']);
    $i = $id->getByUsername($_REQUEST['i']);
    if (isset($i)) {
        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('site_root_path', $config->getValue('site_root_path'));
            $s->assign('instance', $i);
            $exchanges = $pd->getExchangesBetweenUsers($i->network_user_id, $user->user_id);
            $s->assign('exchanges', $exchanges);
            $s->assign('total_exchanges', count($exchanges));
            $mutual_friends = $fd->getMutualFriends($user->user_id, $i->network_user_id);
Exemplo n.º 24
0
<?php

chdir("..");
require_once 'config.webapp.inc.php';
ini_set("include_path", ini_get("include_path") . PATH_SEPARATOR . $INCLUDE_PATH);
require_once "init.php";
include 'dbc.php';
if ($_POST['Submit'] == 'Send') {
    $host = $_SERVER['HTTP_HOST'];
    $rs_search = mysql_query("select user_email from " . $TWITALYTIC_CFG['table_prefix'] . "owners where user_email='{$_POST['email']}'");
    $user_count = mysql_num_rows($rs_search);
    if ($user_count != 0) {
        $newpwd = rand(1000, 9999);
        $host = $_SERVER['HTTP_HOST'];
        $newmd5pwd = md5($newpwd);
        mysql_query("UPDATE " . $TWITALYTIC_CFG['table_prefix'] . "owners set user_pwd='{$newmd5pwd}' where user_email='{$_POST['email']}'");
        $message = "You have requested new login details from {$host}. Here are the login details...\n\n\nUser Name: {$_POST['email']} \n\nPassword: {$newpwd} \n\n____________________________________________\n*** LOGIN ***** \n\nTo Login: http://{$host}/login.php \n\n\n_____________________________________________\nThank you. This is an automated response. PLEASE DO NOT REPLY.\n";
        mail($_POST['email'], "New Login Details", $message, "From: \"Auto-Response\" <robot@{$host}>\r\n" . "X-Mailer: PHP/" . phpversion());
        die("Thank you. New Login details has been sent to your email address");
    } else {
        die("Account with given email does not exist");
    }
}
$s = new SmartyThinkTank();
$s->display('session.forgot.tpl');
Exemplo n.º 25
0
        die("ERROR: Old password does not match or empty.");
    } elseif ($_POST['pass1'] != $_POST['pass2']) {
        die("ERROR: New passwords must match.");
    } elseif (strlen($_POST['pass1']) < 5) {
        die("ERROR: New password must be at least 5 characters.");
    } else {
        $newmd5pwd = md5($_POST['pass1']);
        mysql_query("UPDATE " . $THINKTANK_CFG['table_prefix'] . "owners set user_pwd='{$newmd5pwd}' where user_email='{$_SESSION['user']}'");
    }
}
$db = new Database($THINKTANK_CFG);
$conn = $db->getConnection();
$id = new InstanceDAO($db);
$od = new OwnerDAO($db);
$cfg = new Config($db);
$s = new SmartyThinkTank();
$s->caching = 0;
$owner = $od->getByEmail($_SESSION['user']);
$owner_instances = $id->getByOwner($owner);
$to = new TwitterOAuth($cfg->oauth_consumer_key, $cfg->oauth_consumer_secret);
/* Request tokens from twitter */
$tok = $to->getRequestToken();
$token = $tok['oauth_token'];
$_SESSION['oauth_request_token_secret'] = $tok['oauth_token_secret'];
/* Build the authorization URL */
$oauthorize_link = $to->getAuthorizeURL($token);
$s->assign('owner_instances', $owner_instances);
$s->assign('owner', $owner);
$s->assign('cfg', $cfg);
$s->assign('oauthorize_link', $oauthorize_link);
# clean up
Exemplo n.º 26
0
<?php

session_start();
if (!isset($_SESSION['user'])) {
    header("Location: /session/login.php");
}
// set up
chdir("..");
chdir("..");
require_once 'init.php';
$s = new SmartyThinkTank();
$request_token = $_GET['oauth_token'];
$request_token_secret = $_SESSION['oauth_request_token_secret'];
/*
echo "DEBUG:"
echo "URL Request Token: ".$request_token."<br />";
echo "Session Request Token: ".$request_token_secret."<br />";
*/
$to = new TwitterOAuth($config->getValue('oauth_consumer_key'), $config->getValue('oauth_consumer_secret'), $request_token, $request_token_secret);
$tok = $to->getAccessToken();
if (isset($tok['oauth_token']) && isset($tok['oauth_token_secret'])) {
    $api = new TwitterAPIAccessorOAuth($tok['oauth_token'], $tok['oauth_token_secret'], $config->getValue('oauth_consumer_key'), $config->getValue('oauth_consumer_secret'));
    $u = $api->verifyCredentials();
    //    echo "User ID: ". $u['user_id'];
    //    echo "User name: ". $u['user_name'];
    $twitter_id = $u['user_id'];
    $tu = $u['user_name'];
    $od = DAOFactory::getDAO('OwnerDAO');
    $owner = $od->getByEmail($_SESSION['user']);
    if ($twitter_id > 0) {
        $msg = "<h2 class=\"subhead\">Twitter authentication successful!</h2>";
Exemplo n.º 27
0
require_once 'init.php';
require_once 'model/class.Mailer.php';
$session = new Session();
if ($session->isLoggedIn()) {
    header("Location: ../index.php");
}
$od = DAOFactory::getDAO('OwnerDAO');
$s = new SmartyThinkTank();
$s->caching = false;
if (isset($_POST['Submit']) && $_POST['Submit'] == 'Send') {
    if ($od->doesOwnerExist($_POST['email'])) {
        $newpwd = rand(10000, 99999);
        $server = $_SERVER['HTTP_HOST'];
        $cryptpass = $session->pwdcrypt($newpwd);
        $od->updatePassword($_POST['email'], $cryptpass);
        $es = new SmartyThinkTank();
        $es->caching = false;
        $es->assign('apptitle', $config->getValue('app_title'));
        $es->assign('email', $_POST['email']);
        $es->assign('newpwd', $newpwd);
        $es->assign('server', $server);
        $es->assign('site_root_path', $config->getValue('site_root_path'));
        $message = $es->fetch('_email.forgotpassword.tpl');
        Mailer::mail($_POST['email'], "The " . $config->getValue('app_title') . " Account Details You Requested", $message);
        $successmsg = "Password recovery information has been sent to your email address. <a href=\"login.php\">Sign in.</a>";
    } else {
        $errormsg = "Account does not exist";
    }
}
if (isset($errormsg)) {
    $s->assign('errormsg', $errormsg);
Exemplo n.º 28
0
<?php

session_start();
if (!isset($_SESSION['user'])) {
    require_once 'public.php';
    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;
        }
    }
Exemplo n.º 29
0
 $captcha = new Captcha($THINKTANK_CFG);
 if ($_POST['Submit'] == 'Register') {
     if (strlen($_POST['email']) < 5) {
         $errormsg = "Incorrect email. Please enter valid email address.";
     }
     if (strcmp($_POST['pass1'], $_POST['pass2']) || empty($_POST['pass1'])) {
         if (!isset($errormsg)) {
             $errormsg = "Password does not match or empty.";
         }
     } elseif (!$captcha->check()) {
         //Captcha not valid, captcha handles message...
     } else {
         if ($od->doesOwnerExist($_POST['email'])) {
             $errormsg = "User account already exists.";
         } else {
             $es = new SmartyThinkTank();
             $es->caching = false;
             $activ_code = rand(1000, 9999);
             $cryptpass = $session->pwdcrypt($_POST['pass2']);
             $server = $_SERVER['HTTP_HOST'];
             $od->create($_POST['email'], $cryptpass, $_POST['country'], $activ_code, $_POST['full_name']);
             $es->assign('apptitle', $THINKTANK_CFG['app_title']);
             $es->assign('server', $server);
             $es->assign('site_root_path', $THINKTANK_CFG['site_root_path']);
             $es->assign('email', urlencode($_POST[email]));
             $es->assign('activ_code', $activ_code);
             $message = $es->fetch('_email.registration.tpl');
             Mailer::mail($_POST['email'], "Activate Your " . $THINKTANK_CFG['app_title'] . " Account", $message);
             echo $message;
             unset($_SESSION['ckey']);
             $successmsg = "Success! Check your email for an activation link.";
Exemplo n.º 30
0
<?php

session_start();
if (!isset($_SESSION['user'])) {
    header("Location: login.php");
}
include 'dbc.php';
if ($_POST['Submit'] == 'Change') {
    $rsPwd = mysql_query("select user_pwd from owners where user_email='{$_SESSION['user']}'") or die(mysql_error());
    list($oldpwd) = mysql_fetch_row($rsPwd);
    if ($oldpwd == md5($_POST['oldpwd'])) {
        $newpasswd = md5($_POST['newpwd']);
        mysql_query("Update " . $THINKTANK_CFG['table_prefix'] . "owners\r\n      SET user_pwd = '{$newpasswd}'       WHERE user_email = '{$_SESSION['user']}'") or die(mysql_error());
        $msg = "Location: settings.php?msg=Password updated...";
    } else {
        $msg = "Location: settings.php?msg=ERROR: Password does not match...";
    }
}
$s = new SmartyThinkTank();
if (isset($msg)) {
    $s->assign('msg', $msg);
    $s->display('session.settings.tpl', sha1($msg));
} else {
    $s->display('session.settings.tpl');
}
?>