Beispiel #1
0
<?php

session_start();
// set up
chdir("..");
require_once "common/init.php";
if (!isset($_GET['usr']) || !isset($_GET['code'])) {
    echo "ERROR: Invalid code given...";
    exit;
}
$od = new OwnerDAO($db);
$acode = $od->getActivationCode($_GET['usr']);
$success = false;
if ($_GET['code'] == $acode['activation_code']) {
    $od->updateActivate($_GET['usr']);
    $success = true;
}
$db->closeConnection($conn);
if ($success) {
    header("Location: login.php?smsg=Success!+Your+account+has+been+activated.+You+may+sign+into+ThinkTank.");
} else {
    header("Location: login.php?emsg=Houston,+we+have+a+problem:+account+activation+failed.");
}
Beispiel #2
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 (!$THINKTANK_CFG['is_registration_open']) {
    $s->assign('closed', true);
    $errormsg = 'Sorry, registration on this instance of ThinkTank is closed. <br /><br /><a href="http://github.com/ginatrapani/thinktank/tree/master">Install ThinkTank on your own server</a> or go back to <a href="' . $THINKTANK_CFG['site_root_path'] . 'public.php">the public timeline</a>.';
} else {
    $db = new Database($THINKTANK_CFG);
    $conn = $db->getConnection();
    $od = new OwnerDAO($db);
    $s->assign('closed', false);
    $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.";
Beispiel #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";
$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 />";
Beispiel #4
0
<?php

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 {
Beispiel #5
0
<?php

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";
require_once "class.Mailer.php";
$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']);
Beispiel #6
0
    $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.";
    }
}
$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) {
 /**
  * @return
  */
 public function launchStreams()
 {
     $logger = Logger::getInstance('stream_log_location');
     if (!$this->php_path) {
         $logger->logError("php path is not set: check Twitter Realtime plugin configuration", __METHOD__ . ',' . __LINE__);
         return;
     }
     // get information from database about all streams.  This data is indexed by email + instance id.
     $stream_hash = $this->stream_proc_dao->getAllStreamProcesses();
     // get all owners
     $owners = $this->owner_dao->getAllOwners();
     $count = 0;
     // exec the stream processing script for each owner. This will fire up the
     // stream consumption if the owner has a twitter instance.
     foreach ($owners as $owner) {
         if ($count == self::MAX_INSTANCES) {
             break;
             // only open user stream process for up to MAX_INSTANCES instances
         }
         // the last argument in the following causes only active instances to be retrieved.
         $instances = $this->instance_dao->getByOwnerAndNetwork($owner, 'twitter', true, true);
         foreach ($instances as $instance) {
             $owner_email = $owner->email;
             if (isset($owner_email)) {
                 $idx = $owner_email . "_" . $instance->id;
                 $start_new_proc = false;
                 // if a 'live' process for that user is already running, take no action
                 if (isset($stream_hash[$idx]) && $stream_hash[$idx]['email'] == $owner_email && $stream_hash[$idx]['instance_id'] == $instance->id) {
                     if (strtotime($stream_hash[$idx]['last_report']) < time() - self::GAP_TIME) {
                         $logger->logInfo("killing process " . $stream_hash[$idx]['process_id'] . " -- it has not updated recently", __METHOD__ . ',' . __LINE__);
                         $this->psKill($stream_hash[$idx]['process_id']);
                         $this->stream_proc_dao->deleteProcess($stream_hash[$idx]['process_id']);
                         $start_new_proc = true;
                     } else {
                         $logger->logInfo("process " . $stream_hash[$idx]['process_id'] . " listed with recent update time for instance with {$owner_email} and " . $stream_hash[$idx]['instance_id'] . "-- not starting another one", __METHOD__ . ',' . __LINE__);
                         $count++;
                         // include this proc in the count of running processes
                     }
                 } else {
                     // start up a process for that instance
                     $start_new_proc = true;
                 }
                 if ($start_new_proc) {
                     $logger->logInfo("starting new process for " . "{$owner_email} and " . $instance->id, __METHOD__ . ',' . __LINE__);
                     $pass = $this->owner_dao->getPass($owner_email);
                     if ($pass && isset($this->php_path)) {
                         // @TODO - check that the dir paths are set properly
                         // then exec using that owner email and the encrypted pwd as args
                         $logfile = $this->log_dir . '/' . $owner_email . '_' . $instance->id . '.log';
                         $pid = shell_exec('cd ' . $this->streaming_dir . '; ' . $this->php_path . ' stream2.php ' . ' ' . $instance->id . ' ' . $owner_email . ' ' . $pass . ' > ' . $logfile . ' 2>&1 & echo $!');
                         if (!isset($pid)) {
                             throw new StreamingException("error: could not obtain PID when starting stream2 process.");
                         }
                         // insert PID and email/instance id information into the database.
                         $res = $this->stream_proc_dao->insertProcessInfo(trim($pid), $owner_email, $instance->id);
                         if (!$res) {
                             throw new StreamingException("error: issue inserting process information into database.");
                         }
                         $logger->logInfo("started pid " . trim($pid) . " for {$owner_email} and instance id " . $instance->id, __METHOD__ . ',' . __LINE__);
                         $count++;
                     } else {
                         $logger->logError("error: not launching stream for {$owner_email}-- error " . "with specified password or php path", __METHOD__ . ',' . __LINE__);
                     }
                 }
                 if ($count == self::MAX_INSTANCES) {
                     break;
                     // only open user stream process for up to MAX_OWNERS instances
                 }
             } else {
                 $logger->logError("error: email info not available. not launching stream for instance " . $instance->id, __METHOD__ . ',' . __LINE__);
             }
         }
         // end foreach instance
     }
     // end foreach owner
 }
Beispiel #8
0
<?php

chdir("..");
require_once "common/init.php";
$authorized = false;
if (isset($argc) && $argc > 1) {
    // check for CLI credentials
    $session = new Session();
    $username = $argv[1];
    $pw = $argv[2];
    $od = new OwnerDAO($db);
    $result = $od->getForLogin($username);
    if ($session->pwdCheck($pw, $result['pwd'])) {
        $authorized = true;
        echo "Authorized to run crawler.";
    } else {
        echo "Incorrect username and password.";
    }
} else {
    // check user is logged in on the web
    session_start();
    $session = new Session();
    if ($session->isLoggedIn()) {
        $authorized = true;
    }
}
if ($authorized) {
    $crawler->crawl();
    if (isset($conn)) {
        $db->closeConnection($conn);
        // Clean up