This repository has been archived by the owner on Mar 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.php
96 lines (86 loc) · 3.53 KB
/
admin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
add_action('admin_menu', 'twitter_authenticate_menu');
function twitter_authenticate_menu()
{
add_submenu_page('options-general.php', 'Twitter user authenticate', 'Twitter user authenticate', 'manage_options',
'twitter_authenticate/admin.php', 'showadminpage');
}
function showadminpage()
{
if ( isset($_POST['submit']) )
{
if ( function_exists('current_user_can') && !current_user_can('manage_options') )
die('No cheating, please!');
$consumer_key = $_POST['consumer_key'];
$consumer_secret = $_POST['consumer_secret'];
$username = $_POST['username'];
$settings = $_POST['settings'];
update_option('twitter_authenticate_consumer_key', $consumer_key);
update_option('twitter_authenticate_consumer_secret', $consumer_secret);
update_option("twitter_authenticate_username", $username);
update_option("twitter_authenticate_settings", $settings);
echo '<span style="color: red">Options saved!</span>'."<br />\n";
}else
{
$consumer_key = get_option("twitter_authenticate_consumer_key");
$consumer_secret = get_option("twitter_authenticate_consumer_secret");
$username = get_option("twitter_authenticate_username");
$settings = get_option("twitter_authenticate_settings");
}
//echo 'Twitter app settings:'."<br />\n";
?>
Steps:<br />
1. Write your article, but don't publish it.<br />
2. Set a password, it should be <span style="color: blue"><i>twitter</i></span><span style="color: red">blablabla</span> (Starting with "twitter", the following can be anything except nothing)<br />
3. Come to this page, fill in the following form.<br />
4. Publish your article.<br />
<br />
<?php
echo '<form action="" method="post">'."<br />\n";
echo 'Consumer Key:<input type="text" value="'.$consumer_key.'" name="consumer_key" />'."<br />\n";
echo 'Consumer Kecret:<input type="text" value="'.$consumer_secret.'" name="consumer_secret" />'."<br />\n";
echo 'My Twitter Username:<input type="text" value="'.$username.'" name="username" />'."<br />\n";
echo "<br />\nSettings:<br />\n";
echo '<textarea name="settings" rows="5" cols="50">'.$settings.'</textarea>'."<br />\n";
echo 'Format:<br />
<article id>, ifollow[, <forbidden usernames>]<br />
<article id>, user, <allowed usernames><br />
<article id>, inlist, <list name><br />
(Spaces are ignored. Forbidden/allowed usernames should be separated by "|".)<br />';
echo '<input type="submit" name="submit" value="Save" />'."<br />\n";
echo "</form><br /><br />";
$settings = str_replace(" ", "", $settings);
$array = explode("\n", $settings);
foreach($array as $row)
{
$row = trim($row);
$options = explode(",", $row);
echo $options[0];
$post = get_post($options[0]);
if(!$post)
{
echo " <span style=\"color: red\">Article not found!</span><br />\n";
continue;
}
echo " ".$post->post_title." ";
switch($options[1])
{
case "ifollow": echo "Users <i>".$username."</i> follows";
if(isset($options[2]))
echo " except <i>".str_replace("|", ", ", $options[2])."</i>";
break;
case "user": echo "Following users: <i>";
echo str_replace("|", ", ", $options[2]);
echo "</i>";
break;
case "inlist": echo "Users in list <i>".$options[2]."</i>";
break;
default: echo "<span style=\"color: red\">unknown</span>";
}
if(substr($post->post_password, 0, 7)!='twitter')
echo " <span style=\"color: red\">(Password isn't set correctly)</span>";
if($post->post_status!="publish")
echo " <span style=\"color: red\">(Wrong article status)</span>";
echo "<br />\n";
}
}