diff --git a/inc/config.php b/inc/config.php index 5857c343..78d36e84 100644 --- a/inc/config.php +++ b/inc/config.php @@ -7,6 +7,8 @@ $config = array( // REQUIRED VALUES ------------------------------------ + 'consumer_key' => '', // Your Twitter app consumer key + 'consumer_secret' => '', // Your Twitter app consumer secret 'twitter_screenname' => '', // Your Twitter screen name 'twitter_token' => '', // Twitter oauth secret token 'twitter_token_secr' => '', // Twitter oauth token diff --git a/inc/twitteroauth/config.php b/inc/twitteroauth/config.php index 0439f357..3265040c 100644 --- a/inc/twitteroauth/config.php +++ b/inc/twitteroauth/config.php @@ -2,9 +2,9 @@ /** * @file - * A single location to store configuration. + * A single location to store configuration for TwitterOAuth. */ -define('CONSUMER_KEY', ''); -define('CONSUMER_SECRET', ''); +define('CONSUMER_KEY', $config['consumer_key']); +define('CONSUMER_SECRET', $config['consumer_secret']); define('OAUTH_CALLBACK', 'http://' . $_SERVER['SERVER_NAME'] . str_replace(basename($_SERVER['PHP_SELF']), "callback.php", $_SERVER['PHP_SELF'])); \ No newline at end of file diff --git a/setup.php b/setup.php index 7963b0cb..79854acf 100644 --- a/setup.php +++ b/setup.php @@ -93,9 +93,32 @@ function configSetting($cf, $setting, $value){ // Someone's submitting! Time to set up! if($post){ + + + // Are we redirecting? + if(isset($_POST['redirect']) && !empty($_POST['redirect'])){ + if( + isset($_POST['consumer_key']) && !empty($_POST['consumer_key']) && + isset($_POST['consumer_secret']) && !empty($_POST['consumer_secret']) + ){ + if(!isset($config) || !is_array($config)){ + $config = array(); + } + + $config['consumer_key'] = $_POST['consumer_key']; + $config['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.'; + } + } + $log[] = "Settings being submitted!"; $log[] = "PHP version: " . PHP_VERSION; - if(!empty($_POST['tz']) && !empty($_POST['path']) && !empty($_POST['db_hostname']) && !empty($_POST['db_username']) && !empty($_POST['db_database'])){ // Required fields + if(empty($e) && !empty($_POST['tz']) && !empty($_POST['path']) && !empty($_POST['db_hostname']) && !empty($_POST['db_username']) && !empty($_POST['db_database'])){ // Required fields $log[] = "All required fields filled in."; if(date_default_timezone_set($_POST['tz'])){ $log[] = "Valid time zone."; @@ -177,6 +200,8 @@ function configSetting($cf, $setting, $value){ if(!$e){ // WRITE THE CONFIG FILE, YAY! $cf = file_get_contents("inc/config.php"); + $cf = configSetting($cf, "consumer_key", $_POST['consumer_key']); + $cf = configSetting($cf, "consumer_secret", $_POST['consumer_secret']); $cf = configSetting($cf, "twitter_screenname", $_SESSION['access_token']['screen_name']); $cf = configSetting($cf, "twitter_token", $_SESSION['access_token']['oauth_token']); $cf = configSetting($cf, "twitter_token_secr", $_SESSION['access_token']['oauth_token_secret']); @@ -471,6 +496,10 @@ function configSetting($cf, $setting, $value){ input.submit:active { padding: 8px 15px 6px; } + + input[type=image] { + cursor: pointer; + } option.deselected { font-style: italic; @@ -516,6 +545,10 @@ function configSetting($cf, $setting, $value){ .explanation li { margin: 0 0 .5em; } + + .authorized { + color: #090; + } @@ -562,14 +595,24 @@ function configSetting($cf, $setting, $value){

Basic settings

Green color means the value is required
+
+ +
+
The consumer key of an app created and registered on dev.twitter.com.
+
+
+ +
+
The consumer secret of the above.
+
-
+
Sign in with Twitter'; + echo ''; } else { - echo 'Authorized'; // TODO prettify this + echo 'Authorized'; }?>
Authorize Tweetnest to access your twitter account.