]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - scripts/importtwitteratom.php
Make attachment fit better in notice: drop text and link
[quix0rs-gnu-social.git] / scripts / importtwitteratom.php
index a29526f27e1726f57f3679dcdab034fbf4350614..0cfcba04244fc350a4d450e61fc6b3762245bed4 100755 (executable)
@@ -18,7 +18,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
+define('INSTALLDIR', dirname(__DIR__));
+define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public');
 
 $shortoptions = 'i:n:f:';
 $longoptions = array('id=', 'nickname=', 'file=');
@@ -34,7 +35,6 @@ import an Atom feed from Twitter as notices by a user
 END_OF_IMPORTTWITTERATOM_HELP;
 
 require_once INSTALLDIR.'/scripts/commandline.inc';
-require_once INSTALLDIR.'/extlib/htmLawed/htmLawed.php';
 
 function getAtomFeedDocument()
 {
@@ -82,12 +82,7 @@ function importActivityStream($user, $doc)
         if (!have_option('q', 'quiet')) {
             print $activity->content . "\n";
         }
-        $html = getTweetHtml($object->link);
-
-        $config = array('safe' => 1,
-                        'deny_attribute' => 'class,rel,id,style,on*');
-
-        $html = htmLawed($html, $config);
+        $html = common_purify(getTweetHtml($object->link));
 
         $content = html_entity_decode(strip_tags($html), ENT_QUOTES, 'UTF-8');
 
@@ -108,7 +103,7 @@ function getTweetHtml($url)
     try {
         $client = new HTTPClient();
         $response = $client->get($url);
-    } catch (HTTP_Request2_Exception $e) {
+    } catch (Exception $e) {
         print "ERROR: HTTP response " . $e->getMessage() . "\n";
         return false;
     }