3 if (($_POST["friendica_acct_name"] != '') && ($_POST["friendica_password"] != '')) {
4 setcookie("username", $_POST["friendica_acct_name"], time()+60*60*24*300);
5 setcookie("password", $_POST["friendica_password"], time()+60*60*24*300);
13 font-family: arial, Helvetica,sans-serif;
18 background-color: #729FCF;
34 background-color: #FFFF66;
44 if (isset($_GET['title'])) {
45 $title = $_GET['title'];
47 if (isset($_GET['text'])) {
48 $text = $_GET['text'];
50 if (isset($_GET['url'])) {
54 if ((isset($title)) && (isset($text)) && (isset($url))) {
55 $content = "$title\nsource:$url\n\n$text";
57 $content = $_POST['content'];
60 if (isset($_POST['submit'])) {
62 if (($_POST["friendica_acct_name"] != '') && ($_POST["friendica_password"] != '')) {
63 $acctname = $_POST["friendica_acct_name"];
64 $tmp_account_array = explode("@", $acctname);
65 if (isset($tmp_account_array[1])) {
66 $username = $tmp_account_array[0];
67 $hostname = $tmp_account_array[1];
69 $password = $_POST["friendica_password"];
70 $content = $_POST["content"];
72 $url = "http://" . $hostname . '/api/statuses/update';
73 $data = array('status' => $content);
75 // echo "posting to: $url<br/>";
78 curl_setopt($c, CURLOPT_URL, $url);
79 curl_setopt($c, CURLOPT_USERPWD, "$username:$password");
80 curl_setopt($c, CURLOPT_POSTFIELDS, $data);
81 curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
82 curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
83 $c_result = curl_exec($c);
85 $error = curl_error($c);
86 showForm($error, $content);
91 echo '<script language="javascript" type="text/javascript">window.close();</script>';
95 $error = "Missing account name and/or password...try again please";
96 showForm($error, $content);
100 showForm(null, $content);
103 function showForm($error, $content) {
104 $username_cookie = $_COOKIE['username'];
105 $password_cookie = $_COOKIE['password'];
109 <h2><img class='logo' src='friendica-32.png' align='middle';/>
110 Friendica Bookmarklet</h2>
114 <form method="post" action="{$_SERVER['PHP_SELF']}">
115 Enter the email address of the Friendica Account that you want to cross-post to:(example: user@friendica.org)<br /><br />
116 Account ID: <input type="text" name="friendica_acct_name" value="{$username_cookie}" size="50"/><br />
117 Password: <input type="password" name="friendica_password" value="{$password_cookie}" size="50"/><br />
118 <textarea name="content" id="content" rows="6" cols="70">{$content}</textarea><br />
119 <input type="submit" value="PostIt!" name="submit" /> <span class='error'>$error</span>