RevCMS Working News Comments!

GarettM

Posting Freak
Aug 5, 2010
833
136
Hey this will NOT work for your hotels but look at the code it could help make your comments better. (cherry pick)
PHP:
<?php
    /**
     *    Flabbo.us
     *
     *    Powered By RevolutionCMS
     *
     *    @author        GarettMcCarty
     *    @version    1.0.0
     */
    
    namespace Revolution;
   
    $article    = (!isset($_GET['id']) || !is_numeric($_GET['id'])) ? 1 : $_GET['id'];
   
    $comments    = $revolution->engine->query('SELECT * FROM `cms_news` WHERE id = ' . $article);
   
    $refresh     = false;
   
    if(isset($_POST['comment']))
    {
        $date = date("M j, Y g:i");
        $data = (isset($_POST['comment']) && strlen($_POST['comment']) <= 150) ? $_POST['comment'] : '';
       
        if(strlen($data) > 2)
        {
            $revolution->engine->query('INSERT INTO cms_comments (story, comment, date, author) VALUES ('.$article.', \''. $data.'\', \''.$date.'\',  '.$_SESSION['user']['id'].');');
           
        }
    }

    $query         = $revolution->engine->query('SELECT * FROM cms_comments WHERE story = ' . $article . ' ORDER BY id DESC');
    $comments    = $query->num_rows;
?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8">
        <title>{hotelName} - News</title>
       
        <link rel="stylesheet" href="{url}/app/template/skins/Habbo/styles/common.css" type="text/css">
        <script type="text/javascript" src="{url}/app/template/skins/Habbo/js/libs2.js"></script>
        <script type="text/javascript" src="{url}/app/template/skins/Habbo/js/visual.js"></script>
        <script type="text/javascript" src="{url}/app/template/skins/Habbo/js/libs.js"></script>
        <script type="text/javascript" src="{url}/app/template/skins/Habbo/js/common.js"></script>
        <script type="text/javascript" src="{url}/app/template/skins/Habbo/js/fullcontent.js"></script>
       
        <style>
            #logo {
                margin-top: -30px;
                background: url('{url}/app/template/skins/Habbo/images/logo.png') no-repeat;
                background-size: cover;
                width: 220px;
                height: 90px;
            }
        </style>
       
        <!--[if IE 8]>
            <link rel="stylesheet" href="{url}/app/template/skins/Habbo/styles/ie8.css" type="text/css">
        <![endif]-->
        <!--[if lt IE 8]>
            <link rel="stylesheet" href="{url}/app/template/skins/Habbo/styles/ie.css" type="text/css" />
        <![endif]-->
        <!--[if lt IE 7]>
            <link rel="stylesheet" href="{url}/app/template/skins/Habbo/styles/ie6.css" type="text/css" />
            <script type="text/javascript" src="{url}/app/template/skins/Habbo/js/pngfix.js"></script>
            <script type="text/javascript">
                try { document.execCommand('BackgroundImageCache', false, true); } catch(e) {}
            </script>
            <style type="text/css">
                body { behavior: url({url}/app/template/skins/Habbo/js/csshover.htc); }
            </style>
        <![endif]-->
    </head>
   
    <body id="news">
   
        <div id="overlay"></div>
        <div id="header-container">
            <div id="header" class="clearfix">
                <h1>
                    <a href="{url}/">
                        <div id="logo"></div>
                    </a>
                </h1>
                <div id="subnavi">
                    <div id="subnavi-search">
                        <div id="subnavi-search-upper">
                            <ul id="subnavi-search-links">
                                <li><a href="{url}/logout" style="color:#000">Sign Out</a></li>
                            </ul>
                        </div>
                    </div>
                    <div id="to-hotel">
                        <a href="{url}/client" class="new-button green-button" target="eac955c8dbc88172421193892a3e98fc7402021a" onclick="HabboClient.openOrFocus(this); return false;"><b>Enter {hotelName} Hotel</b><i></i></a>
                    </div>
                </div>
                <ul id="navi">
                    <li class="metab"><a href="{url}/me">{username}</a><span></span></li>
                    <li class="selected"><strong>Community</strong><span></span></li>
                    {housekeeping}
                </ul>
                <div id="habbos-online"><div class="rounded"><span>{online} members online</span></div></div>
            </div>
        </div>
        <div id="content-container">
            <div id="navi2-container" class="pngbg">
                <div id="navi2" class="pngbg clearfix">
                    <ul>
                        <li class=""><a href="{url}/community">Community</a></li>
                        <li class="selected">News</li>
                        <li class=" last"><a href="{url}/staff">Staff</a></li>
                    </ul>
                </div>
            </div>
            <div id="container">
                <div id="content" style="position: relative" class="clearfix">
                    <div id="column1" class="column">
                        <div class="habblet-container ">       
                            <div class="cbb clearfix default ">
                                <h2 class="title">News</h2>
                                <div id="article-archive">
                                    <ul>
                                        {newsList}
                                    </ul>
                                </div>
                            </div>
                        </div>
                        <script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>
                    </div>
                    <div id="column2" class="column">
                        <div class="habblet-container ">       
                            <div class="cbb clearfix notitle ">
                                <div id="article-wrapper">
                                    <h2>{newsTitle}</h2>
                                    <div class="article-meta">Posted {newsDate}</div>
                                   
                                    <div class="article-body">
                                        {newsContent}
                                        <br><br>
                                        <p><font face="Verdana" size="1"><b>- {newsAuthor}</b></p>
                                        <script type="text/javascript" language="Javascript">
                                            document.observe("dom:loaded", function() {
                                                $$('.article-images a').each(function(a) {
                                                    Event.observe(a, 'click', function(e) {
                                                        Event.stop(e);
                                                        Overlay.lightbox(a.href, "Image is loading");
                                                    });
                                                });
                                               
                                                $$('a.article-2729').each(function(a) {
                                                    a.replace(a.innerHTML);
                                                });
                                            });
                                        </script>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="habblet-container ">       
                            <div class="cbb clearfix notitle">
                                <div id="article-wrapper">
                                    <h2>Comments (<?php echo $comments; ?>)</h2>
                                    <div class="article-meta">Post a new comment</div>
                                    <p class="summary">
                                        <form method="post" action="{url}/news">
                                            <textarea name="comment" cols="83" rows="2" placeholder="Share your thoughts..."></textarea>
                                            <input type="submit" value="comment" style="vertical-align: right; text-align: right;" class="commentGo">
                                        </form>
                                    </p>
                                </div>
                            </div>
                        </div>
                        <div class="habblet-container orange">
                            <div class="cbb clearfix notitle">
                                <?php
                                    if($reload == true) {
                                        echo '<p> Please Reload </p>';
                                    }
                                    if($comments > 0):
                                        while($comment = $query->fetch_assoc()):
                                            $info    = $revolution->engine->query('SELECT * FROM users WHERE id = ' . $comment['author']);
                                            $info    = $info->fetch_assoc();
                                           
                                            if($comment['id'] % 2 == 0):
                                ?>
                                            <!-- Begin Comment -->
                                            <div style="width: 600px; display: block;">
                                                <div style="width: 420px; height: 90px; display: inline-block;vertical-align: top;margin: 0;padding-top: 20px; text-align: right;">
                                                    <b> <?php echo $info['username']; ?> </b>
                                                    <br />
                                                    <p><?php echo $comment['comment']; ?> </p>
                                                </div>
                                                <div style="width: 100px; height: 90px; display: inline-block;vertical-align: top;margin: 0">
                                                    <img src="http://avatar-retro.com/habbo-imaging/avatarimage.php?figure=<?php echo $info['look']; ?>&action=std&direction=4&head_direction=4&gesture=std&size=m&img_format=gif" style="margin-top: -20px; margin-left: 10px;" />
                                                </div>
                                            </div>
                                            <!-- End Comment -->
                                <?php
                                            else:
                                ?>
                                            <!-- Begin Comment -->
                                            <div style="width: 600px; display: block;">
                                                <div style="width: 100px; height: 90px; display: inline-block;vertical-align: top;margin: 0">
                                                    <img src="http://avatar-retro.com/habbo-imaging/avatarimage.php?figure=<?php echo $info['look']; ?>" style="margin-top: -20px; margin-left: 10px;" />
                                                </div>
                                                <div style="width: 420px; height: 90px; display: inline-block;vertical-align: top;margin: 0;padding-top: 20px;">
                                                    <b> <?php echo $info['username']; ?> </b>
                                                    <br />
                                                    <p><?php echo $comment['comment']; ?> </p>
                                                </div>
                                            </div>
                                            <!-- End Comment -->
                                <?php
                                            endif;
                                            unset($info);
           
                                        endwhile;
                                    endif;
                                ?>
                            </div>
                        </div>
                        <script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>
                    </div>
                </div>
            </div>
        </div>
        <script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>
        <script type="text/javascript">
            HabboView.run();
        </script>

        <!--[if lt IE 7]>
            <script type="text/javascript">
                Pngfix.doPngImageFix();
            </script>
        <![endif]-->
       
        <div id="footer" >
            <p>2014 &copy {hotelName}. {hotelName} is not affiliated with saluke and does not recieve income from this site.</p>
        </div>
   
    </body>
</html>

remove this and it could work i guess?
Code:
revolution->
 

Marlboro20

Member
Dec 17, 2013
37
6
Hey this will NOT work for your hotels but look at the code it could help make your comments better. (cherry pick)
remove this and it could work i guess?
Code:
revolution->
The code with removed revolution->
PHP:
<?php
    /**
     * RevolutionCMS
     *
     * @author    Kryptos
     * @version    1.0.0
     */
   
    namespace Revolution;
    global $engine;
   
    $article    = (!isset($_GET['id']) || !is_numeric($_GET['id'])) ? 1 : $_GET['id'];
    $comments    = $revolution->engine->query('SELECT * FROM `cms_news` WHERE id = ' . $article);
    $refresh    = false;
   
    if(isset($_POST['comment']))
    {
        $date = date("M j, Y g:i");
        $data = (isset($_POST['comment']) && strlen($_POST['comment']) <= 150) ? $_POST['comment'] : '';
       
        if(strlen($data) > 2)
        {
            $engine->query('INSERT INTO cms_comments (story, comment, date, author) VALUES ('.$article.', \''. $data.'\', \''.$date.'\',  '.$_SESSION['user']['id'].');');
        }
    }

    $query        = $engine->query('SELECT * FROM cms_comments WHERE story = ' . $article . ' ORDER BY id DESC');
    $comments    = $query->num_rows;
?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8">
        <title>{hotelName} - News</title>
       
        <link rel="stylesheet" href="{url}/app/template/skins/Habbo/styles/common.css" type="text/css">
        <script type="text/javascript" src="{url}/app/template/skins/Habbo/js/libs2.js"></script>
        <script type="text/javascript" src="{url}/app/template/skins/Habbo/js/visual.js"></script>
        <script type="text/javascript" src="{url}/app/template/skins/Habbo/js/libs.js"></script>
        <script type="text/javascript" src="{url}/app/template/skins/Habbo/js/common.js"></script>
        <script type="text/javascript" src="{url}/app/template/skins/Habbo/js/fullcontent.js"></script>
       
        <style>
            #logo {
                margin-top: -30px;
                background: url('{url}/app/template/skins/Habbo/images/logo.png') no-repeat;
                background-size: cover;
                width: 220px;
                height: 90px;
            }
        </style>
       
        <!--[if IE 8]>
            <link rel="stylesheet" href="{url}/app/template/skins/Habbo/styles/ie8.css" type="text/css">
        <![endif]-->
        <!--[if lt IE 8]>
            <link rel="stylesheet" href="{url}/app/template/skins/Habbo/styles/ie.css" type="text/css" />
        <![endif]-->
        <!--[if lt IE 7]>
            <link rel="stylesheet" href="{url}/app/template/skins/Habbo/styles/ie6.css" type="text/css" />
            <script type="text/javascript" src="{url}/app/template/skins/Habbo/js/pngfix.js"></script>
            <script type="text/javascript">
                try { document.execCommand('BackgroundImageCache', false, true); } catch(e) {}
            </script>
            <style type="text/css">
                body { behavior: url({url}/app/template/skins/Habbo/js/csshover.htc); }
            </style>
        <![endif]-->
    </head>
   
    <body id="news">
   
        <div id="overlay"></div>
        <div id="header-container">
            <div id="header" class="clearfix">
                <h1>
                    <a href="{url}/">
                        <div id="logo"></div>
                    </a>
                </h1>
                <div id="subnavi">
                    <div id="subnavi-search">
                        <div id="subnavi-search-upper">
                            <ul id="subnavi-search-links">
                                <li><a href="{url}/logout" style="color:#000">Sign Out</a></li>
                            </ul>
                        </div>
                    </div>
                    <div id="to-hotel">
                        <a href="{url}/client" class="new-button green-button" target="eac955c8dbc88172421193892a3e98fc7402021a" onclick="HabboClient.openOrFocus(this); return false;"><b>Enter {hotelName} Hotel</b><i></i></a>
                    </div>
                </div>
                <ul id="navi">
                    <li class="metab"><a href="{url}/me">{username}</a><span></span></li>
                    <li class="selected"><strong>Community</strong><span></span></li>
                    {housekeeping}
                </ul>
                <div id="habbos-online"><div class="rounded"><span>{online} members online</span></div></div>
            </div>
        </div>
        <div id="content-container">
            <div id="navi2-container" class="pngbg">
                <div id="navi2" class="pngbg clearfix">
                    <ul>
                        <li class=""><a href="{url}/community">Community</a></li>
                        <li class="selected">News</li>
                        <li class=" last"><a href="{url}/staff">Staff</a></li>
                    </ul>
                </div>
            </div>
            <div id="container">
                <div id="content" style="position: relative" class="clearfix">
                    <div id="column1" class="column">
                        <div class="habblet-container ">      
                            <div class="cbb clearfix default ">
                                <h2 class="title">News</h2>
                                <div id="article-archive">
                                    <ul>
                                        {newsList}
                                    </ul>
                                </div>
                            </div>
                        </div>
                        <script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>
                    </div>
                    <div id="column2" class="column">
                        <div class="habblet-container ">      
                            <div class="cbb clearfix notitle ">
                                <div id="article-wrapper">
                                    <h2>{newsTitle}</h2>
                                    <div class="article-meta">Posted {newsDate}</div>
                                   
                                    <div class="article-body">
                                        {newsContent}
                                        <br><br>
                                        <p><font face="Verdana" size="1"><b>- {newsAuthor}</b></p>
                                        <script type="text/javascript" language="Javascript">
                                            document.observe("dom:loaded", function() {
                                                $$('.article-images a').each(function(a) {
                                                    Event.observe(a, 'click', function(e) {
                                                        Event.stop(e);
                                                        Overlay.lightbox(a.href, "Image is loading");
                                                    });
                                                });
                                               
                                                $$('a.article-2729').each(function(a) {
                                                    a.replace(a.innerHTML);
                                                });
                                            });
                                        </script>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="habblet-container ">      
                            <div class="cbb clearfix notitle">
                                <div id="article-wrapper">
                                    <h2>Comments (<?php echo (int) $comments; ?>)</h2>
                                    <div class="article-meta">Post a new comment</div>
                                    <p class="summary">
                                        <form method="post" action="{url}/news">
                                            <textarea name="comment" cols="83" rows="2" placeholder="Share your thoughts..."></textarea>
                                            <input type="submit" value="comment" style="vertical-align: right; text-align: right;" class="commentGo">
                                        </form>
                                    </p>
                                </div>
                            </div>
                        </div>
                        <div class="habblet-container orange">
                            <div class="cbb clearfix notitle">
                                <?php
                                    if($reload == true) {
                                        echo '<p> Please Reload </p>';
                                    }
                                    if($comments > 0):
                                        while($comment = $query->fetch_assoc()):
                                            $info    = $engine->query('SELECT * FROM users WHERE id = ' . $comment['author']);
                                            $info    = $info->fetch_assoc();
                                           
                                            if($comment['id'] % 2 == 0):
                                ?>
                                            <!-- Begin Comment -->
                                            <div style="width: 600px; display: block;">
                                                <div style="width: 420px; height: 90px; display: inline-block;vertical-align: top;margin: 0;padding-top: 20px; text-align: right;">
                                                    <b> <?php echo $info['username']; ?> </b>
                                                    <br />
                                                    <p><?php echo $comment['comment']; ?> </p>
                                                </div>
                                                <div style="width: 100px; height: 90px; display: inline-block;vertical-align: top;margin: 0">
                                                    <img src="http://avatar-retro.com/habbo-imaging/avatarimage.php?figure=<?php echo $info['look']; ?>&action=std&direction=4&head_direction=4&gesture=std&size=m&img_format=gif" style="margin-top: -20px; margin-left: 10px;" />
                                                </div>
                                            </div>
                                            <!-- End Comment -->
                                <?php
                                            else:
                                ?>
                                            <!-- Begin Comment -->
                                            <div style="width: 600px; display: block;">
                                                <div style="width: 100px; height: 90px; display: inline-block;vertical-align: top;margin: 0">
                                                    <img src="http://avatar-retro.com/habbo-imaging/avatarimage.php?figure=<?php echo $info['look']; ?>" style="margin-top: -20px; margin-left: 10px;" />
                                                </div>
                                                <div style="width: 420px; height: 90px; display: inline-block;vertical-align: top;margin: 0;padding-top: 20px;">
                                                    <b> <?php echo $info['username']; ?> </b>
                                                    <br />
                                                    <p><?php echo $comment['comment']; ?> </p>
                                                </div>
                                            </div>
                                            <!-- End Comment -->
                                <?php
                                            endif;
                                            unset($info);
           
                                        endwhile;
                                    endif;
                                ?>
                            </div>
                        </div>
                        <script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>
                    </div>
                </div>
            </div>
        </div>
        <script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>
        <script type="text/javascript">
            HabboView.run();
        </script>
        <!--[if lt IE 7]>
            <script type="text/javascript">
                Pngfix.doPngImageFix();
            </script>
        <![endif]-->
        <div id="footer" >
            <p>2014 &copy {hotelName}. {hotelName} is not affiliated with saluke and does not receive income from this site.</p>
        </div>
    </body>
</html>
 

Detox

Member
Jul 24, 2010
365
24
I'm sorry for bumping threads but I just tested this and it doesn't work, every time you refresh the page it adds the same comment into db which is causing to spam
 

GarettM

Posting Freak
Aug 5, 2010
833
136
I'm sorry for bumping threads but I just tested this and it doesn't work, every time you refresh the page it adds the same comment into db which is causing to spam
I would love to fix it but I don't have a working computer at the moment...

Possible solution add a GET redirect at end of post.
PHP:
if(isset($_POST['comment']))
{
...code is here....
header('Location: '.$_CONFIG['hotel']['URL'] . "/news&Id=" . $article, true, 303);
}
I am not sure if that is even the right variable so don't copy and past

Second option :
PHP:
...beginning of post...
If($_SESSION['comment'] == $data)
   $data = 0; // maybe break;?
...end of post...
$_SESSION['comment'] = $data;
 

Detox

Member
Jul 24, 2010
365
24
I would love to fix it but I don't have a working computer at the moment...

Possible solution add a GET redirect at end of post.
PHP:
if(isset($_POST['comment']))
{
...code is here....
header('Location: '.$_CONFIG['hotel']['URL'] . "/news&Id=" . $article, true, 303);
}
I am not sure if that is even the right variable so don't copy and past

Second option :
PHP:
...beginning of post...
If($_SESSION['comment'] == $data)
   $data = 0; // maybe break;?
...end of post...
$_SESSION['comment'] = $data;
Well I think your on the right track I don't want to redirect to them to new page.
 

Detox

Member
Jul 24, 2010
365
24
I was thinking taking the code from Wickd CMS that he released but it isn't working with my codes even though they are both RevCMS
 

Kristopher

Photographer
Dec 25, 2010
803
68
If you don't redirect them then it won't show there new comment unless you wanna implement this with ajax
Could you possibly clean this and add a check if someone has commented and make it where they can only 2 times per article and if the article exist?
 

Detox

Member
Jul 24, 2010
365
24
Could you possibly clean this and add a check if someone has commented and make it where they can only 2 times per article and if the article exist?
Just grab the code off @Wickd BoonCMS copy released, it works well just gotta edit the code, I still haven't finished yet page for white :s
 

GarettM

Posting Freak
Aug 5, 2010
833
136
Could you possibly clean this and add a check if someone has commented and make it where they can only 2 times per article and if the article exist?
I could if you messaged me but I am not sure when I could get to doing that. I am really busy with work and school at the moment.
Just grab the code off @Wickd BoonCMS copy released, it works well just gotta edit the code, I still haven't finished yet page for white :s
You could if you wanted to
 

JustAGame

New Member
Dec 16, 2011
2
1
Not sure if anyone released this fix, but since I get this whole News Commenting function here, I'll post it here for future user reference.

In the codes, there's this :
PHP:
if($userPosts >= 1)
{
    define('ERROR', 'Sorry, you are only allowed one comment per article.');
}

which is supposed to restrict player for only 1 comment per article, but it doesn't work.

Here's how to make it work:
Replace
PHP:
if($userPosts >= 1)
{
    define('ERROR', 'Sorry, you are only allowed one comment per article.');
}

with

PHP:
$userPosts = mysql_query("SELECT * FROM cms_comments WHERE article = '".htmlentities(mysql_real_escape_string($_GET['id']))."' AND userid = '" . $_SESSION['user']['id']. "'");
$postNum = mysql_num_rows($userPosts);
if($postNum >= 1)
{
    define('ERROR', 'Sorry, you are only allowed one comment per article.');
}

Enjoy ;)
 

n4te

zzz
Oct 27, 2014
669
293
Not sure if anyone released this fix, but since I get this whole News Commenting function here, I'll post it here for future user reference.

In the codes, there's this :
PHP:
if($userPosts >= 1)
{
    define('ERROR', 'Sorry, you are only allowed one comment per article.');
}

which is supposed to restrict player for only 1 comment per article, but it doesn't work.

Here's how to make it work:
Replace
PHP:
if($userPosts >= 1)
{
    define('ERROR', 'Sorry, you are only allowed one comment per article.');
}

with

PHP:
$userPosts = mysql_query("SELECT * FROM cms_comments WHERE article = '".htmlentities(mysql_real_escape_string($_GET['id']))."' AND userid = '" . $_SESSION['user']['id']. "'");
$postNum = mysql_num_rows($userPosts);
if($postNum >= 1)
{
    define('ERROR', 'Sorry, you are only allowed one comment per article.');
}

Enjoy ;)
Thanks for this. Was wondering when a proper fix would show up.
 

Users who are viewing this thread

Top