',
// if it breaks remove stripslashes() and ENT_QUOTES
// "stripslashes('\\1').stripslashes(htmlspecialchars('\\2',ENT_QUOTES)).'\\3'",
// "stripslashes('\\1').stripslashes(htmlspecialchars('\\2',ENT_QUOTES)).'\\3'",
);
$arg = preg_replace($patterns,$replaces,$arg);
return $arg;
}
function postLJChallenge($INTERFACE)
{
$client = new IXR_Client($INTERFACE);
$s = $client->query('LJ.XMLRPC.getchallenge');
if(!$s)
{
die('postChallenge : Something went wrong - '.$client->getErrorCode().' : '.$client->getErrorMessage());
}
return $client->getResponse();
}
function challengeMD5($pass,$results)
{
return md5($results['challenge'].md5($pass));
}
function constructResponse($username,$safeword,$results,$postdata)
{
// This is where you can reformat post information and set privacy levels.
$options =
array(
// Change the 'taglist' to change the tags the post will display.
'taglist'=>"add tags,delicious links"
,'opt_preformatted'=>true
// This sets the Icon, and is CaSe sEnSitIve.
,'picture_keyword'=>"Webstuff"
);
$event = $postdata;
// Change the timezone for your purposes, list available at http://www.php.net/manual/en/timezones.php
$tz = new DateTimeZone('Europe/London');
$date = new DateTime();
$date->setTimezone($tz);
$year = $date->format('Y');
$mon = $date->format('n');
$day = $date->format('j');
$hour = $date->format('G');
$min = $date->format('i');
// The post Subject, reorder/reword at will but make sure ' symbols surround all text.
$subject= 'Interesting Links for '.$mon.'-'.$day.'-'.$year;
// $security='usemask'
// $allowmask='0'
$r =
array(
'username'=>$username,
'auth_method' => 'challenge',
'auth_challenge' => $results['challenge'],
'auth_response' => $safeword,
// 'security' => $security,
// 'allowmask' => $allowmask,
'event' => $event,
'subject' => $subject,
'year' => $year,
'mon' => $mon,
'day' => $day,
'hour' => $hour,
'min' => $min,
'props' => $options
);
return $r;
}
function postLJResponse($response,$INTERFACE)
{
$client = new IXR_Client($INTERFACE);
$p = $client->query('LJ.XMLRPC.postevent',$response);
if(!$p)
{
die('postLJResponse : Something went wrong - '.$client->getErrorCode().' : '.$client->getErrorMessage().'
\n\n'.print_r($response));
}
return $client->getResponse();
}
function newPost($args)
{
$INTERFACE=getInterface();
$username=$args[1];
$pass=$args[2];
$junk=$args[3]['description'];
file_put_contents("filetest/junk.txt",$junk);
$junk=fixPost($junk);
file_put_contents("filetest/junkafter.txt",$junk);
$challenge=postLJChallenge($INTERFACE);
$safeword=challengeMD5($pass,$challenge);
$response=constructResponse($username,$safeword,$challenge,$junk);
$retval=postLJResponse($response,$INTERFACE);
return $retval['anum'];
}
function getInterface()
{
$s='http://www.dreamwidth.org/interface/xmlrpc';
return $s;
}
$server = new IXR_Server(
array(
'metaWeblog.newPost' => 'newPost'
)
);
?>