Skip to content

Commit

Permalink
Importing SVN r981
Browse files Browse the repository at this point in the history
  • Loading branch information
daris committed Oct 1, 2011
0 parents commit ece5714
Show file tree
Hide file tree
Showing 160 changed files with 8,546 additions and 0 deletions.
169 changes: 169 additions & 0 deletions ConnectixBoards/_config.php
@@ -0,0 +1,169 @@
<?php

// Settings, such as page title...
$settings = array(
'Title' => 'ConnectixBoards to FluxBB converter',
'Forum' => 'ConnectixBoards',
'Page' => '<b>ConnectixBoards to FluxBB</b> converter at page: ',
'db_def' => 'connectixboards',
'pre_def' => 'cb_'
);

// List of pages to go through
$parts = array(
'groups',
'users',
'categories',
'forums',
'topics',
'posts',
'bans',
'messages',
'polls',
'end'
);

$tables = array(
'Groups' => 'groups',
'Users' => 'users',
'Categories' => 'forums',
'Forums' => 'topicgroups',
'Topics' => 'topics',
'Posts' => 'messages',
'Polls' => 'polls',
'Messages' => 'mp',
);
$tablerem = array('Users' => 1);

include_once PUN_ROOT.'include/parser.php';

// Convert posts BB-code
function convert_posts($message)
{
$message = convert_to_utf8($message);

$message = str_replace("\n", '', $message);
$pattern = array(
// b, i, u, s and center
'#<!--b--><span class="b">#i',
'#</span><!--/b-->#i',
'#<!--i--><span class="i">#i',
'#</span><!--/i-->#i',
'#<!--u--><span class="u">#i',
'#</span><!--/u-->#i',
'#<!--s--><span class="s">#i',
'#</span><!--/u-->#i',
'#<!--center--><span class="center">#i',
'#</span><!--/center-->#i',

// Lists
'#<!--list(num)?--><(ul|ol)>#i',
'#</(ul|ol)><!--/list(num)?-->#i',
'#<li><span class="nodisplay">\[\*\]</span>#i',
'#</li>#i',

// Colors
'#<!--color=--><span style="color:\s*(.*?);?">#i',
'#</span><!--/color=-->#i',

// Images
'#<!--img--><img src="#i',
'#" alt="Posted Image" />(<!--/img-->)?#i',

// Smileys ans stuff
'#<img src="smileys\/.*?" alt="(.*?)" class="smiley" />#i',

//Links and emails
'#<!--url=--><a href="(.*?)">#i',
'#(<!--url-->)?<a href="(.*?)">#i',
'#<!--email--><a href="mailto:(.*?)">#i',
'#</a>(<!--/url=?-->)?#i',
'#</a><!--/email-->#i',

//Videos (ex: Youtube, Dailymotion)
'#<!--flash--><object type="application/x-shockwave-flash" data="(.*?)" width="560" height="436"><param name="quality" value="high" /><param name="movie" value="(.*?)" /></object><span class="nodisplay">\[flash\]\[/flash\]</span><!--/flash-->#i',
'#<!--youtube--><object width="425" height="350"><param name="movie" value="(.*?)"></param><param name="wmode" value="transparent"></param><embed src="(.*?)" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object><!--/youtube-->#i',

// Sizes
'#<!--size=--><span style="font-size:[0-9]{1,2}px;?">#i',
'#</span><!--/(size|font)=-->#i',
'#<!--font=--><span style="font-family:(.*?)">#i',

// Quotes och Code
'#<!--quote=?--><blockquote class="citationb?">(<p><span class="u">(.*?)</span></p>)?<p>#i',
'#</p></blockquote><!--/quote=?-->#i',
'#<!--(code|php)--><span class="code">(<p>)?<code>#i',
'#</code>(</p>)?</span><!--/(code|php)-->#i',

//Spoilers
'#<!--spoil--><span class="spoil"><span class="spoil_info" onclick="hideAndShow\(\'spoil[0-9a-f]{32}\'\);">Spoiler</span><span class="spoil_spoiler" id="spoil[0-9a-f]{32}">#i',
'#</span></span><script type="text/javascript">hideAndShow\(\'spoil[0-9a-f]{32}\'\);</script><!--/spoil-->#i',

'#<br />#i'
);
$replace = array(
// b, i, u, s and center
'[b]',
'[/b]',
'[i]',
'[/i]',
'[u]',
'[/u]',
'[s]',
'[/s]',
'',
'',

// Lists
'[list]',
'[/list]',
'[*]',
'[/*]',

// Colors
'[color=$1]',
'[/color]',

// Images
'[img]',
'[/img]',

// Smileys and stuff
'$1',

//Links and emails
'[url=$1]',
'[url]',
'[email=$1]',
'[/url]',
'[/email]',

//Videos (ex: youtube and dailymotion)
'[url]$1[/url]',
'[url]$1[/url]',

// Sizes and font family
'',
'',
'',

// Quotes och Code
'[quote]',
'[/quote]',
'[code]',
'[/code]',

//Spoilers
'[quote]',
'[/quote]',

"\n"
);
$errors = array();
return preparse_bbcode(preg_replace($pattern, $replace, $message), $errors);
}

function decode_ip($int_ip){
$hexipbang = explode('.', chunk_split($int_ip, 2, '.'));
return hexdec($hexipbang[0]). '.' . hexdec($hexipbang[1]) . '.' . hexdec($hexipbang[2]) . '.' . hexdec($hexipbang[3]);
}
7 changes: 7 additions & 0 deletions ConnectixBoards/_info.php
@@ -0,0 +1,7 @@
<?php

$info = array(
'version' => 'ConnectixBoards 0.8',
'note' => '',
'update' => '2011-05-09',
);
15 changes: 15 additions & 0 deletions ConnectixBoards/bans.php
@@ -0,0 +1,15 @@
<?php

$result = $fdb->query('SELECT * FROM '.$fdb->prefix.'banned') or myerror("Unable to get ban data");

while($ob = $fdb->fetch_assoc($result))
{
// Dataarray
$todb = array(
'ip' => ($ob['ban_ip'] == '') ? 'null' : long2ip($ob['ban_ip']),
'expire' => ($ob['ban_expires'] == '') ? 'null' : $ob['ban_expires']
);

// Save data
insertdata('bans', $todb, __FILE__, __LINE__);
}
34 changes: 34 additions & 0 deletions ConnectixBoards/categories.php
@@ -0,0 +1,34 @@
<?php
/* */
$cat_count = 0;
// Fetch forum info
$result = $fdb->query('SELECT * FROM '.$fdb->prefix.'forums') or myerror('Unable to fetch categories', __FILE__, __LINE__, $fdb->error());
while($ob = $fdb->fetch_assoc($result))
{
echo htmlspecialchars($ob['forum_name']).' ('.$ob['forum_id'].")<br>\n"; flush();

// Dataarray
$todb = array(
'id' => $ob['forum_id'],
'cat_name' => html_entity_decode(htmlspecialchars_decode($ob['forum_name']), ENT_QUOTES, 'UTF-8'),
'disp_position' => $ob['forum_order'],
);

// Save data
insertdata('categories', $todb, __FILE__, __LINE__);

$cat_count++;
}

// If there are not categories, add default
if ($cat_count == 0)
{
$todb = array(
'id' => 1,
'cat_name' => 'Default category',
'disp_position' => 1,
);

// Save data
insertdata('categories', $todb, __FILE__, __LINE__);
}
24 changes: 24 additions & 0 deletions ConnectixBoards/end.php
@@ -0,0 +1,24 @@
<?php

// Get CB config
echo "\n<br>Updating FluxBB settings<br/>"; flush();
$phpconfig = array();

$result = $fdb->query('SELECT cf_field, cf_value FROM '.$fdb->prefix.'config') or myerror('Unable to get forum info', __FILE__, __LINE__, $fdb->error());
while(list($name, $var) = $fdb->fetch_row($result))
$phpconfig[$name] = $var;

// Save fluxbb config
$config = array(
'o_board_title' => $phpconfig['forumname'],
'o_board_desc' => 'Sample board description',
'o_webmaster_email' => $phpconfig['supportmail'],
);
if (isset($phpconfig['defaulttimezone']))
$config['o_server_timezone'] = $phpconfig['defaulttimezone'];

while (list($conf_name, $conf_value) = @each($config))
$db->query('UPDATE '.$db->prefix.'config SET conf_value=\''.$db->escape($conf_value).'\' WHERE conf_name=\''.$conf_name.'\'') or myerror('Unable to save config: '.$conf_name.'='.$conf_value, __FILE__, __LINE__, $db->error());

// Load global 'end' file
require './end.php';
63 changes: 63 additions & 0 deletions ConnectixBoards/forums.php
@@ -0,0 +1,63 @@
<?php

// Fetch forum info
$cat_result = $db->query('SELECT c.id FROM '.$db->prefix.'categories AS c ORDER BY c.id') or myerror('FluxBB: Unable to get table: categories', __FILE__, __LINE__, $db->error());
$categories = array();
while($cur_cat = $db->fetch_assoc($cat_result))
$categories[] = $cur_cat['id'];

if (!$db->field_exists('forums', 'parent_forum_id'))
$db->add_field('forums', 'parent_forum_id', 'INT', true, 0);

// Fetch forum info
$result = $fdb->query('SELECT * FROM '.$fdb->prefix.'topicgroups WHERE tg_id>'.$start.' ORDER BY tg_id LIMIT '.$_SESSION['limit']) or myerror('Connectix Boards: Unable to get table: forums', __FILE__, __LINE__, $fdb->error());
$last_id = -1;
while($ob = $fdb->fetch_assoc($result))
{
$last_id = $ob['tg_id'];
echo htmlspecialchars($ob['tg_name']).' ('.$ob['tg_id'].")<br>\n"; flush();

// Check for anonymous poster id problem
// $ob['forum_last_post_id'] == -1 ? $ob['forum_last_post_id'] = 1 : null;
if ($ob['tg_lasttopic'] > 0)
{
$lastpostres = $fdb->query('SELECT t.topic_lastmessage, m.msg_id, m.msg_timestamp, m.msg_guest, m.msg_userid, u.usr_id, u.usr_name FROM '.$fdb->prefix.'topics AS t LEFT JOIN '.$fdb->prefix.'messages AS m ON t.topic_lastmessage=m.msg_id LEFT JOIN '.$fdb->prefix.'users AS u ON m.msg_userid=u.usr_id WHERE t.topic_id='.$ob['tg_lasttopic'].' ') or myerror("Unable to fetch forum last post infos for forum conversion.", __FILE__,__LINE__, $fdb->error());
$last_post = $fdb->fetch_assoc($lastpostres);

if ($last_post['msg_userid'] == 0)
$last_post['usr_name'] = $last_post['msg_guest'];
if ($last_post['usr_name'] == '')
$last_post['usr_name'] = $lang_common['Guest'];

// Change last_post = 0 to null to prevent the time-bug.
if (!isset($last_post['msg_timestamp']) || $last_post['msg_timestamp'] == 0)
$last_post['msg_timestamp'] = 'null';
if ($ob['tg_lasttopic'] == 0)
$ob['tg_lasttopic'] = 'null';

// Unset variables
if (!isset($last_post['usr_name']))
$last_post['usr_name'] = 'null';
}

// Dataarray
$todb = array(
'id' => $ob['tg_id'],
'forum_name' => html_entity_decode(htmlspecialchars_decode($ob['tg_name']), ENT_QUOTES, 'UTF-8'),
'forum_desc' => $ob['tg_comment'],
'num_topics' => $ob['tg_nbtopics'],
'num_posts' => $ob['tg_nbmess'],
'disp_position' => $ob['tg_order'],
'last_post_id' => isset($last_post['topic_lastmessage']) ? $last_post['topic_lastmessage'] : 0,
'last_poster' => isset($last_post['usr_name']) ? $last_post['usr_name'] : '',
'last_post' => isset($last_post['msg_timestamp']) ? $last_post['msg_timestamp'] : 0,
'cat_id' => $ob['tg_fromforum'],
'parent_forum_id'=> $ob['tg_fromtopicgroup'],
'redirect_url' => $ob['tg_link'],
);

// Save data
insertdata('forums', $todb, __FILE__, __LINE__);
}

convredirect('forum_id', 'forums', $last_id);
21 changes: 21 additions & 0 deletions ConnectixBoards/groups.php
@@ -0,0 +1,21 @@
<?php

// Fetch forum info
$result = $fdb->query('SELECT * FROM '.$fdb->prefix.'groups WHERE gr_id > 4') or myerror('Unable to fetch groups', __FILE__, __LINE__, $fdb->error());
while($ob = $fdb->fetch_assoc($result))
{
echo htmlspecialchars($ob['gr_name']).' ('.$ob['gr_id'].")<br>\n"; flush();

if (trim($ob['gr_name']) == '')
$ob['gr_name'] = 'Group';

// Dataarray
$todb = array(
'g_id' => $ob['gr_id'],
'g_title' => $ob['gr_name'],
'g_user_title' => $ob['gr_name'],
);

// Save data
insertdata('groups', $todb, __FILE__, __LINE__);
}

0 comments on commit ece5714

Please sign in to comment.