/**
  * @return string
  */
 public function control()
 {
     $output = "";
     $authorized = false;
     if (isset($this->argc) && $this->argc > 2) {
         // check for CLI credentials
         $session = new Session();
         $streamer_method = $this->argv[1];
         $username = $this->argv[2];
         if ($this->argc > 3) {
             $pw = $this->argv[3];
         } else {
             $pw = getenv('THINKUP_PASSWORD');
         }
         $owner_dao = DAOFactory::getDAO('OwnerDAO');
         $owner = $owner_dao->getByEmail($username);
         $passcheck = $owner_dao->getPass($username);
         if ($session->pwdCheck($pw, $passcheck)) {
             $authorized = true;
             Session::completeLogin($owner);
         } else {
             $output = "ERROR: Incorrect username and password.";
         }
     } else {
         // check user is logged in on the web
         if ($this->isLoggedIn()) {
             $authorized = true;
         } else {
             $output = "ERROR: Invalid or missing stream method, username, and password.";
         }
     }
     if ($authorized) {
         $streamer = Streamer::getInstance();
         // print "have streamer method: $streamer_method\n";
         switch ($streamer_method) {
             case 'stream':
                 $streamer->stream();
                 break;
             case 'streamProcess':
                 $streamer->streamProcess();
                 break;
             case 'shutdownStreams':
                 $streamer->shutdownStreams();
                 break;
             default:
                 $output = "Error: could not identify stream method to run.";
         }
     }
     return $output;
 }
Ejemplo n.º 2
0
 *
 * Copyright (c) 2009-2011 Gina Trapani, Amy Unruh
 *
 * LICENSE:
 *
 * This file is part of ThinkUp (http://thinkupapp.com).
 *
 * ThinkUp is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any
 * later version.
 *
 * ThinkUp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with ThinkUp.  If not, see
 * <http://www.gnu.org/licenses/>.
 *
 * @author Amy Unruh
 */
$config = Config::getInstance();
//@TODO: For the testing sake, check if mock class has already been loaded
//@TODO: Figure out a better way to do this
if (!class_exists('TwitterOAuth')) {
    Utils::defineConstants();
    require_once THINKUP_WEBAPP_PATH . 'plugins/twitter/extlib/twitteroauth/twitteroauth.php';
}
$webapp = Webapp::getInstance();
$webapp->registerPlugin('twitterrealtime', 'TwitterRealtimePlugin');
$streamer = Streamer::getInstance();
$streamer->registerStreamerPlugin('TwitterRealtimePlugin');