2 if (!isset($_POST["friendika_acct_name"])) $_POST["friendika_acct_name"] = '';
3 if (!isset($_COOKIE['username'])) $_COOKIE['username'] = '';
4 if (!isset($_COOKIE['password'])) $_COOKIE['password'] = '';
5 if (!isset($hostname)) $hostname = '';
6 if (!isset($username)) $username = '';
9 if (($_POST["friendika_acct_name"] != '') && ($_POST["friendika_password"] != '')) {
10 setcookie("username", $_POST["friendika_acct_name"], time()+60*60*24*300);
11 setcookie("password", $_POST["friendika_password"], time()+60*60*24*300);
19 font-family: arial, Helvetica,sans-serif;
24 background-color: #000;
40 background-color: #FFFF66;
50 if (isset($_GET['title'])) {
51 $title = $_GET['title'];
53 if (isset($_GET['text'])) {
54 $text = $_GET['text'];
56 if (isset($_GET['url'])) {
60 if ((isset($title)) && (isset($text)) && (isset($url))) {
61 $content = "$title\nsource:$url\n\n$text";
63 $content = $_POST['content'];
66 if (isset($_POST['submit'])) {
68 if (($_POST["friendika_acct_name"] != '') && ($_POST["friendika_password"] != '')) {
69 $acctname = $_POST["friendika_acct_name"];
70 $tmp_account_array = explode("@", $acctname);
71 if (isset($tmp_account_array[1])) {
72 $username = $tmp_account_array[0];
73 $hostname = $tmp_account_array[1];
75 $password = $_POST["friendika_password"];
76 $content = $_POST["content"];
78 $url = "http://" . $hostname . '/api/statuses/update';
79 $data = array('status' => $content);
81 // echo "posting to: $url<br/>";
84 curl_setopt($c, CURLOPT_URL, $url);
85 curl_setopt($c, CURLOPT_USERPWD, "$username:$password");
86 curl_setopt($c, CURLOPT_POSTFIELDS, $data);
87 curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
88 curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
89 $c_result = curl_exec($c);
91 $error = curl_error($c);
92 showForm($error, $content);
97 echo '<script language="javascript" type="text/javascript">window.close();</script>';
101 $error = "Missing account name and/or password...try again please";
102 showForm($error, $content);
106 showForm(null, $content);
109 function showForm($error, $content) {
110 $username_cookie = $_COOKIE['username'];
111 $password_cookie = $_COOKIE['password'];
115 <h2><img class='logo' src='friendika-32.png' align='middle';/>
116 Friendica Bookmarklet</h2>
120 <form method="post" action="{$_SERVER['PHP_SELF']}">
121 Enter the email address of the Friendica Account that you want to cross-post to:(example: user@friendica.org)<br /><br />
122 Account ID: <input type="text" name="friendika_acct_name" value="{$username_cookie}" size="50"/><br />
123 Password: <input type="password" name="friendika_password" value="{$password_cookie}" size="50"/><br />
124 <textarea name="content" id="content" rows="6" cols="70">{$content}</textarea><br />
125 <input type="submit" value="PostIt!" name="submit" /> <span class='error'>$error</span>