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 9 of 9
  1. #1
    Join Date
    Aug 2005
    Posts
    856
    Tokens
    0

    Default Ajax Shoutbox - 5hc

    PHP Code:
    <html>
    <head>
    <title>Home</title>
    <style type="text/css">
    a {
    font-size: 10px;
    color: #000000;
    }
    a:link {
    text-decoration: none;
    color: #000000;
    }
    a:visited {
    text-decoration: none;
    color: #000000;
    }
    a:hover {
    text-decoration: underline;
    color: #000000;
    }
    a:active {
    text-decoration: none;
    color: #000000;
    }
    body,td,th,p {
    font-family: Verdana;
    font-size: 10px;
    color: #000000;
    }
    .12 { color: red; }
    .11 { color: navy; }
    .10 { color: ; }
    .9 { color: darkorchid; }
    .8 { color: darkorchid; }
    .7 { color: darkorchid; }
    .6 { color: darkorchid; }
    .5 { color: green; }
    .4 { color: green; }
    .3 { color: green; }
    .2 { color: green; }
    .1 { color: black; }
    input {
     font-family: Tahoma, Arial;
     font-size: 8pt;
     font-weight: bold;
     width: 200;
     color: #000000;
     background-color: #FFFFFF;
     border: 1px solid #000000;
    }
    select {
     background-color: #ffffff;
     font-family: Arial, Helvetica, sans-serif;
     font-size: 8pt;
     color: #000000;
     width: 200;
     border: 1px solid #000000;
    }
    textarea {
    background-color: #ffffff;
     font-family: Arial, Helvetica, sans-serif;
     font-size: 8pt;
     color: #000000;
     width: 200;
     border: 1px solid #000000;
    }
    </style>
    <link href="ourhabbo.css" rel="stylesheet" type="text/css">
    </head>
    <BODY bgcolor="#ffffff">
    <?php
    include ('config.php');
    if(
    $logged[username]){ 
    $catid=$_GET['id'];
    if(
    $_POST['submit']){ //checks if the form was submitted
    $name $logged[username]; //posts the username
    $face $logged[display_badge]; //posts the users face
    $shout addslashes(htmlspecialchars($_POST['shout'])); //posts the shout
    $day date("d");
    $days $day 1;
    $date date("m-Y");
    $shout $_POST[shout]; 
    // Assuming your ban code is "ban: MrUser" 
    if ($logged[level] == 12 && stristr($shout":ban ")) 
        { 
    //since they have banning permission (im guesing) and "ban: " is in the input, we must be banning someone 
    //Exsplode the space in shout 
     
    $ban explode(" "$shout); 
    // the explode implode is more for when concatinaginng an undefined string length, since the syntax of the input of known its far easy just to drag the second chunk, 1 in this case. 
    $usertoban $ban['1']; 
    $result mysql_query("UPDATE `users` SET `banned` = 'banned' WHERE `username` = '$usertoban'") or die ('Error during the execution of the MySQL query : ' mysql_error());
    $query mysql_query("INSERT INTO `ban` (`id` , `username` , `time`) VALUES ('', '$usertoban', '$days-$date')") or die ('Error during the execution of the MySQL query : ' mysql_error());
    $alert mysql_query("UPDATE `users` SET `alert` = 'You have been banned and can no longer use the Site' WHERE `username` = '$usetoban'") or die ('Error during the execution of the MySQL query : ' mysql_error());
    }else{
    if (
    $logged[level] == 12 && stristr($shout":warnmod ")){ 
    $warnmod explode(" "$shout);
    $modtowarn $warnmod['1']; 
    $alert mysql_query("UPDATE `users` SET `alert` = 'Please do not socialize in the Chatrooms' WHERE `username` = '$modtowarn'") or die ('Error during the execution of the MySQL query : ' mysql_error());
    }else{
    if (
    $logged[level] == 12 && stristr($shout":mute ")) 
        { 
    //since they have banning permission (im guesing) and "ban: " is in the input, we must be banning someone 
    //Exsplode the space in shout 
     
    $mute explode(" "$shout); 
    // the explode implode is more for when concatinaginng an undefined string length, since the syntax of the input of known its far easy just to drag the second chunk, 1 in this case. 
    $usertomute $mute['1']; 
    $result mysql_query("UPDATE `users` SET `chat` = 'No' WHERE `username` = '$usertomute'") or die ('Error during the execution of the MySQL query : ' mysql_error());
    $alert mysql_query("UPDATE `users` SET `alert` = 'You have been muted, and can no longer use the Chatrooms' WHERE `username` = '$usertomute'") or die ('Error during the execution of the MySQL query : ' mysql_error());
    $date =  date("j F / G:i");
    $username $logged[username];
    mysql_query("INSERT INTO `logs` (`id` , `description`, `user`, `date` ) VALUES (NULL , 'Muted $usertomute', '$logged[username]', '$date')"); //Inserts into the D.B 
    }else{
    if (
    $logged[level] == 12 && stristr($shout":unmute ")) 
        { 
    //since they have banning permission (im guesing) and "ban: " is in the input, we must be banning someone 
    //Exsplode the space in shout 
     
    $unmute explode(" "$shout); 
    // the explode implode is more for when concatinaginng an undefined string length, since the syntax of the input of known its far easy just to drag the second chunk, 1 in this case. 
    $usertounmute $unmute['1']; 
    $result mysql_query("UPDATE `users` SET `chat` = 'Yes' WHERE `username` = '$usertounmute'") or die ('Error during the execution of the MySQL query : ' mysql_error());
    $alert mysql_query("UPDATE `users` SET `alert` = 'You have been unmuted, and can now use the Chatrooms' WHERE `username` = '$usertounmute'") or die ('Error during the execution of the MySQL query : ' mysql_error());
    $date =  date("j F / G:i");
    $username $logged[username];
    mysql_query("INSERT INTO `logs` (`id` , `description`, `user`, `date` ) VALUES (NULL , 'Unmuted $usertounmute', '$logged[username]', '$date')"); //Inserts into the D.B 
    }else{
    if(
    $logged[level] == 12 && $shout == ':clearroom'){
    mysql_query("DELETE FROM `shout` WHERE `cat` = '$catid'");   
    $date =  date("j F  G : i");
    mysql_query("INSERT INTO `logs` (`id` , `description`, `user`, `date` ) VALUES (NULL , 'Cleared the Chatroom', '$logged[username]', '$date')");
    $insert MYSQL_QUERY("INSERT INTO shout (name,shout,face,level,cat)".
    "VALUES ('System', 'This room has been cleared by an Administrator', 'http://www.ourhabbo.net/images/BADGES/admin.gif', '12','$catid')");
    }else{
    $insert MYSQL_QUERY("INSERT INTO shout (name,shout,face,level,cat)".
    "VALUES ('$name', '$shout', '$face', '$logged[level]','$catid')");
    $points=$logged['points'];
    $newpoints=$points 5;
    $sql2 mysql_query("UPDATE `users` set points = '$newpoints' where username = '$logged[username]'");
    }
    }
    }
    }
    }
    }
    $rooommysql_query("SELECT * FROM chatrooms WHERE id = '$catid'"); //finds the shouts order by id
    $room=mysql_fetch_array($rooom);
    $amountu mysql_query("SELECT * FROM `users` WHERE `page` = '/site/chatroom.php?id=$catid'");
    $amount mysql_num_rows($amountu);
    echo(
    "<table width='90%' align='center' class='contentTable'><tr class='contentTableHeader'><td colspan='2'><center>$room[name] - $amount Users Online</center></td></tr>");
    $find mysql_query("SELECT * FROM shout WHERE cat = '$catid' ORDER BY id DESC"); //finds the shouts order by id
    while($r=mysql_fetch_array($find)){ 
    $name $r[name]; //name
    $level $r[level]; //level
    $shout htmlspecialchars(addslashes($r[shout])); //shout
    $id $r[id]; //id
        
    $query mysql_query("SELECT * FROM `users` WHERE username = '$name'"); 
        
    $user mysql_fetch_array($query); //loop's the shouts
    $face $user[display_badge];
    echo 
    "<tr class='contentTableAltRow'><td width='5%'>";
    if(
    $face){
    echo(
    "<img src='$face' align='left'>");
    }
    echo
    "</td><td width='95%'><a href='members.php?user=$name'><span class='$level'><b>$name</span></a> ";
    echo 
    "</b></span><br>".$shout." ";
    if(
    $logged[level] == 11 || $logged[level] == 12){
    echo 
    "<br><b><a href = \"delete_shout.php?id=$id\">Delete</a> || ";
        
    $query mysql_query("SELECT * FROM `users` WHERE username = '$name'"); 
        
    $user mysql_fetch_array($query); 
    if(
    $user[banned] == 'banned'){
    echo
    "<a href = \"unbanuser.php?name=$name&cat=$catid\">Unban User</a> || ";
    }else{
    echo
    "<a href = \"banuser.php?name=$name&cat=$catid\">Ban User</a> || ";
    }
    if(
    $user[chat] == 'Yes'){
    echo
    "<a href = \"muteuser.php?name=$name&cat=$catid\">Mute User</b>";
    }else{
    echo
    "<a href = \"unmuteuser.php?name=$name&cat=$catid\">Unmute User</b>";
    }
    }
    echo 
    "</td></tr>";
    }
    echo(
    "</table>");
    if(
    $logged[username] && $logged[chat] == 'Yes'){ //if the user is logged in display the form
    echo "
    <br><center><form method=post>
    Shout: <input type=text name=shout width=200> <input type=submit value=Shout width=25 name=submit><br/>
    </form></center>"
    ;
    echo(
    "<br><b>Users in this Chatroom:</b><br>");
    $onlines mysql_query("SELECT * FROM `users` WHERE `page` = '/site/chatroom.php?id=$catid'");
    while(
    $online mysql_fetch_array($onlines)){
    echo(
    "<a href='members.php?user=$online[username]'>$online[username]</a>, ");
    }
    }
    }
    ?>
    </body>
    </html><?
    if ($logged[banned] == 'banned'){
    echo (
    "<meta http-equiv=\"Refresh\" content=\"0; URL=banned.php\"/>");
    }
    ?>
    I need that made to refresh everytime a new shout is posted. whoever manages it will get 5hcs maybe 8 depending on how am feeling...

  2. #2
    Join Date
    Nov 2006
    Location
    Leeds, Yorkshire
    Posts
    992
    Tokens
    0

    Default

    Just use a meta refresh to refresh it every 20 seconds or whatever.

    HTML Code:
    <meta http-equiv="refresh" content="20">


  3. #3
    Join Date
    Aug 2005
    Posts
    856
    Tokens
    0

    Default

    But then you get a bid page reload.. i want it to auto update which does refresh whenever someone posts.
    Last edited by xRoyal15; 13-12-2006 at 04:41 PM.

  4. #4
    Join Date
    Nov 2006
    Location
    Leeds, Yorkshire
    Posts
    992
    Tokens
    0

    Default

    Quote Originally Posted by xRoyal15
    made to refresh everytime a new shout is posted
    Quote Originally Posted by xRoyal15
    auto update with no refresh whenever someone posts.
    make up your mind.


  5. #5
    Join Date
    Aug 2005
    Posts
    856
    Tokens
    0

    Default

    typo.. needs to refresh.

  6. #6
    Join Date
    Dec 2006
    Location
    da hood.
    Posts
    274
    Tokens
    0

    Default

    Doesnt it already do that?


    Cool people: Spaceinvader, Xeoro, RNelson, -1., Redtom, Sam, Tomm, snail.


  7. #7
    Join Date
    Aug 2005
    Posts
    856
    Tokens
    0

    Default

    No... like when someone else posts everyone gets to see it

  8. #8
    Join Date
    Aug 2004
    Location
    bristol
    Posts
    3,799
    Tokens
    0

    Latest Awards:

    Default

    The script needs the capability to just output the data which needs to be refreshed (for example, the HTML table containing the messages). You cannot efficiently refresh the entire page, but only systematically update the data within HTML elements. I'm assuming you wrote that PHP, so if you can make it just output the HTML table when the URL has "?load=table" attached or something; I'll write the AJAX for free.
    kinda quit.

  9. #9
    Join Date
    Aug 2005
    Posts
    856
    Tokens
    0

    Default

    Oki Thanks

Posting Permissions

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