<?php require dirname(__FILE__) . '/../../../fx.php'; // Are we logged in? if (strlen(User::cGet('id')) == 0 or strlen(User::cGet('oat')) == 0 or strlen(User::cGet('oats')) == 0) { Redirect('/account/signin'); } $data = array('user' => User::Get(), 'message' => ' '); if (!empty($_POST['save'])) { $pattern = '/^([a-z0-9\\+])(([-a-z0-9\\+._])*([a-z0-9\\+]))*\\@([a-z0-9])(([a-z0-9-])*([a-z0-9]))+(\\.([a-z0-9])([-a-z0-9_-])?([a-z0-9])+)+$/i'; if (!preg_match($pattern, $_POST['email'])) { $data['message'] = '<span style="color:red;">Save failed: Invalid email address; please try again.</span>'; } else { $replies = array(); $replies['status'] = trim($_POST['status']) == 'active' ? 'active' : 'inactive'; $replies['email'] = trim($_POST['email']); $replies['min_interval'] = intval($_POST['min_interval']) * 60; $replies['max_queued'] = intval($_POST['max_queued']); $replies['replies_only'] = empty($_POST['replies_only']) ? 0 : 1; $replies['ignore_self'] = empty($_POST['ignore_self']) ? 0 : 1; $result = User::UpdateService('replies', $data['user'], $replies); if ($result === true) { $data['message'] = 'Changes saved <strong>successfully</strong>'; } else { $data['message'] = '<span style="color:red;">Save failed: ' . $result . '</span>'; } } } $data['replies'] = User::GetServices($data['user'], 'replies'); Layout('Replies', 'account'); if ($data['replies'] === false) {
<?php require dirname(__FILE__) . '/../../fx.php'; $url = ParseURL(2); // Has oauth registration been requested? if (!empty($url[0]) and $url[0] == 'oauth') { if (!empty($_REQUEST['oauth_token'])) { // Create TwitterOAuth object with app key/secret and token key/secret from default phase $to = new TwitterOAuth(config('oauth', 'consumer_key'), config('oauth', 'consumer_secret'), User::cGet('ort'), User::cGet('orts')); // Request access tokens from twitter $tok = $to->getAccessToken(); // Save the access tokens User::cSet('oat', $tok['oauth_token']); User::cSet('oats', $tok['oauth_token_secret']); // Create TwitterOAuth with app key/secret and user access key/secret $to = new TwitterOAuth(config('oauth', 'consumer_key'), config('oauth', 'consumer_secret'), User::cGet('oat'), User::cGet('oats')); // Run request on twitter API as user to get their user details $user = json_decode($to->OAuthRequest('https://twitter.com/account/verify_credentials.json', array(), 'GET'), true); // Store the user ID in the cookie User::cSet('id', $user['id']); // Now save the user in the DB User::Update($user, true); // Tell me about it //@mail('*****@*****.**', 'TwitApps signin: '.$user['screen_name'], print_r($user, true)); // Take them to the account page Redirect('/account/'); } else { $to = new TwitterOAuth(config('oauth', 'consumer_key'), config('oauth', 'consumer_secret')); $tok = $to->getRequestToken(); User::cSet('ort', $tok['oauth_token']); User::cSet('orts', $tok['oauth_token_secret']);