Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 6 of 6

Thread: coding help

  1. #1
    Join Date
    Feb 2006
    Location
    Ontario Canada
    Posts
    4,587
    Tokens
    0

    Latest Awards:

    Default coding help

    i need help placing / modding code
    ok this is the file that proccess the shout in this file i want http://thybag.co.uk/?p=Tutorials&ind=40 added so it proccesses the smileys and bad words for $message
    PHP Code:
    <?php

    $name 
    $_POST['name'];
    $website $_POST['website'];
    $message $_POST['message'];

    if(empty(
    $name) OR empty($message))
    {
    echo 
    "

    <script language='javascript'>

    alert('You need to fill out both of the form fields...');

    </script>
    "
    ;

    }
    else
    {

    echo 
    "

    <script language='javascript'>

    alert('Thanks for your message 
    $name...');

    </script>
    "
    ;
    $name htmlspecialchars($name);
    $message htmlspecialchars($message);
    $tag = ("<font size=\"1\" face=\"Verdana\">
    <b>
    $name</b>: $message </font><br><br>");
    $read fopen("content.txt""r");
    $contents fread($readfilesize('content.txt'));
    fclose($read);

    $write fopen("content.txt""w");
    fwrite($write"$tag $contents");
    fclose($write);
    }

    print 
    "<meta http-equiv=\"refresh\" content=\"0;/v3/shout.htm\">";

    // Copyright 2006 - 2007 Colin-Roberts.net

    ?>
    Last edited by Colin-Roberts; 12-11-2006 at 06:51 PM.

    .:.:#14:.:. .:.: Impossible Is Nothing :.:. .:.: 845 Rep:.:.
    .:.: Stand up for what is right, even if you stand alone:.:.


  2. #2
    Join Date
    Mar 2006
    Location
    Scotland
    Posts
    1,012
    Tokens
    175

    Latest Awards:

    Default

    You need to make a BBCODE file. I'll explain it later.


    You don't like me
    Chances are I don't like you.

  3. #3
    Join Date
    Feb 2006
    Location
    Ontario Canada
    Posts
    4,587
    Tokens
    0

    Latest Awards:

    Default

    kk thanx richard

    .:.:#14:.:. .:.: Impossible Is Nothing :.:. .:.: 845 Rep:.:.
    .:.: Stand up for what is right, even if you stand alone:.:.


  4. #4
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    Quote Originally Posted by Colin-Roberts View Post
    i need help placing / modding code
    ok this is the file that proccess the shout in this file i want http://thybag.co.uk/?p=Tutorials&ind=40 added so it proccesses the smileys and bad words for $message
    I set it all out in functions to make it realy easy to add in, u just copy in the functions and, call em when u want em.
    PHP Code:
    <?php
    //Get varibles
    $name $_POST['name'];
    $website $_POST['website'];
    $message $_POST['message'];
    //Define functions
    function filter($msg)
    {
    //replace the veg with sware words.
    $bad_words explode(','"tomato,lettuce,carrot,potato,broccoli,cucumber,pea" );
      foreach (
    $bad_words as $naughty)
       {
      
    $msg eregi_replace($naughty"****"$msg);
       }
    return 
    $msg
    }
    function 
    doSmily($msg)
    {
    $msg str_replace(':)''<img src="Smileys/smile.gif" alt=":)" />'$msg);
    $msg str_replace(':(''<img src="Smileys/sad.gif" alt=":(" />'$msg);
    $msg str_replace(':D''<img src="Smileys/biggrin.gif" alt=":D" />'$msg);
    $msg str_replace(';)''<img src="Smileys/wink.gif" alt=";)" />'$msg);
    $msg str_replace(':o''<img src="Smileys/ohmy.gif" alt=":o" />'$msg);

    return 
    $msg;
    }

    //Start the page code
    if(empty($name) OR empty($message))
    {
    echo 
    "

    <script language='javascript'>

    alert('You need to fill out both of the form fields...');

    </script>
    "
    ;

    }
    else
    {

    echo 
    "

    <script language='javascript'>

    alert('Thanks for your message 
    $name...');

    </script>
    "
    ;
    //Before we add to the DB, we remove the bad words
    $message filter($message)

    $name htmlspecialchars($name);
    // Note, Dosmily function is called after html charicters have been removed. This is so the image codes do not also get filtered, which would stop them from showing up correctly.
    $message doSmily(htmlspecialchars($message));

    //And the rest of your code
    $tag = ("<font size=\"1\" face=\"Verdana\">
    <b>
    $name</b>: $message </font><br><br>");
    $read fopen("content.txt""r");
    $contents fread($readfilesize('content.txt'));
    fclose($read);

    $write fopen("content.txt""w");
    fwrite($write"$tag $contents");
    fclose($write);
    }

    print 
    "<meta http-equiv=\"refresh\" content=\"0;/v3/shout.htm\">";

    // Copyright 2006 - 2007 Colin-Roberts.net

    ?>

  5. #5
    Join Date
    Feb 2006
    Location
    Ontario Canada
    Posts
    4,587
    Tokens
    0

    Latest Awards:

    Default

    Parse error: syntax error, unexpected T_VARIABLE in addtag.php on line 55
    (addtag.php is the file i posted)
    Line 55:
    $name = htmlspecialchars($name);
    the lines around it:
    $name = htmlspecialchars($name);
    // Note, Dosmily function is called after html charicters have been removed. This is so the image codes do not also get filtered, which would stop them from showing up correctly.
    $message = doSmily(htmlspecialchars($message));
    Last edited by Colin-Roberts; 12-11-2006 at 07:38 PM.

    .:.:#14:.:. .:.: Impossible Is Nothing :.:. .:.: 845 Rep:.:.
    .:.: Stand up for what is right, even if you stand alone:.:.


  6. #6
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    Ah, yes a simple stupid mistake.. although i cant see how someone, who coulnt see what it was themselves after knowing about it, can actualy claime to know php...

    //Before we add to the DB, we remove the bad words
    $message = filter($message);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •