[pumpio] Update config file style/name
[friendica-addons.git/.git] / ljpost / ljpost.php
index 97daf51..c60af03 100644 (file)
 use Friendica\Content\Text\BBCode;
 use Friendica\Core\Addon;
 use Friendica\Core\L10n;
+use Friendica\Core\Logger;
 use Friendica\Core\PConfig;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
+use Friendica\Util\XML;
 
 function ljpost_install() {
     Addon::registerHook('post_local',           'addon/ljpost/ljpost.php', 'ljpost_post_local');
@@ -54,7 +56,7 @@ function ljpost_settings(&$a,&$s) {
 
     /* Add our stylesheet to the page so we can make our settings look nice */
 
-    $a->page['htmlhead'] .= '<link rel="stylesheet"  type="text/css" href="' . $a->get_baseurl() . '/addon/ljpost/ljpost.css' . '" media="all" />' . "\r\n";
+    $a->page['htmlhead'] .= '<link rel="stylesheet"  type="text/css" href="' . $a->getBaseURL() . '/addon/ljpost/ljpost.css' . '" media="all" />' . "\r\n";
 
     /* Get the current state of our config variables */
 
@@ -131,7 +133,7 @@ function ljpost_post_local(&$a,&$b) {
 
        $lj_enable = (($lj_post && x($_REQUEST,'ljpost_enable')) ? intval($_REQUEST['ljpost_enable']) : 0);
 
-       if($_REQUEST['api_source'] && intval(PConfig::get(local_user(),'ljpost','post_by_default')))
+       if($b['api_source'] && intval(PConfig::get(local_user(),'ljpost','post_by_default')))
                $lj_enable = 1;
 
     if(! $lj_enable)
@@ -168,23 +170,20 @@ function ljpost_send(&$a,&$b) {
        if($x && strlen($x[0]['timezone']))
                $tz = $x[0]['timezone'];
 
-       $lj_username = xmlify(PConfig::get($b['uid'],'ljpost','lj_username'));
-       $lj_password = xmlify(PConfig::get($b['uid'],'ljpost','lj_password'));
-       $lj_journal = xmlify(PConfig::get($b['uid'],'ljpost','lj_journal'));
+       $lj_username = XML::escape(PConfig::get($b['uid'],'ljpost','lj_username'));
+       $lj_password = XML::escape(PConfig::get($b['uid'],'ljpost','lj_password'));
+       $lj_journal = XML::escape(PConfig::get($b['uid'],'ljpost','lj_journal'));
 //     if(! $lj_journal)
 //             $lj_journal = $lj_username;
 
-       $lj_blog = xmlify(PConfig::get($b['uid'],'ljpost','lj_blog'));
+       $lj_blog = XML::escape(PConfig::get($b['uid'],'ljpost','lj_blog'));
        if(! strlen($lj_blog))
-               $lj_blog = xmlify('http://www.livejournal.com/interface/xmlrpc');
+               $lj_blog = XML::escape('http://www.livejournal.com/interface/xmlrpc');
 
        if($lj_username && $lj_password && $lj_blog) {
-
-               require_once('include/bbcode.php');
-
-               $title = xmlify($b['title']);
+               $title = XML::escape($b['title']);
                $post = BBCode::convert($b['body']);
-               $post = xmlify($post);
+               $post = XML::escape($post);
                $tags = ljpost_get_tags($b['tag']);
 
                $date = DateTimeFormat::convert($b['created'], $tz);
@@ -234,12 +233,12 @@ function ljpost_send(&$a,&$b) {
 
 EOT;
 
-               logger('ljpost: data: ' . $xml, LOGGER_DATA);
+               Logger::log('ljpost: data: ' . $xml, Logger::DATA);
 
                if ($lj_blog !== 'test') {
-                       $x = Network::post($lj_blog, $xml, ["Content-Type: text/xml"]);
+                       $x = Network::post($lj_blog, $xml, ["Content-Type: text/xml"])->getBody();
                }
-               logger('posted to livejournal: ' . ($x) ? $x : '', LOGGER_DEBUG);
+               Logger::log('posted to livejournal: ' . ($x) ? $x : '', Logger::DEBUG);
        }
 }