1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

MySQL Request - changing BBCODE in Messages

Discussion in 'Installation, Upgrade, and Import Support' started by kankan, Nov 18, 2012.

  1. kankan

    kankan Active Member

    Hello,

    I have just migrated my PunBB messages to a fresh Xenforo set up.
    I got some tweaked BBCode in my PunBB forum like : [imgz]picture.jp[/imgz] (to make a thumbnail of the picture) and [img align=C] (to center the image)
    Of course those BBcodes are not understood by Xenforo and asking myself if i could run a MySQL request to parse the message database and automatically change those BBCodes from [imgz] to

    As i am not very involved into MySQL, how do i have to write the command ?

    Kindest regards,

    Nicolas
     
  2. cclaerhout

    cclaerhout Well-Known Member

    Use this addon to recreate your bbcodes. And if your bbcode is using an url to parse an image for example, also use this addon.
    You might need this addon too to perform search & replace.
     
    CNK and Jake Bunce like this.
  3. kankan

    kankan Active Member

    Thank you Cedric, i will check them out
    Regards
     
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  5. kankan

    kankan Active Member

    Hi Jake
    Thank you for your answer
    Just tested this addon
    Met the following pb :

    I have filled the info as followed :
    Quick Find: [imgz

    Regular Expression: [imgz]

    Replacement String:
    Code:
    [img]
    But the results in the post were like this :
    Code:
    [[img]]
    Anything i did wrong ?
     
  6. cclaerhout

    cclaerhout Well-Known Member

    With regex, [] must be escaped
    Code:
    \[imgz\]
     
    Jake Bunce likes this.
  7. kankan

    kankan Active Member

    Not in replacement string ?
     
  8. cclaerhout

    cclaerhout Well-Known Member

    Use this regex for imgz bbcodes (the imgz opening tag can't contain any options)
    Code:
    #\[imgz\](.+?)\[/imgz\]#ui
    => [] are escaped

    In replacement string you can use \1 for your bbcode content; for example:
    Code:
    [newbbcode]\1[/newbbcode]
    => [] are not escaped
     
    Jake Bunce likes this.
  9. cclaerhout

    cclaerhout Well-Known Member

    Question: your [img align=C] will always start like this and finish with [/img] ?
     
  10. kankan

    kankan Active Member

  11. cclaerhout

    cclaerhout Well-Known Member

    Sorry I've changed the first regex, look at it again please
     
    Jake Bunce likes this.
  12. cclaerhout

    cclaerhout Well-Known Member

    For the second replacement:
    Regex:
    Code:
    #\[img align=C\](.+?)\[/img\]#ui
    Replacement:
    Code:
    [center][img]\1[/img][/center]
     
    Jake Bunce likes this.
  13. kankan

    kankan Active Member

    Thank you Cedric :

    Getting this message :
    Server Error

    preg_match_all() [function.preg-match-all]: Delimiter must not be alphanumeric or backslash
    1. XenForo_Application::handlePhpError()
    2. preg_match_all() in PostReplace/ControllerAdmin/PostReplace.php at line 26
    3. PostReplace_ControllerAdmin_PostReplace->actionReplace() in XenForo/FrontController.php at line 310
    4. XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 13
     
  14. Luke F

    Luke F Well-Known Member

    From the examples it looks like the addon needs a full regex incl starting/ending #, etc.
     
    Jake Bunce and cclaerhout like this.
  15. cclaerhout

    cclaerhout Well-Known Member

    I guess the program is working with full code. I've modified regex but I'm checking first the program.
     
    Jake Bunce likes this.
  16. cclaerhout

    cclaerhout Well-Known Member

    Yes, I haven't seen the examples. My bad.
     
  17. kankan

    kankan Active Member

    Thank you, working pretty good
     
  18. kankan

    kankan Active Member

    What would be the query to change :
    Code:
    [video][media=youtube]m6XEB9Aj9KA[/media] into Xen ?
    I tried :
    Code:
    #\[video\]http:.+youtube.+v=(\w+)\1\].+\[/video\]#siU
    then in replacement :
    Code:
    [media=youtube]\2[/media]
    But nothing

    Thank you
     
  19. cclaerhout

    cclaerhout Well-Known Member

    Are you sure about this pattern:
    Code:
    [video][media=youtube]m6XEB9Aj9KA[/media] into Xen ?
    I think you mixed up both bbcodes
    What is the source?
     
    Jake Bunce likes this.
  20. kankan

    kankan Active Member

    yes sorry, mixed up during the edition of my post
    please read:
    Code:
    [video]http://www.youtube.com/watch?v=m6XEB9Aj9KA&feature=related[/video]
     

Share This Page