2017-05-25 21:55:34 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// Change these variables
|
2017-09-04 20:27:51 +02:00
|
|
|
$gnusocialuser = "@fsfe@quitter.no";
|
2017-05-25 23:43:37 +02:00
|
|
|
$twitteruser = "fsfe";
|
2017-05-25 21:55:34 +02:00
|
|
|
$flattruser = "fsfe";
|
|
|
|
$supporturl = "https://fsfe.org/donate?pmpc";
|
|
|
|
|
|
|
|
// Don't change below here
|
|
|
|
$service = isset($_GET['service']) ? $_GET['service'] : false;
|
|
|
|
$url = isset($_GET['url']) ? $_GET['url'] : false;
|
|
|
|
$title = isset($_GET['title']) ? $_GET['title'] : false;
|
|
|
|
$diasporapod = isset($_GET['diasporapod']) ? $_GET['diasporapod'] : false;
|
|
|
|
$gnusocialpod = isset($_GET['gnusocialpod']) ? $_GET['gnusocialpod'] : false;
|
|
|
|
|
|
|
|
if(empty($service) || empty($url)) {
|
|
|
|
echo 'At least one required variable is empty. You have to define at least service and url';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$service = htmlspecialchars($service);
|
|
|
|
$diasporapod = htmlspecialchars($diasporapod);
|
|
|
|
$gnusocialpod = htmlspecialchars($gnusocialpod);
|
2017-08-29 22:50:07 +02:00
|
|
|
$url = urlencode($url);
|
|
|
|
$title = urlencode($title);
|
2017-05-25 21:55:34 +02:00
|
|
|
|
|
|
|
if ($service === "diaspora") {
|
|
|
|
$diasporapod = validateurl($diasporapod);
|
|
|
|
echo $diasporapod;
|
|
|
|
header("Location: " . $diasporapod . "/bookmarklet?url=" . $url . "&title=" . $title);
|
|
|
|
die();
|
|
|
|
} elseif($service === "gnusocial") {
|
|
|
|
$gnusocialpod = validateurl($gnusocialpod);
|
2017-09-04 20:27:51 +02:00
|
|
|
header("Location: " . $gnusocialpod . "/notice/new?status_textarea=" . $title . " " . $url);
|
2017-05-25 21:55:34 +02:00
|
|
|
die();
|
|
|
|
} elseif($service === "reddit") {
|
|
|
|
header("Location: https://reddit.com/submit?url=" . $url . "&title=" . $title);
|
|
|
|
die();
|
|
|
|
} elseif($service === "flattr") {
|
|
|
|
header("Location: https://flattr.com/submit/auto?user_id=" . $flattruser . "&url=" . $url . "&title=" . $title);
|
|
|
|
die();
|
|
|
|
} elseif($service === "hnews") {
|
|
|
|
header("Location: https://news.ycombinator.com/submitlink?u=" . $url . "&t=" . $title);
|
|
|
|
die();
|
|
|
|
} elseif($service === "twitter") {
|
2017-09-04 20:27:51 +02:00
|
|
|
header("Location: https://twitter.com/share?url=" . $url . "&text=" . $title);
|
2017-05-25 21:55:34 +02:00
|
|
|
die();
|
|
|
|
} elseif($service === "facebook") {
|
|
|
|
header("Location: https://www.facebook.com/sharer/sharer.php?u=" . $url);
|
|
|
|
die();
|
|
|
|
} elseif($service === "gplus") {
|
|
|
|
header("Location: https://plus.google.com/share?url=" . $url);
|
|
|
|
die();
|
|
|
|
} elseif($service === "support") {
|
|
|
|
header("Location: " . $supporturl);
|
|
|
|
die();
|
|
|
|
} else {
|
|
|
|
echo 'Social network unknown.';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If diaspora/GS pod has been typed without http(s):// prefix, add it
|
|
|
|
function validateurl($url) {
|
|
|
|
if (preg_match('#^https?://#i', $url) === 0) {
|
|
|
|
return 'https://' . $url;
|
|
|
|
} else {
|
|
|
|
return $url;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|