|
|
<?php
|
|
|
|
|
|
require_once('include/admin.inc.php');
|
|
|
|
|
|
auth_redirect(); // Require logged in user to access this page.
|
|
|
|
|
|
|
|
|
if('post_twitter' == $_REQUEST['action'])
|
|
|
{
|
|
|
check_nonce('new-twitter');
|
|
|
|
|
|
$postmessage = '';
|
|
|
if(!empty($_REQUEST['stdmessage']) ) $postmessage = trim($_REQUEST['stdmessage']);
|
|
|
if( strlen($_REQUEST['message']) ) $postmessage = trim($_REQUEST['message']);
|
|
|
|
|
|
#string replacement macros
|
|
|
$next_strip_id = $mtdb->getOne( 'SELECT MAX(id) FROM strip' );
|
|
|
$next_strip_id += 1;
|
|
|
$postmessage = str_replace("#nextcomic", $next_strip_id, $postmessage);
|
|
|
|
|
|
if('' == $postmessage) _redirect( ADMIN_PATH . '/post-twitter.php?tweet=missing');
|
|
|
$username = sanitize_username($_REQUEST['twitter_user']);
|
|
|
$postasuser = $mtdb->getOne( sprintf('SELECT username FROM twitter_user WHERE username="%s"', mysqli_real_escape_string($mtdb->link, $username)));
|
|
|
|
|
|
if( in_array('twitter', $_REQUEST['service']) )
|
|
|
$rc = twitterpost( numeric_entities(utfentities($postmessage)), $postasuser );
|
|
|
if( in_array('rss', $_REQUEST['service']) )
|
|
|
$rc = rsspost( numeric_entities(utfentities($postmessage)), SITE_HOST.SITE_PATH );
|
|
|
|
|
|
if($rc) _redirect( ADMIN_PATH . '/post-twitter.php?tweet=success');
|
|
|
_redirect( ADMIN_PATH . '/post-twitter.php?tweet=fail');
|
|
|
|
|
|
// Shall not pass, all routes lead to redirect.
|
|
|
}
|
|
|
|
|
|
if( isset($_REQUEST['tweet']) && 'success' == $_REQUEST['tweet'] )
|
|
|
$info.='Status successfully posted to Twitter.';
|
|
|
|
|
|
if( isset($_REQUEST['tweet']) && 'fail' == $_REQUEST['tweet'] )
|
|
|
$info.='Status could not be posted to Twitter. Is it up?';
|
|
|
|
|
|
if( isset($_REQUEST['tweet']) && 'missing' == $_REQUEST['tweet'] )
|
|
|
$error.='Oops~ Looks like you forgot to enter a message.';
|
|
|
|
|
|
|
|
|
$statuses = $mtdb->getAll('SELECT id, position, message FROM twitter_status ORDER BY position, id');
|
|
|
$twitter_users = $mtdb->getAll('SELECT id, username, oauth_token, oauth_token_secret, oauth_access_token FROM twitter_user ORDER BY username');
|
|
|
|
|
|
adminhead('Update Twitter');
|
|
|
adminmenu();
|
|
|
|
|
|
?>
|
|
|
|
|
|
<h2>Update Twitter</h2>
|
|
|
<form name="statusform" method="post" action="post-twitter.php">
|
|
|
<?php nonce_field('new-twitter'); ?>
|
|
|
<input type="hidden" name="action" value="post_twitter" />
|
|
|
<script type="text/javascript" src="<?php echo SITE_HOST.SITE_PATH; ?>/resources.js"></script>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
<p>Post As: <select name="twitter_user">
|
|
|
<?php foreach($twitter_users as $k=>$v) {
|
|
|
printf( '<option %s value="%s">%s</option>', ($v->username == TWITTER_USER ? 'selected="selected"' : '') , htmlentities($v->username), htmlentities($v->username) );
|
|
|
}
|
|
|
?>
|
|
|
</select>
|
|
|
<a href="manage-twitter-users.php">Edit</a>
|
|
|
</p>
|
|
|
<p>Message Preset: <select name="stdmessage" onChange="copyPreset()">
|
|
|
<option value=""></option>
|
|
|
<!-- TODO: Javascript to copy the preset downward, so it can be edited. -->
|
|
|
<?php foreach($statuses as $k=>$v) {
|
|
|
printf( '<option value="%s">%s</option>', htmlentities($v->message), htmlentities($v->message) );
|
|
|
} ?>
|
|
|
</select>
|
|
|
<a href="manage-twitter-presets.php">Edit</a>
|
|
|
</p>
|
|
|
<p><textarea cols="70" rows="2" id="statusmessage" name="message" maxlength="140" size="140" onKeyDown="charCounter();" onKeyUp="charCounter();"></textarea> <input type="submit" value="Send" /></p>
|
|
|
<p style="padding-bottom:1em;">Characters remaining: <span id="charactersremaining">140</span>
|
|
|
<p>
|
|
|
Post to:
|
|
|
<label><input type="checkbox" name="service[]" value="twitter" selected="selected" checked="checked" /> Twitter</label>
|
|
|
<label><input type="checkbox" name="service[]" value="rss" /> RSS</label>
|
|
|
</p>
|
|
|
</form>
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
<!--
|
|
|
function copyPreset() {
|
|
|
var preset = document.statusform.stdmessage;
|
|
|
var status = document.statusform.message
|
|
|
status.value = preset.options[preset.selectedIndex].value
|
|
|
charCounter()
|
|
|
}
|
|
|
function charCounter() {
|
|
|
var status = document.statusform.message
|
|
|
var charactersremaining = document.getElementById('charactersremaining');
|
|
|
charactersremaining.innerHTML = 140 - status.value.length
|
|
|
}
|
|
|
-->
|
|
|
</script>
|
|
|
|
|
|
<?php /*?>
|
|
|
<script type="text/javascript" src="http://twitter.com/statuses/user_timeline/<?php echo TWITTER_USER; ?>.json?callback=mtCallback&count=3"></script> */ ?>
|
|
|
|
|
|
<hr/>
|
|
|
<script src="http://widgets.twimg.com/j/2/widget.js"></script>
|
|
|
<table border="0"><tr>
|
|
|
<?php foreach($twitter_users as $k=>$v) { ?>
|
|
|
<td>
|
|
|
<script>
|
|
|
new TWTR.Widget({
|
|
|
version: 2,
|
|
|
type: 'profile',
|
|
|
rpp: 4,
|
|
|
interval: 6000,
|
|
|
width: 250,
|
|
|
height: 300,
|
|
|
theme: {
|
|
|
shell: {
|
|
|
background: '#ffffff',
|
|
|
color: '#000000'
|
|
|
},
|
|
|
tweets: {
|
|
|
background: '#f9fcfc',
|
|
|
color: '#000000',
|
|
|
links: '#0000ff'
|
|
|
}
|
|
|
},
|
|
|
features: {
|
|
|
scrollbar: false,
|
|
|
loop: false,
|
|
|
live: false,
|
|
|
hashtags: true,
|
|
|
timestamp: true,
|
|
|
avatars: false,
|
|
|
behavior: 'all'
|
|
|
}
|
|
|
}).render().setUser('<?php echo $v->username; ?>').start();
|
|
|
</script>
|
|
|
</td>
|
|
|
<?php } ?>
|
|
|
</tr></table>
|
|
|
|
|
|
<?php
|
|
|
adminfooter();
|
|
|
?>
|
|
|
|