diff --git a/callback.php b/callback.php index b2dc9025..76b1e4ba 100644 --- a/callback.php +++ b/callback.php @@ -16,6 +16,12 @@ header('Location: ./clearsessions.php'); } +if(!defined('CONSUMER_KEY') || !defined('CONSUMER_SECRET')){ + die('Consumer key and/or secret were not specified. Please check your configuration file, ' . + 'or if you were setting up Tweet Nest, please provide these values before authenticating. ' . + 'You can create them at dev.twitter.com.'); +} + /* Create TwitteroAuth object with app key/secret and token key/secret from default phase */ $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']); diff --git a/setup.php b/setup.php index 79854acf..400d9ff6 100644 --- a/setup.php +++ b/setup.php @@ -105,14 +105,14 @@ function configSetting($cf, $setting, $value){ $config = array(); } - $config['consumer_key'] = $_POST['consumer_key']; - $config['consumer_secret'] = $_POST['consumer_secret']; + $config['consumer_key'] = $_SESSION['entered_consumer_key'] = $_POST['consumer_key']; + $config['consumer_secret'] = $_SESSION['entered_consumer_secret'] = $_POST['consumer_secret']; require 'redirect.php'; exit; } else { $e[] = 'Please fill in your Twitter app consumer key and secret before authenticating with Twitter. ' . - 'You can get these by creating an app at dev.twitter.com.'; + 'You can get these by creating an app at dev.twitter.com.'; } } @@ -134,7 +134,7 @@ function configSetting($cf, $setting, $value){ $e[] = "The two typed admin passwords didn’t match. Please make sure they’re the same."; } if (!isset($_SESSION['access_token'])) { - $e[] = "You must authorize Tweetnest to use your Twitter account before continuing."; + $e[] = "You must authorize Tweet Nest to use your Twitter account before continuing."; } $sPath = "/" . trim($_POST['path'], "/"); $log[] = "Formatted path: " . $sPath; @@ -235,6 +235,23 @@ function configSetting($cf, $setting, $value){ $e[] = "Not all required fields were filled in!"; } } + + // Form preparation + $enteredConsumerKey = ''; + $enteredConsumerSecret = ''; + + if(isset($_SESSION['entered_consumer_key']) && !empty($_SESSION['entered_consumer_key'])){ + $enteredConsumerKey = $_SESSION['entered_consumer_key']; + } + if(isset($_SESSION['entered_consumer_secret']) && !empty($_SESSION['entered_consumer_secret'])){ + $enteredConsumerSecret = $_SESSION['entered_consumer_secret']; + } + if($post && isset($_POST['consumer_key']) && !empty($_POST['consumer_key'])){ + $enteredConsumerKey = $_POST['consumer_key']; + } + if($post && isset($_POST['consumer_secret']) && !empty($_POST['consumer_secret'])){ + $enteredConsumerSecret = $_POST['consumer_secret']; + } ?> @@ -598,7 +615,7 @@ function configSetting($cf, $setting, $value){