public function authControl()
 {
     $config = Config::getInstance();
     Loader::definePathConstants();
     $this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/hellothinkup/view/hellothinkup.account.index.tpl');
     $this->addToView('message', 'Hello ThinkUp world! This is an example plugin configuration page for  ' . $this->owner->email . '.');
     $this->view_mgr->addHelp('hellothinkup', 'contribute/developers/plugins/buildplugin');
     /** set option fields **/
     // name text field
     $name_field = array('name' => 'testname', 'label' => 'Your Name', 'size' => 40);
     // set element name and label
     $name_field['default_value'] = 'ThinkUp User';
     // set default value
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, $name_field);
     // add element
     // set testname header
     $this->addPluginOptionHeader('testname', 'User Info');
     // add a header for an element
     // set a special required message
     $this->addPluginOptionRequiredMessage('testname', 'Please enter a name, because we\'d really like to have one...');
     // gender radio field
     $gender_field = array('name' => 'testradio', 'label' => 'You Like');
     // set an element name and label
     $gender_field['values'] = array('Cookies' => 1, 'Cake' => 2, 'Other' => 3);
     $gender_field['default_value'] = '3';
     // set default value
     $this->addPluginOption(self::FORM_RADIO_ELEMENT, $gender_field);
     // add element
     // Birth Year Select
     $bday_field = array('name' => 'testbirthyear', 'label' => 'Select The Year You Were Born');
     $years = array();
     $i = 1900;
     while ($i <= 2010) {
         $years['Born in ' . $i] = $i;
         $i++;
     }
     $bday_field['values'] = $years;
     $bday_field['default_value'] = '2005';
     $this->addPluginOption(self::FORM_SELECT_ELEMENT, $bday_field);
     // Enable registration stuff
     $reg_field = array('name' => 'testregopen', 'label' => 'Open Registration');
     $this->addPluginOptionHeader('testregopen', 'Registration Options');
     $reg_field['values'] = array('Open' => 1, 'Closed' => 0);
     $this->addPluginOption(self::FORM_RADIO_ELEMENT, $reg_field);
     // registration key
     $reg_key = array('name' => 'RegKey', 'validation_regex' => '^\\d+$');
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, $reg_key);
     $this->setPluginOptionNotRequired('RegKey');
     $this->addPluginOptionRequiredMessage('RegKey', 'Please enter interger value for RegKey');
     // advanced data
     $adv1 = array('name' => 'AdvancedInfo1', 'label' => '1st advanced field', 'advanced' => true);
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, $adv1);
     $this->setPluginOptionNotRequired('AdvancedInfo1');
     // by default not required
     $adv2 = array('name' => 'AdvancedInfo2', 'label' => '2nd advanced field', 'advanced' => true);
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, $adv2);
     $plugin = new HelloThinkUpPlugin();
     $this->addToView('is_configured', $plugin->isConfigured());
     return $this->generateView();
 }
 public function authControl()
 {
     $config = Config::getInstance();
     Loader::definePathConstants();
     $this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/geoencoder/view/geoencoder.account.index.tpl');
     $this->view_mgr->addHelp('geoencoder', 'userguide/settings/plugins/geoencoder');
     $this->addToView('message', 'This is the GeoEncoder plugin configuration page for ' . $this->owner->email . '.');
     /** set option fields **/
     // gmaps_api_key text field
     $name_field = array('name' => 'gmaps_api_key', 'label' => 'Google Maps API Key', 'size' => 55);
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, $name_field);
     $this->addPluginOptionRequiredMessage('gmaps_api_key', 'Please enter your Google Maps API Key');
     // distance_unit radio field
     $distance_unit_field = array('name' => 'distance_unit', 'label' => 'Unit of Distance');
     $distance_unit_field['values'] = array('Kilometers' => 'km', 'Miles' => 'mi');
     $distance_unit_field['default_value'] = 'km';
     $this->addPluginOption(self::FORM_RADIO_ELEMENT, $distance_unit_field);
     $plugin = new GeoEncoderPlugin();
     if (!$plugin->isConfigured()) {
         $this->addInfoMessage('Please complete plugin setup to start using it.', 'setup');
         $this->addToView('is_configured', false);
     } else {
         $this->addToView('is_configured', true);
     }
     $this->addToView('thinkup_site_url', Utils::getApplicationURL());
     return $this->generateView();
 }
 public function authControl()
 {
     $config = Config::getInstance();
     Loader::definePathConstants();
     $this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/facebook/view/facebook.account.index.tpl');
     $this->view_mgr->addHelp('facebook', 'userguide/settings/plugins/facebook');
     /** set option fields **/
     // Application ID text field
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, array('name' => 'facebook_app_id', 'label' => 'App ID', 'size' => 18));
     // add element
     // set a special required message
     $this->addPluginOptionRequiredMessage('facebook_app_id', 'The Facebook plugin requires a valid App ID.');
     // Application Secret text field
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, array('name' => 'facebook_api_secret', 'label' => 'App Secret', 'size' => 37));
     // add element
     // set a special required message
     $this->addPluginOptionRequiredMessage('facebook_api_secret', 'The Facebook plugin requires a valid App Secret.');
     $max_crawl_time_label = 'Max crawl time in minutes';
     $max_crawl_time = array('name' => 'max_crawl_time', 'label' => $max_crawl_time_label, 'default_value' => '20', 'advanced' => true, 'size' => 3);
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, $max_crawl_time);
     $this->addToView('thinkup_site_url', Utils::getApplicationURL());
     $facebook_plugin = new FacebookPlugin();
     if ($facebook_plugin->isConfigured()) {
         $this->setUpFacebookInteractions($facebook_plugin->getOptionsHash());
         $this->addToView('is_configured', true);
     } else {
         $this->addInfoMessage('Please complete plugin setup to start using it.', 'setup');
         $this->addToView('is_configured', false);
     }
     return $this->generateView();
 }
 public function authControl()
 {
     $config = Config::getInstance();
     Loader::definePathConstants();
     $this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/twitter/view/twitter.account.hashtag.tpl');
     $this->view_mgr->addHelp('twitterhashtag', 'userguide/settings/plugins/twitter/savedsearches');
     if (isset($this->instance_username) && $this->instance_username != '') {
         $this->addToView('user', $this->instance_username);
         $instance_dao = DAOFactory::getDAO('InstanceDAO');
         $instance = $instance_dao->getByUsername($this->instance_username, 'twitter');
         if (isset($instance)) {
             $this->addToView('instance', $instance);
             $hashtaginstance_dao = DAOFactory::getDAO('InstanceHashtagDAO');
             $hashtags = $hashtaginstance_dao->getByUsername($this->instance_username, 'twitter');
             if (isset($hashtags)) {
                 $this->addToView('hashtags', $hashtags);
             }
         } else {
             $this->addErrorMessage("Twitter user @" . $this->instance_username . " does not exist.");
         }
     } else {
         $this->addErrorMessage("User undefined.");
     }
     return $this->generateView();
 }
Exemplo n.º 5
0
 /**
  * Private Constructor
  * @param array $vals Optional values to override file config
  * @return Config
  */
 private function __construct($vals = null)
 {
     if ($vals != null) {
         $this->config = $vals;
     } else {
         Loader::definePathConstants();
         if (file_exists(EFC_WEBAPP_PATH . 'config.inc.php')) {
             require EFC_WEBAPP_PATH . 'config.inc.php';
             $this->config = $EFC_CFG;
             //set version info...
             /*
             require EFC_WEBAPP_PATH . 'install/version.php';
             $this->config['EFC_VERSION']  = $EFC_VERSION;
             $this->config['EFC_VERSION_REQUIRED'] =
             array('php' => $EFC_VERSION_REQUIRED['php'], 'mysql' => $EFC_VERSION_REQUIRED['mysql']);
             */
         } else {
             throw new ConfigurationException("EFC's configuration file does not exist! " . "Try installing EFC.");
         }
     }
     foreach (array_keys(self::$defaults) as $default) {
         if (!isset($this->config[$default])) {
             $this->config[$default] = self::$defaults[$default];
         }
     }
 }
 public function authControl()
 {
     $config = Config::getInstance();
     Loader::definePathConstants();
     $this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/twitter/view/twitter.account.index.tpl');
     $this->view_mgr->addHelp('twitter', 'userguide/settings/plugins/twitter/index');
     $instance_dao = DAOFactory::getDAO('InstanceDAO');
     // get plugin option values if defined...
     $plugin_options = $this->getPluginOptions();
     $oauth_consumer_key = $this->getPluginOption('oauth_consumer_key');
     $oauth_consumer_secret = $this->getPluginOption('oauth_consumer_secret');
     $archive_limit = $this->getPluginOption('archive_limit');
     $num_twitter_errors = $this->getPluginOption('num_twitter_errors');
     $this->addToView('twitter_app_name', "ThinkUp " . $_SERVER['SERVER_NAME']);
     $this->addToView('thinkup_site_url', Utils::getApplicationURL(true));
     $plugin = new TwitterPlugin();
     if ($plugin->isConfigured()) {
         $this->addToView('is_configured', true);
         $owner_instances = $instance_dao->getByOwnerAndNetwork($this->owner, 'twitter');
         $this->addToView('owner_instances', $owner_instances);
         if (isset($this->owner) && $this->owner->isMemberAtAnyLevel()) {
             if ($this->owner->isMemberLevel()) {
                 if (sizeof($owner_instances) > 0) {
                     $this->do_show_add_button = false;
                     $this->addInfoMessage("To connect another Twitter account to ThinkUp, upgrade your membership.", 'membership_cap');
                 }
             }
         }
         if (isset($_GET['oauth_token']) || $this->do_show_add_button) {
             $twitter_oauth = new TwitterOAuth($oauth_consumer_key, $oauth_consumer_secret);
             /* Request tokens from twitter */
             $token_array = $twitter_oauth->getRequestToken(Utils::getApplicationURL(true) . "account/?p=twitter");
             if (isset($token_array['oauth_token']) || isset($_SESSION["MODE"]) && $_SESSION["MODE"] == "TESTS" || getenv("MODE") == "TESTS") {
                 //testing
                 $token = $token_array['oauth_token'];
                 SessionCache::put('oauth_request_token_secret', $token_array['oauth_token_secret']);
                 if (isset($_GET['oauth_token'])) {
                     self::addAuthorizedUser($oauth_consumer_key, $oauth_consumer_secret, $num_twitter_errors);
                 }
                 if ($this->do_show_add_button) {
                     /* Build the authorization URL */
                     $oauthorize_link = $twitter_oauth->getAuthorizeURL($token);
                     $this->addToView('oauthorize_link', $oauthorize_link);
                 }
             } else {
                 //set error message here
                 $this->addErrorMessage("Unable to obtain OAuth tokens from Twitter. Please double-check the consumer key and secret " . "are correct.", "setup");
                 $oauthorize_link = '';
                 $this->addToView('is_configured', false);
             }
         }
     } else {
         $this->addInfoMessage('Please complete plugin setup to start using it.', 'setup');
         $this->addToView('is_configured', false);
     }
     // add plugin options from
     $this->addOptionForm();
     return $this->generateView();
 }
 /**
  * @return str
  */
 public function authControl()
 {
     $config = Config::getInstance();
     Loader::definePathConstants();
     $this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/twitterrealtime/view/twitterrealtime.account.index.tpl');
     $this->view_mgr->addHelp('twitterrealtime', 'userguide/settings/plugins/twitterrealtime');
     $id = DAOFactory::getDAO('InstanceDAO');
     $od = DAOFactory::getDAO('OwnerDAO');
     // get plugin option values if defined...
     $plugin_options = $this->getPluginOptions();
     // get oauth option values from twitter plugin.
     // @TODO -- what is the right way to do this?
     $plugin_option_dao = DAOFactory::GetDAO('PluginOptionDAO');
     $twitter_options = $plugin_option_dao->getOptionsHash('twitter', true);
     $oauth_consumer_key = null;
     if (isset($twitter_options['oauth_consumer_key'])) {
         $oauth_consumer_key = $twitter_options['oauth_consumer_key']->option_value;
     }
     $oauth_consumer_secret = null;
     if (isset($twitter_options['oauth_consumer_secret'])) {
         $oauth_consumer_secret = $twitter_options['oauth_consumer_secret']->option_value;
     }
     // @TODO - get any other option values as necessary
     // $archive_limit = $this->getPluginOption('archive_limit');
     $auth_from_twitter = '';
     if (isset($oauth_consumer_key) && isset($oauth_consumer_secret)) {
         $to = new TwitterOAuth($oauth_consumer_key, $oauth_consumer_secret);
         /* Request tokens from twitter */
         $tok = $to->getRequestToken();
         if (isset($tok['oauth_token'])) {
             $token = $tok['oauth_token'];
             $_SESSION['oauth_request_token_secret'] = $tok['oauth_token_secret'];
             /* Build the authorization URL */
             $oauthorize_link = $to->getAuthorizeURL($token);
             // create indication that auth from twitter plugin is okay
             $auth_from_twitter = "Using the Twitter Consumer key and secret as set in " . "the <a href=\"./?p=twitter\">Twitter plugin</a>.";
         } else {
             //set error message here
             $this->addErrorMessage("Unable to obtain OAuth token. Check your Twitter plugin consumer key and secret configuration.");
             $oauthorize_link = '';
         }
     } else {
         $this->addErrorMessage("Missing required settings! Please configure the Twitter plugin.");
         $oauthorize_link = '';
     }
     $owner_instances = $id->getByOwnerAndNetwork($this->owner, 'twitter');
     $this->addToView('owner_instances', $owner_instances);
     $this->addToView('oauthorize_link', $oauthorize_link);
     $this->addToView('auth_from_twitter', $auth_from_twitter);
     // add plugin options from
     $this->addOptionForm();
     $plugin = new TwitterRealtimePlugin();
     $this->addToView('is_configured', $plugin->isConfigured());
     return $this->generateView();
 }
Exemplo n.º 8
0
 /**
  * Constructor
  * @param bool $session_started
  * @return ThreadJSController
  */
 public function __construct($session_started = false)
 {
     parent::__construct($session_started);
     foreach ($this->REQUIRED_PARAMS as $param) {
         if (!isset($_GET[$param]) || $_GET[$param] == '') {
             $this->is_missing_param = true;
         }
     }
     Loader::definePathConstants();
     $this->setViewTemplate(THINKUP_WEBAPP_PATH . '_lib/view/api.embed.v1.thread_js.tpl');
 }
Exemplo n.º 9
0
 public function __construct()
 {
     $config = Config::getInstance();
     if ($config->getValue('recaptcha_enable')) {
         $this->type = self::RECAPTCHA_CAPTCHA;
         Loader::definePathConstants();
         require_once EFC_WEBAPP_PATH . '_lib/extlib/recaptcha-php-1.10/recaptchalib.php';
     } else {
         $this->type = self::THINKUP_CAPTCHA;
     }
 }
 public function __construct($session_started = false, $reqs = null)
 {
     //Explicitly set TZ (before we have user's choice) to avoid date() warning about using system settings
     Utils::setDefaultTimezonePHPini();
     Loader::definePathConstants();
     //Don't call parent constructor because config.inc.php doesn't exist yet
     //Instead, set up the view manager with manual array configuration
     $cfg_array = array('site_root_path' => Utils::getSiteRootPathFromFileSystem(), 'source_root_path' => THINKUP_ROOT_PATH, 'datadir_path' => THINKUP_WEBAPP_PATH . 'data/', 'debug' => false, 'app_title_prefix' => '', 'cache_pages' => false);
     $this->view_mgr = new ViewManager($cfg_array);
     $this->setPageTitle('Install ThinkUp');
     $this->disableCaching();
     $this->reqs = $reqs;
 }
 /**
  * Generates the calling JavaScript to create embedded thread on calling page.
  * @return str JavaScript source
  */
 public function control()
 {
     Loader::definePathConstants();
     $this->setViewTemplate(THINKUP_WEBAPP_PATH . '_lib/view/api.embed.v1.embed.tpl');
     $this->setContentType('text/javascript');
     if (!$this->is_missing_param) {
         $this->addToView('post_id', $_GET['p']);
         $this->addToView('network', $_GET['n']);
     } else {
         $this->addErrorMessage('No ThinkUp thread specified.');
     }
     return $this->generateView();
 }
 private function getInstalledInsightPlugins()
 {
     // Detect what plugins exist in the filesystem; parse their header comments for plugin metadata
     Loader::definePathConstants();
     $installed_plugins = array();
     foreach (glob(THINKUP_WEBAPP_PATH . "plugins/insightsgenerator/insights/*.php") as $includefile) {
         $fhandle = fopen($includefile, "r");
         $contents = fread($fhandle, filesize($includefile));
         fclose($fhandle);
         $plugin_vals = $this->parseFileContents($contents);
         array_push($installed_plugins, $plugin_vals);
     }
     return $installed_plugins;
 }
 public function authControl()
 {
     // Get an instance
     $config = Config::getInstance();
     // Set up some constants
     Loader::definePathConstants();
     // Set the view to the account index page for this plugin
     $this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/foursquare/view/foursquare.account.index.tpl');
     // URL to the help page for this plugin
     $this->view_mgr->addHelp('foursquare', 'userguide/settings/plugins/foursquare');
     // Set some option fields on the template page
     // Set the client ID text field
     $name_field = array('name' => 'foursquare_client_id', 'label' => 'Client ID', 'size' => 48);
     // Set the default value to be blank
     $name_field['default_value'] = '';
     // Add the element to the page
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, $name_field);
     // Set a message saying this field is required
     $this->addPluginOptionRequiredMessage('foursquare_client_id', 'A client id is requried to use foursquare');
     // Set the client secret field
     $name_field = array('name' => 'foursquare_client_secret', 'label' => 'Client Secret', 'size' => 48);
     // Set the default value to be blank
     $name_field['default_value'] = '';
     // Add the element to the page
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, $name_field);
     // Set a message saying this field is required
     $this->addPluginOptionRequiredMessage('foursquare_client_secret', 'A client secret is requried to use foursquare');
     // Get a data access object so we can get the options for the plugin from the database
     $plugin_option_dao = DAOFactory::getDAO('PluginOptionDAO');
     // Get a cached hash of the options from the database
     $options = $plugin_option_dao->getOptionsHash('foursquare', true);
     // Create a new plugin object
     $plugin = new FoursquarePlugin();
     // If the plugin is configured
     if ($plugin->isConfigured()) {
         // Set up the interactions
         $this->setUpFoursquareInteractions($options);
         // Indicate on the view that this plugin is configured
         $this->addToView('is_configured', true);
     } else {
         // If the plugin isn't configured
         // Tell the user that this plugin needs configuring
         $this->addInfoMessage('Please complete plugin setup to start using it', 'setup');
         // Indicate on the view that this plugin is not configured
         $this->addToView('is_configured', false);
     }
     $this->addToView('thinkup_site_url', Utils::getApplicationURL());
     // Display the foursquare account index page
     return $this->generateView();
 }
Exemplo n.º 14
0
 public function __construct($session_started = false)
 {
     parent::__construct($session_started);
     $config = Config::getInstance();
     Loader::definePathConstants();
     $this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/twitter/view/auth.tpl');
     $this->setPageTitle('Authorizing Your Twitter Account');
     if (!isset($_GET['oauth_token']) || $_GET['oauth_token'] == '') {
         $this->addInfoMessage('No OAuth token specified.');
         $this->is_missing_param = true;
     }
     if (!SessionCache::isKeySet('oauth_request_token_secret') || SessionCache::get('oauth_request_token_secret') == '') {
         $this->addInfoMessage('Secret token not set.');
         $this->is_missing_param = true;
     }
 }
 public function authControl()
 {
     $config = Config::getInstance();
     Loader::definePathConstants();
     $this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/youtube/view/account.index.tpl');
     $this->view_mgr->addHelp('youtube', 'userguide/settings/plugins/youtube');
     /* set option fields **/
     // client ID text field
     $name_field = array('name' => 'youtube_client_id', 'label' => 'Client ID', 'size' => 50);
     $name_field['default_value'] = '';
     // set default value
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, $name_field);
     // add element
     // set a special required message
     $this->addPluginOptionRequiredMessage('youtube_client_id', 'A client ID is required to use YouTube.');
     // client secret text field
     $name_field = array('name' => 'youtube_client_secret', 'label' => 'Client secret', 'size' => 40);
     $name_field['default_value'] = '';
     // set default value
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, $name_field);
     // add element
     // set a special required message
     $this->addPluginOptionRequiredMessage('youtube_client_secret', 'A client secret is required to use YouTube.');
     // Three optional fields that will be useful for very active YouTubers
     $max_crawl_time_label = 'Max crawl time in minutes';
     $max_crawl_time = array('name' => 'max_crawl_time', 'label' => $max_crawl_time_label, 'default_value' => '20', 'advanced' => true, 'size' => 3);
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, $max_crawl_time);
     $developer_key_label = 'YouTube Developer Key';
     $developer_key = array('name' => 'developer_key', 'label' => $developer_key_label, 'default_value' => '', 'advanced' => true, 'size' => 40);
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, $developer_key);
     $comments_label = 'Maximum Comments to Collect';
     $comments = array('name' => 'max_comments', 'label' => $comments_label, 'default_value' => '', 'advanced' => true, 'size' => 5);
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, $comments);
     $plugin_option_dao = DAOFactory::getDAO('PluginOptionDAO');
     $options = $plugin_option_dao->getOptionsHash('youtube', true);
     //get cached
     $plugin = new YouTubePlugin();
     if ($plugin->isConfigured()) {
         $this->setUpYouTubeInteractions($options);
         $this->addToView('is_configured', true);
     } else {
         $this->addInfoMessage('Please complete plugin setup to start using it.', 'setup');
         $this->addToView('is_configured', false);
     }
     $this->addToView('thinkup_site_url', Utils::getApplicationURL());
     return $this->generateView();
 }
 public function authControl()
 {
     $config = Config::getInstance();
     Loader::definePathConstants();
     $this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/expandurls/view/expandurls.account.index.tpl');
     $this->view_mgr->addHelp('expandurls', 'userguide/settings/plugins/expandurls');
     $links_to_expand = array('name' => 'links_to_expand', 'label' => 'Links to expand per crawl', 'default_value' => 1500, 'size' => 4);
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, $links_to_expand);
     /** set option fields **/
     // API key text field
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, array('name' => 'flickr_api_key', 'size' => 40, 'label' => 'Flickr API key (<a href="http://www.flickr.com/services/api/keys/">Get it here</a>)'));
     // add element
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, array('name' => 'bitly_login', 'label' => 'Bit.ly Username'));
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, array('name' => 'bitly_api_key', 'size' => 40, 'label' => 'Bit.ly API key (<a href="http://bitly.com/a/your_api_key">Get it here</a>)'));
     $this->addToView('is_configured', true);
     return $this->generateView();
 }
 /**
  * Override the parent's go method because there is no view manager here--we're outputting the image directly.
  */
 public function go()
 {
     $config = Config::getInstance();
     $random_num = rand(1000, 99999);
     SessionCache::put('ckey', md5($random_num));
     $img = rand(1, 4);
     Loader::definePathConstants();
     $captcha_bg_image_path = THINKUP_WEBAPP_PATH . "assets/img/captcha/bg" . $img . ".PNG";
     $img_handle = imageCreateFromPNG($captcha_bg_image_path);
     if ($img_handle === false) {
         echo 'CAPTCHA image could not be created from ' . $captcha_bg_image_path;
     } else {
         $this->setContentType('image/png');
         $this->sendHeader();
         $color = ImageColorAllocate($img_handle, 0, 0, 0);
         ImageString($img_handle, 5, 20, 13, $random_num, $color);
         ImagePng($img_handle);
         ImageDestroy($img_handle);
     }
 }
 public function authControl()
 {
     $config = Config::getInstance();
     Loader::definePathConstants();
     $this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/instagram/view/instagram.account.index.tpl');
     $this->view_mgr->addHelp('instagram', 'userguide/settings/plugins/instagram');
     /** set option fields **/
     // Application ID text field
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, array('name' => 'instagram_app_id', 'label' => 'Client ID', 'size' => 18));
     // add element
     // set a special required message
     $this->addPluginOptionRequiredMessage('instagram_app_id', 'The instagram plugin requires a valid Client ID.');
     // Application Secret text field
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, array('name' => 'instagram_api_secret', 'label' => 'Client Secret', 'size' => 37));
     // add element
     // set a special required message
     $this->addPluginOptionRequiredMessage('instagram_api_secret', 'The instagram plugin requires a valid Client Secret.');
     $max_api_calls_label = 'API calls per crawl (5000 max)';
     $max_api_calls = array('name' => 'max_api_calls', 'label' => $max_api_calls_label, 'default_value' => '2500', 'advanced' => true, 'size' => 5);
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, $max_api_calls);
     $this->addToView('thinkup_site_url', Utils::getApplicationURL());
     $instagram_plugin = new InstagramPlugin();
     $instance_dao = DAOFactory::getDAO('InstanceDAO');
     $owner_instances = $instance_dao->getByOwnerAndNetwork($this->owner, 'instagram');
     if ($instagram_plugin->isConfigured()) {
         $this->addToView('is_configured', true);
         if (isset($this->owner) && $this->owner->isMemberAtAnyLevel()) {
             if ($this->owner->isMemberLevel()) {
                 if (sizeof($owner_instances) > 0) {
                     $this->do_show_add_button = false;
                     $this->addInfoMessage("To connect another Instagram account to ThinkUp, upgrade your " . "membership.", 'membership_cap');
                 }
             }
         }
         $this->setUpInstagramInteractions($instagram_plugin->getOptionsHash());
     } else {
         $this->addInfoMessage('Please complete plugin setup to start using it.', 'setup');
         $this->addToView('is_configured', false);
     }
     return $this->generateView();
 }
 public function authControl()
 {
     $config = Config::getInstance();
     Loader::definePathConstants();
     $this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/googleplus/view/googleplus.account.index.tpl');
     $this->view_mgr->addHelp('googleplus', 'userguide/settings/plugins/googleplus');
     /** set option fields **/
     // client ID text field
     $name_field = array('name' => 'google_plus_client_id', 'label' => 'Client ID', 'size' => 50);
     $name_field['default_value'] = '';
     // set default value
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, $name_field);
     // add element
     // set a special required message
     $this->addPluginOptionRequiredMessage('google_plus_client_id', 'A client ID is required to use Google+.');
     // client secret text field
     $name_field = array('name' => 'google_plus_client_secret', 'label' => 'Client secret', 'size' => 40);
     $name_field['default_value'] = '';
     // set default value
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, $name_field);
     // add element
     // set a special required message
     $this->addPluginOptionRequiredMessage('google_plus_client_secret', 'A client secret is required to use Google+.');
     $plugin_option_dao = DAOFactory::getDAO('PluginOptionDAO');
     $options = $plugin_option_dao->getOptionsHash('googleplus', true);
     //get cached
     $plugin = new GooglePlusPlugin();
     if ($plugin->isConfigured()) {
         $this->setUpGPlusInteractions($options);
         $this->addToView('is_configured', true);
     } else {
         $this->addInfoMessage('Please complete plugin setup to start using it.', 'setup');
         $this->addToView('is_configured', false);
     }
     $this->addToView('thinkup_site_url', Utils::getApplicationURL());
     return $this->generateView();
 }
 public function authControl()
 {
     $config = Config::getInstance();
     Loader::definePathConstants();
     $this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/twitter/view/twitter.account.index.tpl');
     $this->view_mgr->addHelp('twitter', 'userguide/settings/plugins/twitter');
     $id = DAOFactory::getDAO('InstanceDAO');
     $od = DAOFactory::getDAO('OwnerDAO');
     // get plugin option values if defined...
     $plugin_options = $this->getPluginOptions();
     $oauth_consumer_key = $this->getPluginOption('oauth_consumer_key');
     $oauth_consumer_secret = $this->getPluginOption('oauth_consumer_secret');
     $archive_limit = $this->getPluginOption('archive_limit');
     $num_twitter_errors = $this->getPluginOption('num_twitter_errors');
     $max_api_calls_per_crawl = $this->getPluginOption('max_api_calls_per_crawl');
     //Add public user instance
     if (isset($_GET['twitter_username'])) {
         // if form was submitted
         $logger = Logger::getInstance();
         $api = new TwitterAPIAccessorOAuth('NOAUTH', 'NOAUTH', $oauth_consumer_key, $oauth_consumer_secret, $num_twitter_errors, $max_api_calls_per_crawl);
         $api_call = str_replace("[id]", $_GET['twitter_username'], $api->cURL_source['show_user']);
         list($cURL_status, $data) = $api->apiRequestFromWebapp($api_call);
         if ($cURL_status == 200) {
             $thisFeed = array();
             try {
                 $xml = $api->createParserFromString(utf8_encode($data));
                 $user = array('user_id' => $xml->id, 'user_name' => $xml->screen_name, 'is_protected' => $xml->protected);
             } catch (Exception $e) {
                 $this->addErrorMessage($e->getMessage());
             }
             if (isset($user) && $user["is_protected"] == 'false') {
                 // if so, add to instances table and owners table
                 $i = $id->getByUsernameOnNetwork($_GET['twitter_username'], 'twitter');
                 $oid = DAOFactory::getDAO('OwnerInstanceDAO');
                 $msg = '';
                 if (isset($i)) {
                     //Instance exists
                     $oi = $oid->get($this->owner->id, $i->id);
                     if ($oi == null) {
                         //Owner_instance doesn't exist
                         $oid->insert($this->owner->id, $i->id, '', '');
                     }
                 } else {
                     //Instance does not exist
                     $id->insert($user["user_id"], $user["user_name"]);
                     $i = $id->getByUsernameOnNetwork($user["user_name"], 'twitter');
                     $oid->insert($this->owner->id, $i->id, '', '');
                 }
                 $this->addSuccessMessage($_GET['twitter_username'] . " has been added to ThinkUp.");
                 $this->addSuccessMessage("Added " . $_GET['twitter_username'] . " to ThinkUp.");
             } else {
                 // if not, return error
                 $this->addErrorMessage($_GET['twitter_username'] . " is a private Twitter account; ThinkUp cannot track it without authorization.");
             }
         } else {
             $this->addErrorMessage($_GET['twitter_username'] . " is not a valid Twitter username.");
         }
     }
     $this->addToView('twitter_app_name', "ThinkUp " . $_SERVER['SERVER_NAME']);
     $this->addToView('thinkup_site_url', Utils::getApplicationURL(true));
     $plugin = new TwitterPlugin();
     if ($plugin->isConfigured()) {
         $to = new TwitterOAuth($oauth_consumer_key, $oauth_consumer_secret);
         /* Request tokens from twitter */
         $tok = $to->getRequestToken(Utils::getApplicationURL(true) . "plugins/twitter/auth.php");
         if (isset($tok['oauth_token']) || isset($_SESSION["MODE"]) && $_SESSION["MODE"] == "TESTS" || getenv("MODE") == "TESTS") {
             //testing
             $token = $tok['oauth_token'];
             SessionCache::put('oauth_request_token_secret', $tok['oauth_token_secret']);
             /* Build the authorization URL */
             $oauthorize_link = $to->getAuthorizeURL($token);
             $owner_instances = $id->getByOwnerAndNetwork($this->owner, 'twitter');
             $this->addToView('owner_instances', $owner_instances);
             $this->addToView('oauthorize_link', $oauthorize_link);
             $this->addToView('is_configured', true);
         } else {
             //set error message here
             $this->addErrorMessage("Unable to obtain OAuth tokens from Twitter. Please double-check the consumer key and secret " . "are correct.", "setup");
             $oauthorize_link = '';
             $this->addToView('is_configured', false);
         }
     } else {
         $this->addInfoMessage('Please complete plugin setup to start using it.', 'setup');
         $this->addToView('is_configured', false);
     }
     // Secret config file value enables public Twitter name search
     $this->addToView('enable_twitter_search', $config->getValue('enable_twitter_search'));
     // add plugin options from
     $this->addOptionForm();
     return $this->generateView();
 }
Exemplo n.º 21
0
 /**
  * Get plugin view directory
  * @param str $shortname Plugin short name
  * @return str view path
  */
 public static function getPluginViewDirectory($shortname)
 {
     Loader::definePathConstants();
     $view_path = THINKUP_WEBAPP_PATH . 'plugins/' . $shortname . '/view/';
     return $view_path;
 }
Exemplo n.º 22
0
 /**
  * Initalize app
  * Load config file and required plugins
  * @throws Exception
  */
 private function initalizeApp()
 {
     $classname = get_class($this);
     if ($classname != "InstallerController") {
         //Initialize config
         $config = Config::getInstance();
         if ($config->getValue('debug')) {
             ini_set("display_errors", 1);
             ini_set("error_reporting", E_STRICT);
         }
         if ($classname != "BackupController") {
             //Init plugins
             $plugin_dao = DAOFactory::getDAO('PluginDAO');
             $active_plugins = $plugin_dao->getActivePlugins();
             Loader::definePathConstants();
             foreach ($active_plugins as $active_plugin) {
                 //add plugin's model and controller folders as Loader paths here
                 Loader::addPath(THINKUP_WEBAPP_PATH . 'plugins/' . $active_plugin->folder_name . "/model/");
                 Loader::addPath(THINKUP_WEBAPP_PATH . 'plugins/' . $active_plugin->folder_name . "/controller/");
                 //require the main plugin registration file here
                 if (file_exists(THINKUP_WEBAPP_PATH . 'plugins/' . $active_plugin->folder_name . "/controller/" . $active_plugin->folder_name . ".php")) {
                     require_once THINKUP_WEBAPP_PATH . 'plugins/' . $active_plugin->folder_name . "/controller/" . $active_plugin->folder_name . ".php";
                 }
             }
         }
     }
 }
Exemplo n.º 23
0
 public function testDefinePathConstants()
 {
     Loader::definePathConstants();
     $this->assertTrue(defined('THINKUP_ROOT_PATH'));
     $this->assertTrue(is_readable(THINKUP_ROOT_PATH));
     $this->debug(THINKUP_ROOT_PATH);
     $this->assertTrue(defined('THINKUP_WEBAPP_PATH'));
     $this->assertTrue(is_readable(THINKUP_WEBAPP_PATH));
     $this->debug(THINKUP_WEBAPP_PATH);
 }
 /**
  * @return str
  */
 public function authControl()
 {
     $config = Config::getInstance();
     Loader::definePathConstants();
     $this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/twitterrealtime/view/twitterrealtime.account.index.tpl');
     $this->view_mgr->addHelp('twitterrealtime', 'userguide/settings/plugins/twitterrealtime');
     $id = DAOFactory::getDAO('InstanceDAO');
     $od = DAOFactory::getDAO('OwnerDAO');
     // get plugin option values if defined...
     $plugin_options = $this->getPluginOptions();
     // get oauth option values from twitter plugin.
     // @TODO -- what is the right way to do this?
     $plugin_option_dao = DAOFactory::GetDAO('PluginOptionDAO');
     $twitter_options = $plugin_option_dao->getOptionsHash('twitter', true);
     $oauth_consumer_key = null;
     if (isset($twitter_options['oauth_consumer_key'])) {
         $oauth_consumer_key = $twitter_options['oauth_consumer_key']->option_value;
     }
     $oauth_consumer_secret = null;
     if (isset($twitter_options['oauth_consumer_secret'])) {
         $oauth_consumer_secret = $twitter_options['oauth_consumer_secret']->option_value;
     }
     // @TODO - get any other option values as necessary
     // $archive_limit = $this->getPluginOption('archive_limit');
     //Add public user instance
     if (isset($_GET['twitter_username'])) {
         // if form was submitted
         $logger = Logger::getInstance();
         $api = new TwitterAPIAccessorOAuth('NOAUTH', 'NOAUTH', $oauth_consumer_key, $oauth_consumer_secret, $num_twitter_errors, $max_api_calls_per_crawl);
         $api_call = str_replace("[id]", $_GET['twitter_username'], $api->cURL_source['show_user']);
         list($cURL_status, $data) = $api->apiRequestFromWebapp($api_call);
         if ($cURL_status == 200) {
             $thisFeed = array();
             try {
                 $xml = $api->createParserFromString(utf8_encode($data));
                 $user = array('user_id' => $xml->id, 'user_name' => $xml->screen_name, 'is_protected' => $xml->protected);
             } catch (Exception $e) {
                 $this->addErrorMessage($e->getMessage());
             }
             if (isset($user) && $user["is_protected"] == 'false') {
                 // if so, add to instances table and owners table
                 $i = $id->getByUsernameOnNetwork($_GET['twitter_username'], 'twitter');
                 $oid = DAOFactory::getDAO('OwnerInstanceDAO');
                 $msg = '';
                 if (isset($i)) {
                     //Instance exists
                     $oi = $oid->get($this->owner->id, $i->id);
                     if ($oi == null) {
                         //Owner_instance doesn't exist
                         $oid->insert($this->owner->id, $i->id, '', '');
                     }
                 } else {
                     //Instance does not exist
                     $id->insert($user["user_id"], $user["user_name"]);
                     $i = $id->getByUsernameOnNetwork($user["user_name"], 'twitter');
                     $oid->insert($this->owner->id, $i->id, '', '');
                 }
                 $this->addSuccessMessage($_GET['twitter_username'] . " has been added to ThinkUp.");
                 $this->addSuccessMessage("Added " . $_GET['twitter_username'] . " to ThinkUp.");
             } else {
                 // if not, return error
                 $this->addErrorMessage($_GET['twitter_username'] . " is a private Twitter account; ThinkUp cannot track it without authorization.");
             }
         } else {
             $this->addErrorMessage($_GET['twitter_username'] . " is not a valid Twitter username.");
         }
     }
     $auth_from_twitter = '';
     if (isset($oauth_consumer_key) && isset($oauth_consumer_secret)) {
         $to = new TwitterOAuth($oauth_consumer_key, $oauth_consumer_secret);
         /* Request tokens from twitter */
         $tok = $to->getRequestToken();
         if (isset($tok['oauth_token'])) {
             $token = $tok['oauth_token'];
             $_SESSION['oauth_request_token_secret'] = $tok['oauth_token_secret'];
             /* Build the authorization URL */
             $oauthorize_link = $to->getAuthorizeURL($token);
             // create indication that auth from twitter plugin is okay
             $auth_from_twitter = "Using the Twitter Consumer key and secret as set in " . "the <a href=\"./?p=twitter\">Twitter plugin</a>.";
         } else {
             //set error message here
             $this->addErrorMessage("Unable to obtain OAuth token. Check your Twitter plugin consumer key and secret configuration.");
             $oauthorize_link = '';
         }
     } else {
         $this->addErrorMessage("Missing required settings! Please configure the Twitter plugin.");
         $oauthorize_link = '';
     }
     $owner_instances = $id->getByOwnerAndNetwork($this->owner, 'twitter');
     $this->addToView('owner_instances', $owner_instances);
     $this->addToView('oauthorize_link', $oauthorize_link);
     $this->addToView('auth_from_twitter', $auth_from_twitter);
     // add plugin options from
     $this->addOptionForm();
     $plugin = new TwitterRealtimePlugin();
     $this->addToView('is_configured', $plugin->isConfigured());
     return $this->generateView();
 }
Exemplo n.º 25
0
 public function getInstalledPlugins()
 {
     // Detect what plugins exist in the filesystem; parse their header comments for plugin metadata
     Loader::definePathConstants();
     $active_plugins = $inactive_plugins = array();
     $plugin_files = Utils::getPlugins(THINKUP_WEBAPP_PATH . 'plugins');
     foreach ($plugin_files as $pf) {
         foreach (glob(THINKUP_WEBAPP_PATH . 'plugins/' . $pf . "/controller/" . $pf . ".php") as $includefile) {
             $fhandle = fopen($includefile, "r");
             $contents = fread($fhandle, filesize($includefile));
             fclose($fhandle);
             $plugin_vals = $this->parseFileContents($contents, $pf);
             if (isset($plugin_vals['class'])) {
                 require_once THINKUP_WEBAPP_PATH . 'plugins/' . $pf . "/model/class." . $plugin_vals['class'] . ".php";
                 $installed_plugin = new $plugin_vals['class']($plugin_vals);
             } else {
                 $installed_plugin = new Plugin($plugin_vals);
             }
             if (isset($installed_plugin)) {
                 // Insert or update plugin entries in the database
                 if (!isset($installed_plugin->id)) {
                     $new_plugin_id = $this->insertPlugin($installed_plugin);
                     if ($new_plugin_id === false) {
                         $this->updatePlugin($installed_plugin);
                     } else {
                         $installed_plugin->id = $new_plugin_id;
                     }
                 }
                 // Store in list, active first
                 if ($installed_plugin->is_active) {
                     array_push($active_plugins, $installed_plugin);
                 } else {
                     array_push($inactive_plugins, $installed_plugin);
                 }
             }
         }
     }
     return array_merge($active_plugins, $inactive_plugins);
 }
Exemplo n.º 26
0
 * ThinkUp/webapp/plugins/twitter/model/class.TwitterOAuthThinkUp.php
 *
 * Copyright (c) 2009-2013 Gina Trapani
 *
 * LICENSE:
 *
 * This file is part of ThinkUp (http://thinkup.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 Gina Trapani <ginatrapani[at]gmail[dot]com>
 * @license http://www.gnu.org/licenses/gpl.html
 * @copyright 2009-2013 Gina Trapani
 */
if (!class_exists('twitterOAuth')) {
    Loader::definePathConstants();
    require_once THINKUP_WEBAPP_PATH . 'plugins/twitter/extlib/twitteroauth/twitteroauth.php';
}
class TwitterOAuthThinkUp extends TwitterOAuth
{
}
Exemplo n.º 27
0
 /**
  * Override the parent's fetch method to handle an unwritable compilation directory.
  * @param str $template Template name
  * @param str $cache_key Cache key
  * @param str Results
  */
 public function fetch($template, $cache_key = null, $compile_id = null, $display = false)
 {
     $continue = false;
     if (is_writable(FileDataManager::getDataPath())) {
         if (!file_exists($this->compile_dir)) {
             if (mkdir($this->compile_dir, 0777)) {
                 $continue = true;
             }
         } else {
             $continue = true;
         }
     }
     if (is_writable($this->compile_dir)) {
         if ($this->caching == 1 && !file_exists($this->compile_dir . '/cache')) {
             if (mkdir($this->compile_dir . '/cache/', 0777)) {
                 $continue = true;
             }
         } else {
             $continue = true;
         }
     }
     if ($continue) {
         return parent::fetch($template, $cache_key, $compile_id, $display);
     } else {
         Loader::definePathConstants();
         $whoami = @exec('whoami');
         if (empty($whoami)) {
             $whoami = 'nobody';
         }
         return str_replace(array('#THINKUP_BASE_URL#', '#WHOAMI#', '#COMPILE_DIR#'), array(Utils::getSiteRootPathFromFileSystem(), $whoami, FileDataManager::getDataPath()), file_get_contents(THINKUP_WEBAPP_PATH . '_lib/view/500-perm.html'));
     }
 }
Exemplo n.º 28
0
 /**
  * Constructs EFCController
  *
  *  Adds email address of currently logged in EFC user, '' if not logged in, to view
  *  {$logged_in_user}
  *  @return EFCController
  */
 public function __construct($session_started = false)
 {
     try {
         //$this->baseMem = memory_get_usage(true);
         $this->redis = new Redis();
         $this->redis->connect('127.0.0.1', 6379);
         $this->memcache = new Memcache();
         $this->memcache->connect('127.0.0.1', 11211);
         $config = Config::getInstance();
         $this->profiler_enabled = Profiler::isEnabled();
         if ($this->profiler_enabled) {
             $this->start_time = microtime(true);
         }
         if ($config->getValue('timezone')) {
             date_default_timezone_set($config->getValue('timezone'));
         }
         if (!$session_started) {
             SessionCache::init();
         }
         $this->view_mgr = new ViewManager();
         $this->facebook = new Facebook\Facebook(['app_id' => $config->getValue('fb_app_id'), 'app_secret' => $config->getValue('fb_app_secret'), 'default_graph_version' => 'v2.2']);
         if ($this->isLoggedIn()) {
             $this->addToView('logged_in_user', $this->getLoggedInUser());
         }
         if ($this->isSuperAdmin()) {
             $this->addToView('user_is_admin', true);
         }
         $EFC_VERSION = $config->getValue('EFC_VERSION');
         $this->addToView('EFC_VERSION', $EFC_VERSION);
         if (Utils::isEmpoddyLabs()) {
             $empoddy_endpoint = $config->getValue('empoddy_endpoint');
             $this->addToView('empoddy_endpoint', $empoddy_endpoint);
         }
         if (SessionCache::isKeySet('selected_instance_network') && SessionCache::isKeySet('selected_instance_username')) {
             $this->addToView('selected_instance_network', SessionCache::get('selected_instance_network'));
             $this->addToView('selected_instance_username', SessionCache::get('selected_instance_username'));
         }
     } catch (Exception $e) {
         Loader::definePathConstants();
         //echo 'sending this to Smarty:'.EFC_WEBAPP_PATH.'data/';
         $cfg_array = array('site_root_path' => Utils::getSiteRootPathFromFileSystem(), 'source_root_path' => EFC_ROOT_PATH, 'datadir_path' => EFC_WEBAPP_PATH . 'data/', 'debug' => false, 'app_title_prefix' => "", 'cache_pages' => false);
         $this->view_mgr = new ViewManager($cfg_array);
         $this->setErrorTemplateState();
         $this->addToView('error_type', get_class($e));
         $disable_xss = false;
         // if we are an installer exception, don't filter XSS, we have markup, and we trust this content
         if (get_class($e) == 'InstallerException') {
             $disable_xss = true;
         }
         $this->addErrorMessage($e->getMessage(), null, $disable_xss);
     }
 }