aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorFriendika <info@friendika.com>2011-09-11 21:52:50 -0700
committerFriendika <info@friendika.com>2011-09-11 21:52:50 -0700
commit17b081f9f79c30fb792912a884fd65984eb7c391 (patch)
treec41874c267bac89e3b718f883e52758a524cc29a /include
parent7a06c7c3bfcf4f496930efc8cef92f7dbe6f54a2 (diff)
downloadvolse-hubzilla-17b081f9f79c30fb792912a884fd65984eb7c391.tar.gz
volse-hubzilla-17b081f9f79c30fb792912a884fd65984eb7c391.tar.bz2
volse-hubzilla-17b081f9f79c30fb792912a884fd65984eb7c391.zip
allow html post to api
Diffstat (limited to 'include')
-rw-r--r--include/api.php28
1 files changed, 27 insertions, 1 deletions
diff --git a/include/api.php b/include/api.php
index 1f58a6baa..5d008c290 100644
--- a/include/api.php
+++ b/include/api.php
@@ -466,6 +466,7 @@
}
return null;
}
+
// TODO - media uploads
function api_statuses_update(&$a, $type) {
if (local_user()===false) return false;
@@ -475,7 +476,32 @@
// logger('api_post: ' . print_r($_POST,true));
- $_POST['body'] = urldecode(requestdata('status'));
+ if(requestdata('htmlstatus')) {
+ require_once('library/HTMLPurifier.auto.php');
+ require_once('include/html2bbcode.php');
+
+ $txt = requestdata('htmlstatus');
+ if((strpos($txt,'<') !== false) || (strpos($txt,'>') !== false)) {
+
+ $txt = preg_replace('#<object[^>]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?</object>#s',
+ '[youtube]$1[/youtube]', $txt);
+
+ $txt = preg_replace('#<iframe[^>].+?' . 'http://www.youtube.com/embed/([A-Za-z0-9\-_=]+).+?</iframe>#s',
+ '[youtube]$1[/youtube]', $txt);
+
+ $config = HTMLPurifier_Config::createDefault();
+ $config->set('Cache.DefinitionImpl', null);
+
+
+ $purifier = new HTMLPurifier($config);
+ $txt = $purifier->purify($txt);
+
+ $_POST['body'] = html2bbcode($txt);
+ }
+
+ }
+ else
+ $_POST['body'] = urldecode(requestdata('status'));
$parent = requestdata('in_reply_to_status_id');
if(ctype_digit($parent))