Configure the new TinyMCE to have almost the same buttons as the old one.
Configure the new TinyMCE to have almost the same buttons as the old one.

File last commit:

dc98d7eb2bb1
3cf3f8fd35f8
Show More
twitter.php
63 lines | 2.1 KiB | text/x-php | PhpLexer
<?php
function twitterpost($message, $user=TWITTER_USER, $password=TWITTER_PASS)
{
global $mtdb, $info, $error;
if( $user == '' ) {
# preserve existing twitterpost(message) style posting until OAuth has been vetted.
$user = TWITTER_USER;
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, TWITTER_HOST);
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_POST, 1);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=".urlencode($message));
curl_setopt($curl_handle, CURLOPT_USERPWD, urlencode($user).":".urlencode($password));
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
if(empty($buffer))
{
adminlog("Twitter post failed for user $user!", MTS_TWITTER, MTA_ADD);
}
return !empty($buffer);
} else {
# OAuth Mode
$row = $mtdb->getRow( sprintf('SELECT id, username, oauth_token, oauth_token_secret FROM twitter_user WHERE username="%s"', mysqli_real_escape_string($mtdb->link, $user)));
$username = $row->username;
$oauth_token = $row->oauth_token;
$oauth_token_secret = $row->oauth_token_secret;
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $oauth_token, $oauth_token_secret);
$parameters = array('status' => $message );
$status = $connection->post('statuses/update', $parameters);
switch( $connection->http_code ) {
case 200:
adminlog("Twitter post succeeded for user $username!", MTS_TWITTER, MTA_ADD);
return true;
default:
adminlog("Twitter post failed for user $username!", MTS_TWITTER, MTA_ADD);
return false;
}
}
}
function setOAuthTokens($userid,$oauth_token,$oauth_token_secret, $username) {
global $mtdb;
$id = (int)$userid;
if( $mtdb->query( sprintf('UPDATE twitter_user SET oauth_token="%s", oauth_token_secret="%s", username="%s" WHERE id=%d', mysqli_real_escape_string($mtdb->link, $oauth_token), mysqli_real_escape_string($mtdb->link, $oauth_token_secret), mysqli_real_escape_string($mtdb->link, $username), $id )) )
return true;
return false;
}
?>