X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=ljpost%2Fljpost.php;h=c8690c26e18a1a1bfbdc352d7824e778d31278b2;hb=fd9cfc7f31f93f23afc597622d75ee777db4e3ec;hp=8431b134d81cba6643f9552f6b4c0f547034d7dc;hpb=e57eb5d1986efce574a2c9d88e24fc05262cc8c5;p=friendica-addons.git diff --git a/ljpost/ljpost.php b/ljpost/ljpost.php old mode 100644 new mode 100755 index 8431b134..c8690c26 --- a/ljpost/ljpost.php +++ b/ljpost/ljpost.php @@ -4,8 +4,9 @@ * Name: LiveJournal Post Connector * Description: Post to LiveJournal * Version: 1.0 - * Author: Tony Baldwin + * Author: Tony Baldwin * Author: Michael Johnston + * Author: Cat Gray */ function ljpost_install() { @@ -89,7 +90,7 @@ function ljpost_settings(&$a,&$s) { /* provide a submit button */ - $s .= '
'; + $s .= '
'; } @@ -161,18 +162,25 @@ function ljpost_send(&$a,&$b) { if($x && strlen($x[0]['timezone'])) $tz = $x[0]['timezone']; - $lj_username = get_pconfig($b['uid'],'ljpost','lj_username'); - $lj_password = get_pconfig($b['uid'],'ljpost','lj_password'); - $lj_blog = 'http://www.livejournal.com/interface/xmlrpc'; + $lj_username = xmlify(get_pconfig($b['uid'],'ljpost','lj_username')); + $lj_password = xmlify(get_pconfig($b['uid'],'ljpost','lj_password')); + $lj_journal = xmlify(get_pconfig($b['uid'],'ljpost','lj_journal')); +// if(! $lj_journal) +// $lj_journal = $lj_username; + + $lj_blog = xmlify(get_pconfig($b['uid'],'ljpost','lj_blog')); + if(! strlen($lj_blog)) + $lj_blog = xmlify('http://www.livejournal.com/interface/xmlrpc'); if($lj_username && $lj_password && $lj_blog) { require_once('include/bbcode.php'); require_once('include/datetime.php'); - $title = $b['title']; + $title = xmlify($b['title']); $post = bbcode($b['body']); $post = xmlify($post); + $tags = ljpost_get_tags($b['tag']); $date = datetime_convert('UTC',$tz,$b['created'],'Y-m-d H:i:s'); $year = intval(substr($date,0,4)); @@ -183,28 +191,40 @@ function ljpost_send(&$a,&$b) { $xml = <<< EOT -LJ.XMLRPC.postevent - - -year$year -mon$mon -day$day -hour$hour -min$min -usejournal$lj_username -event$post -username$lj_username -password$lj_password -subject$title -lineendingsunix -ver1 -props - -useragentFriendica -taglistfriendica - - - + + LJ.XMLRPC.postevent + + + + username$lj_username + password$lj_password + event$post + subject$title + lineendingsunix + year$year + mon$mon + day$day + hour$hour + min$min + usejournal$lj_username + + props + + + + useragent + Friendica + + + taglist + $tags + + + + + + + EOT; @@ -212,9 +232,15 @@ EOT; logger('ljpost: data: ' . $xml, LOGGER_DATA); if($lj_blog !== 'test') - $x = post_url($lj_blog,$xml); + $x = post_url($lj_blog,$xml,array("Content-Type: text/xml")); logger('posted to livejournal: ' . ($x) ? $x : '', LOGGER_DEBUG); } } +function ljpost_get_tags($post) +{ + preg_match_all("/\]([^\[#]+)\[/",$post,$matches); + $tags = implode(', ',$matches[1]); + return $tags; +}