SimplePortal

Support => English Support => Topic started by: OnlyMe69 on June 15, 2016, 08:30:02 AM

Title: Total Noob question
Post by: OnlyMe69 on June 15, 2016, 08:30:02 AM
Hi there, I'm new to all this SMF/SP stuff, I inherited a badly maintained forum, we moved the photo directory about and then a guy gave me some DB code that he said would change the links to embedded photos in existing posts  from old pointers to new, running the code just bombs and being no DBA I'm scratching my head a bit, could anyone have a look at the code below and point me in the right direction please?  I believe it's failing at the first hurdle and not populating the array highlighted in red..

many thanks in advance Paul.

Code: [Select]
global $scripturl;
// Grab the first set of members to verify.
$request = mysql_query("SELECT id_msg,body FROM {$db_prefix}messages
            WHERE id_msg >= " . $_REQUEST['start']. "  and id_msg <= " .($_REQUEST['start']+ $increment) . " and body like '%[smg id=%' ORDER BY id_msg ASC");
Code: [Select]

while ($row = mysql_fetch_assoc($request))
{
      $body = $row['body'];
preg_match_all('/\[smg id = (\d*)\]/i', $body, $matches, PREG_PATTERN_ORDER);

// print_r($matches);
if (!empty($matches))
{
foreach($matches[1] as $matchfound)
{

                       $matchfound = (int) $matchfound;

if (!empty($matchfound))
{
                       $result2 = mysql_query("SELECT thumbfilename FROM {$db_prefix}gallery_pic WHERE id_picture = $matchfound");
                        $picRow = mysql_fetch_assoc($result2);

                        $imgurl = $modSettings['gallery_url'] . $picRow['thumbfilename'];

                      //  die("[url={$scripturl}?action=gallery;sa=view;id=$matchfound][img=$imgurl][/url]");
                        if (!empty($picRow['thumbfilename']))
                        {
                            $body = str_replace("[smg id = $matchfound]","[url={$scripturl}?action=gallery;sa=view;id=$matchfound][img]{$imgurl}[/img][/url]",$body);
                            mysql_query("UPDATE {$db_prefix}messages set body = '$body' WHERE id_msg = " . $row['id_msg']);
                        }
                       }

                    }

                }

}
mysql_free_result($request);


                     
Title: Re: Total Noob question
Post by: emanuele on June 15, 2016, 09:05:36 AM
hmm...
It may be a "noob question", but it requires some more thoughts and info.

Let's see first if I got it right.
You had an SMF board, that was using AEVA.
You decided not to use AEVA any more and moved all the images to an external gallery script (which one?).
Now you are trying to convert the AEVA BBCode to img tags pointing to the new script.

Does sound about right?
Title: Re: Total Noob question
Post by: OnlyMe69 on June 15, 2016, 09:24:04 AM
Hi Emanuele, something called SMFGallery Pro was purchased to move away from Aeva which was causing server load problems, the gallery migrated successfully, its just the embedded code "[smg id=XXX]" that I need to swap out now for the new picture locations, i exported the SQL table for the smf_messages and had a look in it, the hooks seem right in the code below relating to what it's looking for and what to change it to, but im wondering if the DB syntax is wrong as when I run the full script it doesn't do anything... Does that make a bit more sense ? :)
Title: Re: Total Noob question
Post by: emanuele on June 15, 2016, 10:06:45 AM
http://www.smfhacks.com/index.php?topic=8871.0

If you paid for the gallery, as far as I can see you should have access to a converter as well, why not ask the creator of the gallery? ;)

ETA: I'm not proposing this to "send you away", but because if you have support from the creator of the gallery it's much easier for him to run an existing and working converter than for me to guess how to convert things that I don't know.
Title: Re: Total Noob question
Post by: ♦ Ninja ZX-10RR ♦ on June 15, 2016, 10:37:32 AM
@emanuele you forgot a vital "not" there, I exceptionally added it for you not to create a big misunderstanding :P
SimplePortal 2.3.8 © 2008-2024, SimplePortal