Convert html to vbcode and post to vbulletin
using vbulletin files :
-
-
require_once( './global.php');
-
-
using external function :
-
-
function html2vb($html){
-
'/\<div align=\"([^\"]+)\".*?\>(.*?)\<\/div\>/is',
-
'/\<(\/?)(?:b|strong)\>/is',
-
'/\<(\/?)(i|u)\>/is',
-
'/\<(\/?)ul\>/is',
-
'/\<li\>(.*?)\<\/li\>/is',
-
'/\<img(.*?) src=\"([^\"]+)\" (.*?)\>/is',
-
"/\<br[^>]*\>\n?/is",
-
'/\<a .*?href=\"(http:\/\/[^\"]+)\"(?:.*?)\>(.*?)\<\/a\>/is',
-
);
-
'[$1]$2[/$1]',
-
'[$1b]',
-
'[$1$2]',
-
'[$1list]',
-
'[*]$1′,
-
'[img]$2[/img]',
-
"\n",
-
'[url="$1"]$2[/url]',
-
);
-
-
-
-
$html = preg_replace('/\<font face=\"(.*?)\".*?\>(.*?)\<\/font\>/is', '[font="$1"]$2[/font]', $html);
-
-
-
// Strip HTML tags
-
-
return $html;
-
-
}
-
posting to vbulletin :
-
-
require_once( './global.php');
-
-
$post = "[i]hello world[/i]";
-
$vbulletin->options['postminchars'] = 1;
-
$itemdata =& datamanager_init('Thread_FirstPost', $vbulletin, $error_type, 'threadpost');
-
$itemdata->set('forumid', 2);
-
$itemdata->set('userid', 1);
-
$itemdata->set('title', 'post title' );
-
$itemdata->set('pagetext', $post);
-
$itemdata->set('visible', 1 );
-
$itemdata->set('allowsmilie', 1 );
-
$itemdata->set(’showsignature', 1 );
-
$itemdata->set('ipaddress', ”);
-
-
-
if ($itemid = $itemdata->save() )
-
{
-
$itemtitle = $itemdata->fetch_field('title');
-
$itemlink = FORUM_URL . "/showthread.php?t=$itemid";
-
}
-
-


December 27th, 2009 at 8:07 am
nice sharing