$server";
print " about $url...\n";
list ($resp, $status, $code) = curl_get($dest);
if ($code != 200 && $status)
print "$status: ";
if (!$resp) {
if ($code == 200)
print "Done.";
else
print "No response!";
}
print "$resp\n";
}
function curl_get($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
if ($error = curl_error($ch))
return array("$error.", "", 0);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$status_line = substr($response, 0, strcspn($response, "\n\r"));
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$body = substr($response, $header_size);
curl_close($ch);
return array($body, $status_line, $status_code);
}
if($content=$_POST['content']) {
// We know what to quote better than you PHP, thank you very much:
if(get_magic_quotes_gpc())
$content = stripslashes($content);
print "
Publishing your message...
\n";
// date('c') isn't implemented by PHP4:
$ts = date('Y-m-d\TH:i:s'). substr_replace(date('O'),':',3,0);
// SCRIPT_URI isn't present on all servers, so we do this instead:
$authority = "http://" . $_SERVER['HTTP_HOST'];
$root = $authority . dirname(dirname($_SERVER['SCRIPT_NAME']));
$post = "$root/data/$ts";
$ex = new SIOCExporter();
$user = new SIOCUser($sioc_nick, "$root/user/$sioc_nick", 'name', 'mail', 'page', $foaf_uri, '', '', '', $foaf_url);
$ex->addObject(new SIOCPost($post, $ts, $content, '', $user, $ts, '', '', '', 'sioct:MicroblogPost'));
$rdf = $ex->makeRDF();
$f = fopen(dirname(__FILE__)."/../data/$ts.rdf", 'w');
fwrite($f, $rdf);
fclose($f);
print "\n";
if($_POST['servers']) {
foreach($_POST['servers'] as $k => $server) {
print "- ";
send_data("$post.rdf", $server);
print "
\n- ";
// The FOAF file should not be sent everytime - fix it
send_data($foaf_url, $server);
print "
\n";
}
}
if($_POST['twitter']) {
print "- Relaying your message to Twitter as $twitter_user.\n";
twitter_post($content, $twitter_user, $twitter_pass);
print "
";
}
if($_POST['laconica']) {
foreach($_POST['laconica'] as $service => $v) {
$user = $laconica[$service];
$laconica_user = $user['user'];
$laconica_pass = $user['pass'];
print "- Relaying your message to $service as $laconica_user.\n";
laconica_post($service, $content, $laconica_user, $laconica_pass);
print "
";
}
}
print "
\n";
}
?>
New content