News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Quote tags not recognized

Started by Burpee, July 05, 2004, 09:39:00 AM

Previous topic - Next topic

[Unknown]

Oh interesting.  The way to fix that will be to replace:

[size=##]

With:

[size=##px]

But, I don't know a simple way to do that with MySQL (all versions, at least..) off hand.

-[Unknown]

Burpee

I'm even more clueless...  ::)
Been trying to do some searches but I have absolutely no clue what to search for :P

packman

Like [Unknown] said, I don't think there is a way to change this directly just using SQL.

I think you'll need to write some code (PHP or Perl) to search the smf_messages table for records that contain the 'size' tag and then do a preg_replace on the body field. I think you'd need...

$body = preg_replace("/\[size=([0-9]?[0-9])\]/i", "\[size=\\1px]", $body);

...but given that this is regexp I'd only trust it after extensive testing!!
Chris

[Unknown]

#43
Quote from: packman on August 30, 2004, 04:27:34 PM
Like [Unknown] said, I don't think there is a way to change this directly just using SQL.

I think you'll need to write some code (PHP or Perl) to search the smf_messages table for records that contain the 'size' tag and then do a preg_replace on the body field. I think you'd need...

$body = preg_replace("/\[size=([0-9]?[0-9])\]/i", "\[size=\\1px]", $body);

...but given that this is regexp I'd only trust it after extensive testing!!


* [Unknown] loves regular expressions ;).

$body = preg_replace('~\[size=([789]|[012][1-9])\]~is', '[size=$1px]', $body);

The reason for this special matching is that we don't want to match, neccessarily, [ size=2 ], which might really be to have that "html font size".  But, most people wouldn't use font sizes lower than 7 anyway... anything higher (not too high!) should be px ;).

-[Unknown]

packman

You beat me to it by 10 minutes. I had to tweak mine a couple of times to make it work. I wasn't a million miles out...I just ended up with a couple of extra slashes that I didn't need! I told you I didn't like regexp :(

I'll add it into the converter.
Chris

packman

I've fixed the timeOffset now. It's timeOffset = phpBB_user_timezone - phpBB_board_timezone.

Whilst it's worth getting right, a lot of users seem to be confused about time zones. I've got users from New Zealand who say they're GMT-12 when they should be GMT+12. I've got a user in Belgium who is convinced he's in GMT+13. Interestingly phpBB doesn't seem to support users in the Kiribati Line Islands who apparently live in GMT+14.
Chris

[Unknown]

Quote from: packman on August 30, 2004, 05:30:52 PM
Whilst it's worth getting right, a lot of users seem to be confused about time zones. I've got users from New Zealand who say they're GMT-12 when they should be GMT+12. I've got a user in Belgium who is convinced he's in GMT+13. Interestingly phpBB doesn't seem to support users in the Kiribati Line Islands who apparently live in GMT+14.

That's specically why, at least as far as I am concerned, SMF uses the method it does - it's less confusing.  Most everyone can add... but even I sometimes forget which time zone I am in.

-[Unknown]

Burpee

Quote from: [Unknown] on August 30, 2004, 04:34:29 PM

* [Unknown] loves regular expressions ;).

$body = preg_replace('~\[size=([789]|[012][1-9])\]~is', '[size=$1px]', $body);

The reason for this special matching is that we don't want to match, neccessarily, [ size=2 ], which might really be to have that "html font size".  But, most people wouldn't use font sizes lower than 7 anyway... anything higher (not too high!) should be px ;).

-[Unknown]

Another question :D
How do I perform this action on my own database?
My guess is to create a .php file, create a mysql query and then... insert this somewhere?

* Burpee feels noob  :-[

[Unknown]

<?php

include_once('/path/to/SSI.php');

$result mysql_query("
   SELECT body, ID_MSG
   FROM 
{$db_prefix}messages}");
while (
$row mysql_fetch_assoc($result))
{
   
$body preg_replace('~\[size=([789]|[012][1-9])\]~is''[size=$1px]'$row['body']);

   
mysql_query("
      UPDATE 
{$db_prefix}messages
      SET body = '
$body'
      WHERE ID_MSG = 
$row[ID_MSG]
      LIMIT 1"
);
}
mysql_free_result($result);

?>


You're lucky you only have 5000 posts.... this isn't the most efficient way, mind you.

-[Unknown]

Burpee

Quote
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/vuurwerk/public_html/forum/sizefix.php on line 8

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/vuurwerk/public_html/forum/sizefix.php on line 18

Maybe there's something wrong with the query?

[Unknown]

Oops, take out that extra } - it's a typo.

Bad:
   FROM {$db_prefix}messages}");

Good:
   FROM {$db_prefix}messages");

-[Unknown]

Burpee

#51
Hmm.... DB is now completely messed up... don't worry tho made a backup
I think that somehow the post ID's are also modified by the query...

[Unknown]

Quote from: Burpee on August 30, 2004, 07:39:17 PM
I think that somehow the post ID's are also modified by the query...

Strange, they shouldn't be.  Then again, you shouldn't be "kissing" me for an invite.

-[Unknown]

Burpee

Quote from: [Unknown] on August 30, 2004, 07:42:45 PM
Strange, they shouldn't be.  Then again, you shouldn't be "kissing" me for an invite.

But... but...  :'(

Advertisement: