Jump to content
Welcome, Guest
Existing user? Sign In

Sign In



Sign Up
The MatriX
  • Welcome To Ghbsys
  • CS GO Streaming Version is released. Have fun streaming while cheating!
  • Have a Payment Issue? Send us a Support ticket.
  • Make a thread if you need support or join our discord for live support.
  • Have Suggestions? Make a thread and you'll earn Ghbsys Points for implemented suggestions.
  • Join our discord to stay well connected! Don't forget to integrate your discord to the site
  • Welcome to [GHB] - GAmEhAcKbAsTaRdS Forum

    Welcome to [GHB] - GAmEhAcKbAsTaRdS Forum, like most online communities you must register to view or post in our community, but don't worry this is a simple free process that requires minimal information for you to signup. Be apart of [GHB] - GAmEhAcKbAsTaRdS Forum by signing in or creating an account.
    • Start new topics and reply to others
    • Subscribe to topics and forums to get email updates
    • Get your own profile page and make new friends
    • Send personal messages to other members.

    [PHP] YouTube UBB in Textarea


    DirectNULL
     Share

    Recommended Posts

    Hello guys,

     

    I've created a YouTube UBB parser for a textarea.

    You can put a video in the post with:

    [youtube]LINK TO VIDEO[/youtube]
    

     

    Down below the source code:

    <?php
    
    ini_set('display_errors', 'On');
    
    error_reporting(E_ALL);
    
    
    
    
    
    function parseYoutubeUbb($sString)
    
    {
    
        $sString = preg_replace('_\[youtube\].*?(v=|v/)(.+?)(&.*?|/.*?)?\[/youtube\]_is', '[youtube]$2[/youtube]', $sString);
    
        $sString = preg_replace('_\[youtube\]([a-z0-9-]+?)\[/youtube\]_is', '<object width="425" height="355"><param name="movie" value="http://www.youtube.com/watch?v=$1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/watch?v=$1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>', $sString);
    
        
    
        return $sString;
    
    }
    
    
    
    $sInput = '';
    
    $sOutput = '';
    
    
    
    if($_SERVER['REQUEST_METHOD'] == 'POST')
    
    {
    
        if(isset($_POST['text']))
    
        {
    
            $sInput = trim($_POST['text']);
    
            $sOutput = nl2br(htmlentities($sInput));
    
            $sOutput = parseYoutubeUbb($sOutput);
    
        }
    
    }
    
    ?>
    
    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <head>
    
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
        <title>YouTube UBB</title>
    
    </head>
    
    <body>
    
        <div id="wrap">
    
            
    
            <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    
            <p>
    
                <textarea name="text" id="text" class="none" cols="60" rows="5"><?php echo $sInput; ?></textarea>
    
            </p>
    
            <p>
    
                <input type="submit" value="Post" />
    
            </p>
    
            </form>
    
            
    
            <h3>Output:</h3>
    
            <div id="content">
    
                <?php echo $sOutput; ?>
    
            </div>
    
        </div>    
    
    </body>
    
    </html>
    

    Have fun with it!

     

    Greetz me icon_smile.gif

    Edited by SeriiousGamerr
    • Upvote 1
    Link to comment
    Share on other sites

    Guest
    This topic is now closed to further replies.
     Share

    • Recently Browsing   0 members

      • No registered users viewing this page.
    ×
    ×
    • Create New...