Jump to content

Need a little help


rsj1

Recommended Posts

Basically what my problem is (I can't post a link as my site contains adult rated material) my shoutbox to be frank sucks. But due to the script I am using (MKPortal) its the only one available that will display both in the portal and the forum (SMF) The problem I have is the latest shouts block is in a thin column on the right hand side of the page (it would look ugly if I moved it to the top) this is fine as long as people only post normal text. The problems come when somebody posts a url eg [a href=\"http://www.google.co.uk/search?q=php+htlp&start=0&ie=utf-8&oe=utf-8&client=firefox-a&rls=org.mozilla:en-US:official\" target=\"_blank\"]http://www.google.co.uk/search?q=php+htlp&...:en-US:official[/a] this expands the column so the url does not get broken. This looks really ugly!

I now have a couple of choices, but as I am not that experienced with php (I get by, but am not great) I cannot code any of these myself.

Choice 1: As the message is posted I need to edit the script to check the text for urls and turn it into:
[code]<a href=\"FOUNDURL\">LINK</a>[/code] (where "LINK" is the actual text displayed.so it would turn [a href=\"http://www.google.com\" target=\"_blank\"]http://www.google.com[/a] into [a href=\"http://www.google.com\" target=\"_blank\"]LINK[/a]) before the message is entered into the database.

Choice 2: As the messages are viewed a bit of code would need to do exactly the same thing as above and turn the long links into [a href=\"http://www.google.com\" target=\"_blank\"]LINK[/a]

Choice 3: A bit of code that will truncate long strings of text (like urls) by either only showing the first 40 characters or by placing a space every 40 characters in the string.

Out of all three I would prefer choice 2. Here is the code that displays the shouts (I have annotated it as much as I can)

[code]
<?php

global $DB, $mklib, $mkportals;
$limit = $this->config['urlo_block'];
if (!$limit) {
    $limit = 5;
}
    $link_user = $mklib_board->forum_link("profile"); //uses a function in another script to get the base link to the users profile
    $query = $DB->query( "SELECT id, idaut, name, message, time FROM mkp_urlobox ORDER BY `id` DESC LIMIT $limit");
    while( $row = $DB->fetch_row($query) ) {
        $name = $row['name']; //The user who shouted's name
        $id_orig_name = $row['idaut']; // the user who shouted's member if
        $content .= "<tr><td class=\"tdblock\"><b><a href=\"$link_user=$id_orig_name\">";
        $content .= $row['name'];
        $content .= "</a></b>, on ";
        $content .= $mklib->create_date($row['time']);  //creates a date using a function in another script
        $content .= "</td></tr><tr><td>";

        $message = $mklib->decode_bb($row['message']); //grabs the message from the database and add the smilies

        //This is where the code editing $message would need to go
        
        $content .= $message;
        $content .= "</td></tr>";
    }

?>
[/code]
NOTE: $content is the variable the code returns and diaplys on the webpage

Any help is much appreciated!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.