diaspora2bb, salmon fix argument error

This commit is contained in:
Friendika 2011-08-25 16:37:27 -07:00
parent 1b33ba6587
commit 21c03fb522
4 changed files with 25 additions and 56 deletions

View file

@ -7,7 +7,7 @@ require_once('include/text.php');
require_once("include/pgettext.php"); require_once("include/pgettext.php");
define ( 'FRIENDIKA_VERSION', '2.2.1082' ); define ( 'FRIENDIKA_VERSION', '2.2.1083' );
define ( 'DFRN_PROTOCOL_VERSION', '2.21' ); define ( 'DFRN_PROTOCOL_VERSION', '2.21' );
define ( 'DB_UPDATE_VERSION', 1082 ); define ( 'DB_UPDATE_VERSION', 1082 );

View file

@ -5,6 +5,25 @@ require_once('include/event.php');
function diaspora2bb($s) {
$s = str_replace(array('\\**','\\__','\\*','\\_'), array('-^doublestar^-','-^doublescore-^','-^star^-','-^score^-'),$s);
$s = preg_replace("/\*\*\*(.+?)\*\*\*/", '[b][i]$1[/i][/b]', $s);
$s = preg_replace("/\_\_\_(.+?)\_\_\_/", '[b][i]$1[/i][/b]', $s);
$s = preg_replace("/\*\*(.+?)\*\*/", '[b]$1[/b]', $s);
$s = preg_replace("/\_\_(.+?)\_\_/", '[b]$1[/b]', $s);
$s = preg_replace("/\*(.+?)\*/", '[i]$1[/i]', $s);
$s = preg_replace("/\_(.+?)\_/", '[i]$1[/i]', $s);
$s = str_replace(array('-^doublestar^-','-^doublescore-^','-^star^-','-^score^-'), array('**','__','*','_'), $s);
$s = preg_replace('/\[(.+?)\]\((.+?)\)/','[url=$2]$1[/url]',$s);
$s = escape_tags($s);
return $s;
}
function stripdcode_br_cb($s) { function stripdcode_br_cb($s) {
return '[code]' . str_replace('<br />', '', $s[1]) . '[/code]'; return '[code]' . str_replace('<br />', '', $s[1]) . '[/code]';
} }

View file

@ -435,32 +435,7 @@ function diaspora_post($importer,$xml) {
$created = unxmlify($xml->created_at); $created = unxmlify($xml->created_at);
$private = ((unxmlify($xml->public) == 'false') ? 1 : 0); $private = ((unxmlify($xml->public) == 'false') ? 1 : 0);
$body = unxmlify($xml->raw_message); $body = diaspora2bb($xml->raw_message);
require_once('library/HTMLPurifier.auto.php');
require_once('include/html2bbcode.php');
$maxlen = get_max_import_size();
if($maxlen && (strlen($body) > $maxlen))
$body = substr($body,0, $maxlen);
if((strpos($body,'<') !== false) || (strpos($body,'>') !== false)) {
$body = preg_replace('#<object[^>]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?</object>#s',
'[youtube]$1[/youtube]', $body);
$body = preg_replace('#<iframe[^>].+?' . 'http://www.youtube.com/embed/([A-Za-z0-9\-_=]+).+?</iframe>#s',
'[youtube]$1[/youtube]', $body);
$body = oembed_html2bbcode($body);
$config = HTMLPurifier_Config::createDefault();
$config->set('Cache.DefinitionImpl', null);
$purifier = new HTMLPurifier($config);
$body = $purifier->purify($body);
$body = html2bbcode($body);
}
$datarray = array(); $datarray = array();
$datarray['uid'] = $importer['uid']; $datarray['uid'] = $importer['uid'];
@ -558,32 +533,7 @@ function diaspora_comment($importer,$xml,$msg) {
// Phew! Everything checks out. Now create an item. // Phew! Everything checks out. Now create an item.
require_once('library/HTMLPurifier.auto.php'); $body = diaspora2bb($text);
require_once('include/html2bbcode.php');
$body = $text;
$maxlen = get_max_import_size();
if($maxlen && (strlen($body) > $maxlen))
$body = substr($body,0, $maxlen);
if((strpos($body,'<') !== false) || (strpos($body,'>') !== false)) {
$body = preg_replace('#<object[^>]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?</object>#s',
'[youtube]$1[/youtube]', $body);
$body = preg_replace('#<iframe[^>].+?' . 'http://www.youtube.com/embed/([A-Za-z0-9\-_=]+).+?</iframe>#s',
'[youtube]$1[/youtube]', $body);
$body = oembed_html2bbcode($body);
$config = HTMLPurifier_Config::createDefault();
$config->set('Cache.DefinitionImpl', null);
$purifier = new HTMLPurifier($config);
$body = $purifier->purify($body);
$body = html2bbcode($body);
}
$message_id = $diaspora_handle . ':' . $guid; $message_id = $diaspora_handle . ':' . $guid;

View file

@ -109,11 +109,11 @@ EOT;
$precomputed = '.YXBwbGljYXRpb24vYXRvbSt4bWw=.YmFzZTY0dXJs.UlNBLVNIQTI1Ng=='; $precomputed = '.YXBwbGljYXRpb24vYXRvbSt4bWw=.YmFzZTY0dXJs.UlNBLVNIQTI1Ng==';
$signature = base64url_encode(rsa_sign(str_replace('=','',$data . $precomputed),true),$owner['sprvkey']); $signature = base64url_encode(rsa_sign(str_replace('=','',$data . $precomputed),$owner['sprvkey']));
$signature2 = base64url_encode(rsa_sign($data . $precomputed),$owner['sprvkey']); $signature2 = base64url_encode(rsa_sign($data . $precomputed,$owner['sprvkey']));
$signature3 = base64url_encode(rsa_sign($data),$owner['sprvkey']); $signature3 = base64url_encode(rsa_sign($data,$owner['sprvkey']));
$salmon_tpl = get_markup_template('magicsig.tpl'); $salmon_tpl = get_markup_template('magicsig.tpl');