public function authControl() { $config = Config::getInstance(); Utils::defineConstants(); $this->setViewTemplate( THINKUP_WEBAPP_PATH.'plugins/hellothinkup/view/hellothinkup.account.index.tpl'); $this->addToView('message', 'Hello, world! This is the example plugin configuration page for '.$this->owner->email .'.'); /** set option fields **/ // name text field $name_field = array('name' => 'testname', 'label' => 'Your Name'); // set an 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); return $this->generateView(); }
/** * Launch the crawler, if the latest crawler_last_run date is older than X minutes, then return a valid RSS feed. * @return string rendered view markup */ public function authControl() { Utils::defineConstants(); $this->setContentType('application/rss+xml; charset=UTF-8'); $this->setViewTemplate('rss.tpl'); $config = Config::getInstance(); $rss_crawler_refresh_rate = $config->getValue('rss_crawler_refresh_rate'); if (empty($rss_crawler_refresh_rate)) { $rss_crawler_refresh_rate = 20; // minutes } $protocol = isset($_SERVER['HTTPS']) ? 'https' : 'http'; $base_url = "{$protocol}://" . $_SERVER['HTTP_HOST'] . THINKUP_BASE_URL; $crawler_launched = false; $instance_dao = DAOFactory::getDAO('InstanceDAO'); $freshest_instance = $instance_dao->getInstanceFreshestOne(); $crawler_last_run = strtotime($freshest_instance->crawler_last_run); if ($crawler_last_run < time() - $rss_crawler_refresh_rate * 60) { $crawler_run_url = $base_url . 'run.php?' . ThinkUpAuthAPIController::getAuthParameters($this->getLoggedInUser()); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $crawler_run_url); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); // seconds curl_setopt($ch, CURLOPT_TIMEOUT, 5); // seconds curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, true); $result = curl_exec($ch); curl_close($ch); $body = substr($result, strpos($result, "\r\n\r\n") + 4); if (strpos($result, 'Content-Type: application/json') && function_exists('json_decode')) { $json = json_decode($body); if (isset($json->error)) { $crawler_launched = false; } else { if (isset($json->result) && $json->result == 'success') { $crawler_launched = true; } } } else { if (strpos($body, 'Error starting crawler') !== FALSE) { $crawler_launched = false; } else { $crawler_launched = true; } } } $items = array(); if ($crawler_launched) { $title = 'ThinkUp crawl started on ' . date('Y-m-d H:i:s'); $link = $base_url . 'rss.php?d=' . urlencode(date('Y-m-d H:i:s')); $description = "Last ThinkUp crawl ended on {$freshest_instance->crawler_last_run}<br />A new crawl " . "was started just now, since it's been more than {$rss_crawler_refresh_rate} minutes since the last run."; $items[] = self::createRSSItem($title, $link, $description); } $items = array_merge($items, $this->getAdditionalItems($base_url)); $this->addToView('items', $items); $this->addToView('logged_in_user', htmlspecialchars($this->getLoggedInUser())); $this->addToView('rss_crawler_refresh_rate', htmlspecialchars($rss_crawler_refresh_rate)); return $this->generateView(); }
public function authControl() { $config = Config::getInstance(); Utils::defineConstants(); $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); } return $this->generateView(); }
public function authControl() { $config = Config::getInstance(); Utils::defineConstants(); $this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/facebook/view/facebook.account.index.tpl'); /** set option fields **/ // Application ID text field $this->addPluginOption(self::FORM_TEXT_ELEMENT, array('name' => 'facebook_app_id', 'label' => 'Application ID')); // add element // set a special required message $this->addPluginOptionRequiredMessage('facebook_app_id', 'The Facebook plugin requires a valid Application ID.'); // API Key text field $this->addPluginOption(self::FORM_TEXT_ELEMENT, array('name' => 'facebook_api_key', 'label' => 'API Key')); // add element // set a special required message $this->addPluginOptionRequiredMessage('facebook_api_key', 'The Facebook plugin requires a valid API Key.'); // Application Secret text field $this->addPluginOption(self::FORM_TEXT_ELEMENT, array('name' => 'facebook_api_secret', 'label' => 'Application Secret')); // add element // set a special required message $this->addPluginOptionRequiredMessage('facebook_api_secret', 'The Facebook plugin requires a valid Application Secret.'); $plugin_option_dao = DAOFactory::getDAO('PluginOptionDAO'); $options = $plugin_option_dao->getOptionsHash('facebook', true); //get cached if (isset($options['facebook_app_id']->option_value) && isset($options['facebook_api_secret']->option_value)) { $this->setUpFacebookInteractions($options); } else { $this->addErrorMessage('Please set your Facebook API key, application ID and secret.'); } return $this->generateView(); }
public function authControl() { $config = Config::getInstance(); Utils::defineConstants(); $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); $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(); }
/** * 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; } } Utils::defineConstants(); $this->setViewTemplate(THINKUP_WEBAPP_PATH.'plugins/embedthread/view/v1.thread_js.tpl'); }
public function __construct() { $config = Config::getInstance(); if ($config->getValue('recaptcha_enable')) { $this->type = self::RECAPTCHA_CAPTCHA; Utils::defineConstants(); require_once THINKUP_WEBAPP_PATH . '_lib/extlib/recaptcha-php-1.10/recaptchalib.php'; } else { $this->type = self::THINKUP_CAPTCHA; } }
public function __construct($session_started = false) { parent::__construct($session_started); $config = Config::getInstance(); Utils::defineConstants(); $this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/facebook/view/auth.tpl'); $this->setPageTitle('Authorizing Your Facebook Account'); if (!isset($_GET['sessionKey']) || $_GET['sessionKey'] == '') { $this->addErrorMessage('No session key specified.'); $this->is_missing_param = true; } }
/** * Generates the calling JavaScript to create embedded thread on calling page. * @return str JavaScript source */ public function control() { Utils::defineConstants(); $this->setViewTemplate(THINKUP_WEBAPP_PATH.'plugins/embedthread/view/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(); }
public function __construct($session_started = false) { //Explicitly set TZ (before we have user's choice) to avoid date() warning about using system settings date_default_timezone_set('America/Los_Angeles'); Utils::defineConstants(); //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' => THINKUP_BASE_URL, 'source_root_path' => THINKUP_ROOT_PATH, 'debug' => false, 'app_title' => "ThinkUp", 'cache_pages' => false); $this->view_mgr = new SmartyThinkUp($cfg_array); $this->setPageTitle('Install ThinkUp'); $this->disableCaching(); }
public function authControl() { $config = Config::getInstance(); Utils::defineConstants(); $this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/expandurls/view/expandurls.account.index.tpl'); $links_to_expand = array('name' => 'links_to_expand', 'label' => 'Links to expand per crawl', 'default_value' => 1500); $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', 'label' => 'Flickr API key (<a href="http://www.flickr.com/services/api/keys/">Get it here</a>)')); // add element return $this->generateView(); }
public function authControl() { $config = Config::getInstance(); Utils::defineConstants(); $this->setViewTemplate( THINKUP_WEBAPP_PATH. 'plugins/expandurls/view/expandurls.account.index.tpl'); $links_to_expand = array( 'name' => 'links_to_expand', 'label' => 'Links to expand per crawl', 'default_value' => 1500 ); $this->addPluginOption(self::FORM_TEXT_ELEMENT, $links_to_expand); return $this->generateView(); }
public function authControl() { $this->disableCaching(); // we don't want to cache the rss link with api key as it can get updated Utils::defineConstants(); $this->setContentType('text/html; charset=UTF-8'); $this->setPageTitle("ThinkUp Crawler"); $this->setViewTemplate('crawler.updatenow.tpl'); $this->addInfoMessage('<b>Hint</b>: You can set up ThinkUp to update automatically. Visit ' . 'Settings → Account to find out how.'); if (isset($_GET['log']) && $_GET['log'] == 'full') { $this->addToView('log', 'full'); } return $this->generateView(); }
public function __construct() { $config = Config::getInstance(); $this->site_root = $config->getValue('site_root_path'); if ($config->getValue('recaptcha_enable')) { $this->type = 1; Utils::defineConstants(); require_once THINKUP_WEBAPP_PATH . '_lib/extlib/recaptcha-php-1.10/recaptchalib.php'; $this->pubkey = $config->getValue('recaptcha_public_key'); $this->prikey = $config->getValue('recaptcha_private_key'); } else { $this->type = 0; } }
public function authControl() { $config = Config::getInstance(); Utils::defineConstants(); $this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/flickrthumbnails/view/flickrthumbnails.account.index.tpl'); /** set option fields **/ // API key text field $this->addPluginOption(self::FORM_TEXT_ELEMENT, array('name' => 'flickr_api_key', 'label' => 'Your Flickr API key')); // add element $this->addPluginOptionHeader('flickr_api_key', 'Flickr API key (<a href="http://www.flickr.com/services/api/keys/">Get it here</a>)'); // set a special required message $this->addPluginOptionRequiredMessage('flickr_api_key', 'The Flickr Thumbnails plugin requires a valid API key.'); return $this->generateView(); }
/** * Constructor * @param array $vals Optional values to override file config * @return Config */ public function __construct($vals = null) { if ($vals != null) { $this->config = $vals; } else { Utils::defineConstants(); if (file_exists(THINKUP_WEBAPP_PATH . 'config.inc.php')) { require THINKUP_WEBAPP_PATH . 'config.inc.php'; $this->config = $THINKUP_CFG; } else { throw new Exception('ThinkUp\'s configuration file does not exist! Try <a href="' . THINKUP_BASE_URL . 'install/">installing ThinkUp.</a>'); } } }
public function __construct($session_started=false) { parent::__construct($session_started); $config = Config::getInstance(); Utils::defineConstants(); $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 (!isset($_SESSION['oauth_request_token_secret']) || $_SESSION['oauth_request_token_secret'] == '' ) { $this->addInfoMessage('Secret token not set.'); $this->is_missing_param = true; } }
public function authControl() { Utils::defineConstants(); if ($this->isAPICall()) { // If the request comes from an API call, output JSON instead of HTML $this->setContentType('application/json; charset=UTF-8'); } else { $this->setContentType('text/html; charset=UTF-8'); $this->setViewTemplate('crawler.run-top.tpl'); echo $this->generateView(); $config = Config::getInstance(); $config->setValue('log_location', false); //this forces output to just echo to page $logger = Logger::getInstance(); $logger->close(); } try { $logger = Logger::getInstance(); if (isset($_GET['log']) && $_GET['log'] == 'full') { $logger->setVerbosity(Logger::ALL_MSGS); echo '<pre style="font-family:Courier;font-size:10px;">'; } else { $logger->setVerbosity(Logger::USER_MSGS); $logger->enableHTMLOutput(); } $crawler = Crawler::getInstance(); //close session so that it's not locked by long crawl session_write_close(); $crawler->crawl(); $logger->close(); } catch (CrawlerLockedException $e) { if ($this->isAPICall()) { // Will be caught and handled in ThinkUpController::go() throw $e; } else { // Will appear in the textarea of the HTML page echo $e->getMessage(); } } if ($this->isAPICall()) { echo json_encode((object) array('result' => 'success')); } else { $this->setViewTemplate('crawler.run-bottom.tpl'); echo $this->generateView(); } }
public function authControl() { $config = Config::getInstance(); Utils::defineConstants(); $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(); }
/** * 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 { Utils::defineConstants(); if (file_exists(THINKUP_WEBAPP_PATH . 'config.inc.php')) { require THINKUP_WEBAPP_PATH . 'config.inc.php'; $this->config = $THINKUP_CFG; //set version info... require THINKUP_WEBAPP_PATH . 'install/version.php'; $this->config['THINKUP_VERSION'] = $THINKUP_VERSION; $this->config['THINKUP_VERSION_REQUIRED'] = array('php' => $THINKUP_VERSION_REQUIRED['php'], 'mysql' => $THINKUP_VERSION_REQUIRED['mysql']); } else { throw new Exception('ThinkUp\'s configuration file does not exist! Try <a href="' . THINKUP_BASE_URL . 'install/">installing ThinkUp.</a>'); } } }
public function authControl() { Utils::defineConstants(); if ($this->isAPICall()) { // If the request comes from an API call, output JSON instead of HTML $this->setContentType('application/json; charset=UTF-8'); } else { $this->setPageTitle("ThinkUp Crawler"); $this->setViewTemplate('crawler.run-top.tpl'); $whichphp = exec('which php'); $php_path = !empty($whichphp) ? $whichphp : 'php'; $this->addSuccessMessage('ThinkUp has just started to collect your posts. This is going to take a little ' . 'while, but if you want to see the technical details of what\'s going on, there\'s a log below. '); $rss_url = THINKUP_BASE_URL . 'rss.php?' . ThinkUpAuthAPIController::getAuthParameters($this->getLoggedInUser()); $this->addInfoMessage('<b>Hint</b><br />You can automate ThinkUp crawls by subscribing to ' . '<strong><a href="' . $rss_url . '" target="_blank">this RSS feed</a></strong> ' . 'in your favorite RSS reader.<br /><br /> Alternately, use the command below to set up a cron job that ' . 'runs hourly to update your posts. (Be sure to change yourpassword to your real password!)<br /><br />' . '<code style="font-family:Courier">cd ' . THINKUP_WEBAPP_PATH . 'crawler/;export THINKUP_PASSWORD=yourpassword; ' . $php_path . ' crawl.php ' . $this->getLoggedInUser() . '</code>'); echo $this->generateView(); echo '<br /><br /><textarea rows="65" cols="110">'; $config = Config::getInstance(); $config->setValue('log_location', false); //this forces output to just echo to page $logger = Logger::getInstance(); $logger->close(); // Will make sure any exception catched below appears as plain text, and not as HTML $this->setContentType('text/plain; charset=UTF-8'); } try { $crawler = Crawler::getInstance(); $crawler->crawl(); } catch (CrawlerLockedException $e) { if ($this->isAPICall()) { // Will be caught and handled in ThinkUpController::go() throw $e; } else { // Will appear in the textarea of the HTML page echo $e->getMessage(); } } if ($this->isAPICall()) { echo json_encode((object) array('result' => 'success')); } else { echo '</textarea>'; $this->setViewTemplate('crawler.run-bottom.tpl'); echo $this->generateView(); } }
public function authControl() { $config = Config::getInstance(); Utils::defineConstants(); $this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/geoencoder/view/geoencoder.account.index.tpl'); $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' => 'Enter Your Google Maps API Key'); $this->addPluginOption(self::FORM_TEXT_ELEMENT, $name_field); $this->addPluginOptionHeader('gmaps_api_key', 'GeoEncoder Plugin Options'); $this->addPluginOptionRequiredMessage('gmaps_api_key', 'Please enter your Google Maps API Key'); // distance_unit radio field $distance_unit_field = array('name' => 'distance_unit', 'label' => 'Select 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); 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); $_SESSION['ckey'] = md5($random_num); $img = rand(1, 4); Utils::defineConstants(); $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'); $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() { Utils::defineConstants(); $this->setContentType('text/html; charset=UTF-8'); $this->setPageTitle("ThinkUp Crawler"); $this->setViewTemplate('crawler.updatenow.tpl'); $whichphp = @exec('which php'); $php_path = (!empty($whichphp))?$whichphp:'php'; $rss_url = THINKUP_BASE_URL.'rss.php?'.ThinkUpAuthAPIController::getAuthParameters($this->getLoggedInUser()); $this->addInfoMessage('<b>Hint</b><br />You can automate ThinkUp crawls by subscribing to '. '<strong><a href="'.$rss_url.'" target="_blank">this RSS feed</a></strong> '. 'in your favorite RSS reader.<br /><br /> Alternately, use the command below to set up a cron job that '. 'runs hourly to update your posts. (Be sure to change yourpassword to your real password!)<br /><br />'. '<code style="font-family:Courier">cd '.THINKUP_WEBAPP_PATH. 'crawler/;export THINKUP_PASSWORD=yourpassword; '.$php_path.' crawl.php '.$this->getLoggedInUser(). '</code>'); if (isset($_GET['log']) && $_GET['log'] == 'full') { $this->addToView('log', 'full'); } return $this->generateView(); }
public function authControl() { $this->disableCaching(); // we don't want to cache the rss link with api key as it can get updated Utils::defineConstants(); $this->setContentType('text/html; charset=UTF-8'); $this->setPageTitle("ThinkUp Crawler"); $this->setViewTemplate('crawler.updatenow.tpl'); $whichphp = @exec('which php'); $php_path = !empty($whichphp) ? $whichphp : 'php'; $email = $this->getLoggedInUser(); $owner = parent::getOwner($email); $rss_url = THINKUP_BASE_URL . sprintf('rss.php?un=%s&as=%s', urlencode($email), $owner->api_key); $config = Config::getInstance(); $site_root_path = $config->getValue('site_root_path'); $this->addInfoMessage('<b>Hint</b><br />You can automate ThinkUp crawls by subscribing to ' . '<strong><a href="' . $rss_url . '" target="_blank">this secret RSS feed</a></strong> ' . 'in your favorite newsreader. Accidentally share the feed URL? ' . '<a href="' . $site_root_path . 'account/index.php?m=manage#instances">Reset it.</a>' . '<br /><br />Alternately, use the command below to set up a cron job that ' . 'runs hourly to update your posts. (Be sure to change yourpassword to your real password!)<br /><br />' . '<code style="font-family:Courier">cd ' . THINKUP_WEBAPP_PATH . 'crawler/;export THINKUP_PASSWORD=yourpassword; ' . $php_path . ' crawl.php ' . $this->getLoggedInUser() . '</code><br /><br /><a href="http://thinkupapp.com/docs/userguide/datacapture.html">Learn more about ' . 'how to update your ThinkUp data</a>.'); if (isset($_GET['log']) && $_GET['log'] == 'full') { $this->addToView('log', 'full'); } return $this->generateView(); }
public function authControl() { $config = Config::getInstance(); Utils::defineConstants(); $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); } return $this->generateView(); }
public function authControl() { $this->disableCaching(); Utils::defineConstants(); $config = Config::getInstance(); $thinkup_db_version = $config->getValue('THINKUP_VERSION'); $install_dao = DAOFactory::getDAO('InstallerDAO'); $db_version = self::getCurrentDBVersion($cached = false); $option_dao = DAOFactory::getDAO('OptionDAO'); // clear options session data $option_dao->clearSessionData(OptionDAO::APP_OPTIONS); if (isset($_GET['migration_index'])) { $migrations = $this->getMigrationList($db_version); $migration_index = $_GET['migration_index'] - 1; $migrations = $this->getMigrationList($db_version); $processed = false; $sql = $migrations[$migration_index]['sql']; try { $install_dao->runMigrationSQL($sql); $processed = true; $this->setJsonData(array('processed' => $processed, 'sql' => $sql)); } catch (Exception $e) { $this->setJsonData(array('processed' => $processed, 'message' => $e->getMessage(), 'sql' => $sql)); } } else { if (isset($_GET['migration_done'])) { $option = $option_dao->getOptionByName(OptionDAO::APP_OPTIONS, 'database_version'); if ($option) { $option_dao->updateOptionByName(OptionDAO::APP_OPTIONS, 'database_version', $thinkup_db_version); } else { $option_dao->insertOption(OptionDAO::APP_OPTIONS, 'database_version', $thinkup_db_version); } $this->setJsonData(array('migration_complete' => true)); $this->deleteTokenFile(); // remove snowflake in progress session if needed $this->snowflakeSession(false, true); } else { $this->setPageTitle('Upgrade the ThinkUp Database Structure'); $this->setViewTemplate('install.upgrade.tpl'); if (version_compare($db_version, $thinkup_db_version, '<')) { ## get migrations we need to run... $migrations = $this->getMigrationList($db_version); $this->addToView('migrations', $migrations); $this->addToView('migrations_json', json_encode($migrations)); if (isset($_GET['upgrade_token'])) { $this->addToView('upgrade_token', $_GET['upgrade_token']); } # no migrations needed, just update the application db version option to reflect if (count($migrations) == 0) { $option = $option_dao->getOptionByName(OptionDAO::APP_OPTIONS, 'database_version'); if ($option) { $option_dao->updateOptionByName(OptionDAO::APP_OPTIONS, 'database_version', $thinkup_db_version); } else { $option_dao->insertOption(OptionDAO::APP_OPTIONS, 'database_version', $thinkup_db_version); } $this->addToView('version_updated', true); $this->deleteTokenFile(); } } } } return $this->generateView(); }
public function getInstalledPlugins($plugin_path) { // Detect what plugins exist in the filesystem; parse their header comments for plugin metadata Utils::defineConstants(); $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); $installed_plugin = $this->parseFileContents($contents, $pf); if (isset($installed_plugin)) { // Insert or update plugin entries in the database if (!isset($installed_plugin->id)) { if ($this->insertPlugin($installed_plugin)) { $installed_plugin->id = $this->getPluginId($installed_plugin->folder_name); } else { $this->updatePlugin($installed_plugin); } } // 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); }
/** * 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) { if (!is_writable($this->compile_dir) || !is_writable($this->compile_dir . '/cache')) { Utils::defineConstants(); $whoami = @exec('whoami'); if (empty($whoami)) { $whoami = 'nobody'; } return str_replace(array('#THINKUP_BASE_URL#', '#WHOAMI#', '#COMPILE_DIR#'), array(THINKUP_BASE_URL, $whoami, $this->compile_dir), file_get_contents(THINKUP_WEBAPP_PATH . '_lib/view/500-perm.html')); } else { return parent::fetch($template, $cache_key, $compile_id, $display); } }
* ThinkUp/webapp/plugins/facebook/controller/facebook.php * * Copyright (c) 2009-2010 Gina Trapani * * 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 Gina Trapani <ginatrapani[at]gmail[dot]com> * @license http://www.gnu.org/licenses/gpl.html * @copyright 2009-2010 Gina Trapani */ Utils::defineConstants(); require_once THINKUP_WEBAPP_PATH . '_lib/extlib/facebook/facebook.php'; $webapp = Webapp::getInstance(); $webapp->registerPlugin('facebook', 'FacebookPlugin'); $webapp->registerPlugin('facebook page', 'FacebookPlugin'); $crawler = Crawler::getInstance(); $crawler->registerCrawlerPlugin('FacebookPlugin');