jablonka.czprosek.czf

vbtobb

Subversion Repositories:
[/] [trunk/] [convert.py] - Diff between revs 2 and 3

Show entire file Ignore whitespace

Rev 2 Rev 3
Line 12... Line 12...
USER_ID_OFFSET=100 USER_ID_OFFSET=100
USER_GROUP_ID=2 USER_GROUP_ID=2
USER_PERMISSIONS='00000000006xv1ssxs' USER_PERMISSIONS='00000000006xv1ssxs'
   
DB_HOST="localhost" DB_HOST="localhost"
DB_NAME="phpbb3" DB_NAME="cexp"
DB_USER="root" DB_USER="root"
DB_PASS="" DB_PASS=""
   
  POSTS_BITFIELD="/8A="
   
# escape strings for mysql # escape strings for mysql
def mysql_escape_string(str): def mysql_escape_string(str):
newstr = str.replace('\\', '\\\\') newstr = str.replace('\\', '\\\\')
newstr = newstr.replace('\'', '\\\'') newstr = newstr.replace('\'', '\\\'')
Line 26... Line 28...
   
# generate bbcode_uid # generate bbcode_uid
def make_uid(timestamp): def make_uid(timestamp):
return "a"+(str(timestamp))[0:7] return "a"+(str(timestamp))[0:7]
#return (timestamp, 16, 36)[0, 8] #return (timestamp, 16, 36)[0, 8]
   
  def get_bbcode_bitfield(post):
  global POSTS_BITFIELD
  return POSTS_BITFIELD
   
# count new user id # count new user id
def tuid(origid): def tuid(origid):
global USER_ID_OFFSET global USER_ID_OFFSET
return (USER_ID_OFFSET + origid) return (USER_ID_OFFSET + origid)
   
def tpost(orig_post, bbcode_uid): def tpost(orig_post, bbcode_uid):
new_post = orig_post.replace('[QUOTE]','[quote:%s]' % bbcode_uid); zz = ['quote', 'code', 'color', 'url', 'b', 'i', 'u', 'size', 'list', 'list=', 'img']
new_post = new_post.replace('[quote]','[quote:%s]' % bbcode_uid); new_post = orig_post
new_post = new_post.replace('[/QUOTE]','[/quote:%s]' % bbcode_uid); for a in zz:
new_post = new_post.replace('[/quote]','[/quote:%s]' % bbcode_uid); new_post = new_post.replace('['+a.upper()+']', '['+a+':'+bbcode_uid+']')
new_post = new_post.replace('[CODE]','[code:%s]' % bbcode_uid); new_post = new_post.replace('['+a+']', '['+a+':'+bbcode_uid+']')
new_post = new_post.replace('[code]','[code:%s]' % bbcode_uid); new_post = new_post.replace('[/'+a.upper()+']', '[/'+a+':'+bbcode_uid+']')
new_post = new_post.replace('[/CODE]','[/code:%s]' % bbcode_uid); new_post = new_post.replace('[/'+a+']', '[/'+a+':'+bbcode_uid+']')
new_post = new_post.replace('[/code]','[/code:%s]' % bbcode_uid);  
new_post = new_post.replace('[url]','[url:%s]' % bbcode_uid);  
new_post = new_post.replace('[url]','[url:%s]' % bbcode_uid);  
new_post = new_post.replace('[/url]','[/url:%s]' % bbcode_uid);  
new_post = new_post.replace('[/url]','[/url:%s]' % bbcode_uid);  
new_post = new_post.replace('[B]','[b:%s]' % bbcode_uid);  
new_post = new_post.replace('[b]','[b:%s]' % bbcode_uid);  
new_post = new_post.replace('[/B]','[/b:%s]' % bbcode_uid);  
new_post = new_post.replace('[/b]','[/b:%s]' % bbcode_uid);  
new_post = new_post.replace('[I]','[i:%s]' % bbcode_uid);  
new_post = new_post.replace('[i]','[i:%s]' % bbcode_uid);  
new_post = new_post.replace('[/I]','[/i:%s]' % bbcode_uid);  
new_post = new_post.replace('[/i]','[/i:%s]' % bbcode_uid);  
new_post = new_post.replace('[U]','[u:%s]' % bbcode_uid);  
new_post = new_post.replace('[u]','[u:%s]' % bbcode_uid);  
new_post = new_post.replace('[/U]','[/u:%s]' % bbcode_uid);  
new_post = new_post.replace('[/u]','[/u:%s]' % bbcode_uid);  
return new_post return new_post
   
# counts correct left_id and right_id for all forum items from forum_index # counts correct left_id and right_id for all forum items from forum_index
def updateBTree(parent_id): def updateBTree(parent_id):
global forum_index global forum_index
Line 216... Line 205...
moduser = row[16] moduser = row[16]
   
phpbb_bbcode_uid = make_uid(dateline) phpbb_bbcode_uid = make_uid(dateline)
phpbb_text = tpost(pagetext, phpbb_bbcode_uid) phpbb_text = tpost(pagetext, phpbb_bbcode_uid)
   
print ("INSERT INTO phpbb_posts SET post_id=%d, topic_id=%d, forum_id=(SELECT forum_id FROM phpbb_topics WHERE topic_id=%d), poster_id=%d, post_time=%d, post_username='%s', post_subject='%s', post_text='%s', post_checksum='%s', bbcode_uid='%s', post_edit_time=%d;" % (postid, threadid, threadid, tuid(userid), dateline, mysql_escape_string(username), mysql_escape_string(title), mysql_escape_string(phpbb_text), mysql_escape_string(md5.new(phpbb_text).hexdigest()), phpbb_bbcode_uid, editdate)) print ("INSERT INTO phpbb_posts SET post_id=%d, topic_id=%d, forum_id=(SELECT forum_id FROM phpbb_topics WHERE topic_id=%d), poster_id=%d, post_time=%d, post_username='%s', post_subject='%s', post_text='%s', post_checksum='%s', bbcode_bitfield='%s', bbcode_uid='%s', post_edit_time=%d;" % (postid, threadid, threadid, tuid(userid), dateline, mysql_escape_string(username), mysql_escape_string(title), mysql_escape_string(phpbb_text), mysql_escape_string(md5.new(phpbb_text).hexdigest()), get_bbcode_bitfield(phpbb_text), phpbb_bbcode_uid, editdate))
print ("UPDATE phpbb_topics SET topic_replies = topic_replies+1, topic_replies_real = topic_replies_real+1 WHERE topic_id=%d;" % (threadid)) print ("UPDATE phpbb_topics SET topic_replies = topic_replies+1, topic_replies_real = topic_replies_real+1 WHERE topic_id=%d;" % (threadid))
print ("UPDATE phpbb_forums SET forum_posts = forum_posts+1, forum_last_post_id=%d, forum_last_post_subject='%s', forum_last_post_time=%d, forum_last_poster_name='%s' WHERE forum_id=(SELECT forum_id FROM phpbb_topics WHERE topic_id=%d);" % (postid, mysql_escape_string(title), dateline, mysql_escape_string(username), threadid)) print ("UPDATE phpbb_forums SET forum_posts = forum_posts+1, forum_last_post_id=%d, forum_last_post_subject='%s', forum_last_post_time=%d, forum_last_poster_name='%s' WHERE forum_id=(SELECT forum_id FROM phpbb_topics WHERE topic_id=%d);" % (postid, mysql_escape_string(title), dateline, mysql_escape_string(username), threadid))
except: except:
print "Error while accessing data: ", sys.exc_info()[0] print "Error while accessing data: ", sys.exc_info()[0]
raise raise
Line 231... Line 220...
global USER_GROUP_ID global USER_GROUP_ID
global USER_PERMISSIONS global USER_PERMISSIONS
   
try: try:
c = db.cursor() c = db.cursor()
msg = "SELECT * FROM user ORDER BY userid;" msg = "SELECT *, (SELECT count(*) FROM user WHERE username=t1.username) AS numusers FROM user AS t1 ORDER BY userid;"
  opsusercount = dict()
c.execute(msg) c.execute(msg)
while (1): while (1):
row = c.fetchone() row = c.fetchone()
if row == None: if row == None:
break break
Line 289... Line 279...
startofweek = row[46] startofweek = row[46]
ipaddress = row[47] ipaddress = row[47]
referrerid = row[48] referrerid = row[48]
pmpopup = row[49] pmpopup = row[49]
nosessionhash = row[50] nosessionhash = row[50]
  numusers = row[51]
   
  if (numusers > 1):
  if (username in opsusercount):
  opsusercount[username] += 1
  username=username+"_OPS"+str(opsusercount[username])
  else:
  opsusercount[username] = 0
   
phpbb_user_type = 2 phpbb_user_type = 2
print ("INSERT INTO phpbb_users SET user_id=%d, user_type=%d, group_id=%d, user_permissions='%s', username='%s', username_clean='%s';" % (tuid(userid), phpbb_user_type, USER_GROUP_ID, USER_PERMISSIONS, mysql_escape_string(username), mysql_escape_string(username))) print ("INSERT INTO phpbb_users SET user_id=%d, user_type=%d, group_id=%d, user_permissions='%s', username='%s', username_clean='%s';" % (tuid(userid), phpbb_user_type, USER_GROUP_ID, USER_PERMISSIONS, mysql_escape_string(username), mysql_escape_string(username)))
except: except:
print "Error while accessing data: ", sys.exc_info()[0] print "Error while accessing data: ", sys.exc_info()[0]

Powered by WebSVN 2.2.1