Jump to content
TNG Community
Philip

Comment Media Support

Recommended Posts

Philip

Comment Media addon

This addon allows anyone to add comments to any media you have.

You can protect your self from spam using Captcha.

It's based on tutorialzine's Simple AJAX Commenting System

The installation files are available at the Comment Media Wiki page. now :)

Known Bugs

* All comment media stuff is pushed far to the left when using Internet Explorer.

(This is caused by Microsoft's reluctance of accepting basic web coding standards. I will post an fix for this soon.)

* Shadows not displaying in Internet Explorer.

(The cause is the same as above.)

Current features

* Automated installation of the required tables in the tng database.

* Automated check to see if there are any encoding problems.

* A Comment Media Control panel available in TNG admin area.

* Enable/Disable Captcha.

* Enable/Disable that users are required to enter a "valid" e-mail.

* Enable/Disable that users are required to enter a "valid" url to their homepage.

* The posters can use their Gravatar image as a portrait.

* TNG admins can delete posts.

Upcoming features

* Bulk delete of posts.

* Layout editor (Posts below submit form, or to the left of it.. and so on)

* Colors integrated with current TNG template.

* The ability to choose on which media guests should be allowed to post comments on.

* The ability to allow only registered users to post comments.

You can also post features you want, in this forum.

Translations

English

$text['CM-AddComment'] = "Add a comment";

$text['CM-Name'] = "Name";

$text['CM-Email'] = "Email address";

$text['CM-Url'] = "Your homepage address<br />(include the http://)";

$text['CM-required'] = "(required)";

$text['CM-TextArea'] = "Text";

$text['CM-Captcha'] = "Spam Check";

$text['CM-Submit'] = "Send";

$text['CM-Delete'] = "Delete post";

Swedish

$text['CM-AddComment'] = "Lämna en kommentar";

$text['CM-Name'] = "Namn";

$text['CM-Email'] = "Email adress";

$text['CM-Url'] = "Din hemsida <br /> (inkludera http:// )";

$text['CM-required'] = "(krävs)";

$text['CM-TextArea'] = "Text";

$text['CM-Captcha'] = "Spam kontroll";

$text['CM-Submit'] = "Skicka";

$text['CM-Delete'] = "Radera kommentar";

Troubleshooting

Strange characters appears in the comments.

This is because there are different encodings in the database and in the TNG.

Use the Comment Media Control Panel to see which encoding you have.

There is an article in TNG Wiki on how to convert to UTF-8

I have the beta version of Comment Media installed but don't want to erase all comments.

If you downloaded the Comment Media from the forum, a topic under the New Ideas and Suggestions, you need to remove all of these files manually.

They should be here:

(Your tng root dir) comment-demo.php

(Your tng root dir) comment-submit.php

(Your tng root dir) css/comment-style.css

(Your tng root dir) extensions/comments/comment-class.php

(Your tng root dir) extensions/comments/recaptchalib.php

(Your tng root dir) img/comment-default_avatar.gif

(Your tng root dir) js/comment-script.js

there might also be one more file:

(Your tng root dir) table.sql

The next step is to rename the comments table in you tng database to: cm_comments

There is a Youtube clip on on how to rename a table in phpMyAdmin.

The last step is to remove the lines in showmedia.php

<?php
require "extensions/comments/comment-class.php";
/*
/    Select all the comments and populate the $comments array with objects
*/

$comments = array();
$mediaID = preg_replace('/[^0-9]/', '', $mediaID);     // I have added this as a precaution, it removes everything that isn't a number                                                    
$result = mysql_query("SELECT * FROM comments WHERE mediaID=$mediaID ORDER BY id ASC");

while($row = mysql_fetch_assoc($result)){
    $comments[] = new Comment($row);
}

// The script below is just a customation for recaptcha
// http://code.google.com/intl/xx-elmer/apis/recaptcha/docs/customization.html
?>
<script type="text/javascript">
var RecaptchaOptions = {
    theme : 'clean'
};
</script>
<link rel="stylesheet" type="text/css" href="css/comment-style.css" />
</div>
<div id="main">
    <?php
    /*
    /    Output the comments one by one:
    */
    foreach($comments as $c){
        echo $c->markup();
    }
    ?>
    <div id="addCommentContainer">
        <p>Add a Comment</p>
        <form id="addCommentForm" method="POST" action="">
            <div>
                <table>
                    <tr>
                        <td class="commentcell-1" >
                            <input type="hidden" name="mediaID" id="mediaID" value="<?php echo $mediaID; ?>" />
                            
                            <label for="name">Your Name</label>
                            <input type="text" name="name" id="name" />
                            
                            <label for="email">Your Email</label>
                            <input type="text" name="email" id="email" />
                            
                            <label for="url">Website (not required)</label>
                            <input type="text" name="url" id="url" />
                        </td>
                        <td class="commentcell-2" >                
                            <label for="body">Comment Body</label>
                            <textarea name="body" id="body" cols="21" rows="5"></textarea>
                            
                            <label for="recaptcha">Spam Check</label>
                            <?php
                            require_once"extensions/comments/recaptchalib.php";
                            $publickey = "your_public_key"; // you got this from the signup page at http://www.google.com/recaptcha/whyrecaptcha
                            echo recaptcha_get_html($publickey);
                            ?>
                            <input type="submit" id="submit" value="Submit" />
                        </td>
                    </tr>
                </table>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="js/comment-script.js"></script>

More to come..

Share this post


Link to post
Share on other sites
genhcn

J'ai fait une tentative ce matin in localhost

error in administration :

Warning: require(../../languages//text.php) [function.require]: failed to open stream: No such file or directory in G:\xampp\htdocs\genealogie\mods\comment_media\cm_settings.php on line 15

Fatal error: require() [function.require]: Failed opening required '../../languages//text.php' (include_path='.;G:\xampp\php\pear\') in G:\xampp\htdocs\genealogie\mods\comment_media\cm_settings.php on line 15

:sad:

Share this post


Link to post
Share on other sites
Philip

Hi

Your warning is saying it can't find the file text.php in your language directory.

Do you have text.php in you language folder? (I'm guessing it's the French-UTF8 folder you are using)

If the answer to the question above is Yes, then do the following:

Comment out that line in cm_settings.php (line number 15)

Replace :

require "../../$mylanguage/text.php";
with
 // require "../../$mylanguage/text.php";

(Note the two forward slashes in the beginning)

Share this post


Link to post
Share on other sites
genhcn

it's ok with //

But....

Error: TNG is not communicating with your database. Please check your database settings and try again.

:oops:

Share this post


Link to post
Share on other sites
Philip

Hi

I get that error sometimes when the database is working to much and can't handle more requests so it works after I have waited a while.

* Is the database on your local computer?

* Can you see if your tng database exists and that it have all the tables? (Use phpMyAdmin or a similar software)

Comment Media should have two tables to be able to work:

cm_comments

cm_settings

Do note that my addon never changes your database settings nor needs to know anything about it.

It simply uses the available database connection.

Share this post


Link to post
Share on other sites
genhcn

Hi

I get that error sometimes when the database is working to much and can't handle more requests so it works after I have waited a while.

* Is the database on your local computer?

Yes and is work ok!

* Can you see if your tng database exists and that it have all the tables? (Use phpMyAdmin or a similar software)

Yes my tng is fonctionnal at localhost

Comment Media should have two tables to be able to work:

cm_comments

cm_settings

je refais les tables et je reviens.... Thank you for help

Do note that my addon never changes your database settings nor needs to know anything about it.

It simply uses the available database connection.

Share this post


Link to post
Share on other sites
genhcn

Two tables in phpmyadmin

but error message again

Error: TNG is not communicating with your database. Please check your database settings and try again.

:sad::oops:

but the script is in media page but not working

Share this post


Link to post
Share on other sites
Philip

The reason that your script doesn't work is probably caused by the file cm_comment.php can't find the cm_submit.php file.

Have you moved the files from the folder mods/comment_media ?

A workaround of this problem is to move all the files to the root folder of your tng installation and then edit the paths in 4 files. I can tell you how to do it if you are interested.

But I just discovered a bug in Comment Media, everything (all comment media stuff) is pushed far to the left.

I will post an fix for this soon.

Share this post


Link to post
Share on other sites
genhcn

cm_comment.php and cm_submit.php is in mods\comment_media folder, is not ok?

I do not know why I have so much trouble with this script is the first time I have trouble with TNG!

;-)

Probably because I want this script absolutely!

:|:lol:

For the bug... no urgence here!

:lol:

Not online, only in localhost for the moment.

Share this post


Link to post
Share on other sites
Philip

Hi

I have created a zipfile which contains edited files which you can unzip into your root directory of your tng installation. They should end up in the same directory as the showmedia.php file.

Note, you could uninstall the mod in tng before you alter the showmedia.php file.

It will otherwise be an broken addon in the mod manager.

All you have to do use them is to edit the line in showmedia.php

From : include "mods/comment_media/cm_comment.php";

to: include "cm_comment.php";

This should fix any problems with the files not finding each others.

Comment_Media_in_TNG_Root_Dir.zip

Share this post


Link to post
Share on other sites
Ken Roy

Hi

I have created a zipfile which contains edited files which you can unzip into your root directory of your tng installation. They should end up in the same directory as the showmedia.php file.

Note, you could uninstall the mod in tng before you alter the showmedia.php file.

It will otherwise be an broken addon in the mod manager.

All you have to do use them is to edit the line in showmedia.php

From : include "mods/comment_media/cm_comment.php";

to: include "cm_comment.php";

This should fix any problems with the files not finding each others.

Comment_Media_in_TNG_Root_Dir.zip

Philip,

You might consider copying your new scripts to the TNG extensions directory using the

%copyfile2:comment_media/cm_comment.php:extensions/comment_media/cm_comment.php% 
parameter to copy the files from the comment_media directory to a different directory than the TNG root directory or copying them to the TNG root using
%copyfile:comment_media/cm_comment.php%

Hopefully, I coded the above parameters correctly.

Ken

Share this post


Link to post
Share on other sites
genhcn

:!: :!: :!:

:-P:razz::smile:

YES! YES! YES!

Work in localhost!

I have to leave, I come back later

Thank you

Share this post


Link to post
Share on other sites
Philip

Hi

I'm aware of the copy functions in the mod manager but since the mod worked when it was in the comment_media folder I saw no reason to copy the files into the extensions folder, or anywhere else and end up with two copies of the files. I also know that you can create files with the mod manager but I thinks it's easier just to place the files in a zip file.

Another way is to place then in a extension/comment_media folder in the zip file and tell the user to unzip the file into the root dir of tng.

There are several ways to do it.

Share this post


Link to post
Share on other sites
Ken Roy

Hi

I'm aware of the copy functions in the mod manager but since the mod worked when it was in the comment_media folder I saw no reason to copy the files into the extensions folder, or anywhere else and end up with two copies of the files. I also know that you can create files with the mod manager but I thinks it's easier just to place the files in a zip file.

Another way is to place then in a extension/comment_media folder in the zip file and tell the user to unzip the file into the root dir of tng.

There are several ways to do it.

Philip,

Well it is your mod, so however you want to deal with issues being raised by others, as long as you don't tell users they have to edit files to fix problems.

I installed your current version just to make sure the mod was not conflicting with the mods I have posted for showmedia, and then removed it, since it is not something I want to use on my site.

Was just offering a comment so that all provide a consistent implementation on mods.

Ken

Share this post


Link to post
Share on other sites
Ken Roy

In the test here

http://genhcn.net/genealogie/showmediax.php?mediaID=125

Le script est fonctionnel sauf que le problème de codage est revenu.

Les accents

éâèê

ne passe pas. Pourtant ce problème avait été résolu lors des tests précédents.

Je ne comprend pas.

Ma base n'a aucun problème d'accents.

Nat

Bonjour Nat,

I think that the issue might be that the Mod Manager config file is saved as ASCII text whereas you are running TNG in UTF-8.

Try changing the $text variable to use [be]& eacute; (without the space) for the accent.

Je pense que l'issue pourrait être que le fichier de config pour cet mod est sauvé comme texte d'ASCII tandis que TNG est UTF-8.

Essayez de changer la variable de $text pour utiliser & eacute; (sans espace) pour l'accent.

Ken

Share this post


Link to post
Share on other sites
genhcn

Bonjour Nat,

I think that the issue might be that the Mod Manager config file is saved as ASCII text whereas you are running TNG in UTF-8.

Try changing the $text variable to use [be]& eacute; (without the space) for the accent.

Je pense que l'issue pourrait être que le fichier de config pour cet mod est sauvé comme texte d'ASCII tandis que TNG est UTF-8.

Essayez de changer la variable de $text pour utiliser & eacute; (sans espace) pour l'accent.

Ken

Where do I make this change?

Share this post


Link to post
Share on other sites
Ken Roy

In the test here

http://genhcn.net/genealogie/showmediax.php?mediaID=125

Le script est fonctionnel sauf que le problème de codage est revenu.

Les accents

éâèê

ne passe pas. Pourtant ce problème avait été résolu lors des tests précédents.

Je ne comprend pas.

Ma base n'a aucun problème d'accents.

Nat

Nat,

Sorry, I did not look closely enough to where you were getting the error. I thought the accented text was part of the $text variable when in fact it is the comment you entered.

Your site is running TNG as ISO-8859-1 and TNG displays the accents correctly from the database. So most likely it is in the code that creates the comment not saving the information to the database correctly. Or that the new database table was created as UTF8 collation sequence when your database is latin1 collation sequence.

It would appear that the setup page for this mod needs to allow the user to specify the collation sequence for the table, or should get it from another TNG table rather than assuming that everyone is using UTF-8 these days.

--- French

Désolé, je n'ai pas regardé assez proche à votre erreur. J'ai pensé que le texte accentué faisait partie d'un variable de $text quand en fait c'est le commentaire que vous avez écrit.

Votre site Web TNG est en ISO-8859-1 et TNG montre les accents correctement de la base de données. C'est très probable que l'erreur est dans le code qui crée le commentaire dans la base de données ne le crée pas correctement. Ou plus probablement l'erreur est que la nouvelle table de base de données a été créée dans l'ordre lexicographique UTF8 quand votre base de données est ordre lexicographique latin1.

La page d'installation pour ce mod doit permettre à l'utilisateur de spécifier l'ordre lexicographique pour la table, ou devrait l'obtenir d'une autre table de TNG plutôt que supposant que chacun emploie UTF-8 de nos jours.

Ken

Share this post


Link to post
Share on other sites
genhcn

The mystery

J'ajoute un commentaire / add commentaire

Before refresh page

After refresh page

but in the phpmyadmin. the comment is not ok.

Nat

Share this post


Link to post
Share on other sites
theKiwi

Nat - this is a problem with something different between what the database is set to and what the character set/encoding is set to for your site, or at least the add comments page.

As Ken wrote, your site is set up to use ISO-8859-1 as seen in the encoding given on your page.

What is the collation of the database - if you view it in phpMyAdmin? Is it something like

latin1_xxxxxx_ci or is it something like xxxxxxx_utf8_xxxxxxx_ci

Roger

Share this post


Link to post
Share on other sites
Ken Roy

The mystery

J'ajoute un commentaire / add commentaire

Before refresh page

After refresh page

but in the phpmyadmin. the comment is not ok.

Nat

Nat,

My guess is that the following line 28 in cm_comment.php

$_SESSION['cm_encoding'] = "UTF-8";
is what causes the problem. This code should be using the TNG character encoding variable - $charset rather than forcing UTF-8 encoding. However this will also require that the tables be created with the correct collation sequence. --- French Ma conjecture est que la ligne 28 dans cm_comment.php
$_SESSION['cm_encoding'] = "UTF-8";

est ce qui pose ce problème.

Ce code devrait employer la variable de codage de caractère de TNG - $charset plutôt que forcer le codage en UTF-8 cependant ceci exigera également que les tables soient créées avec l'ordre lexicographique correct.

Ken

Share this post


Link to post
Share on other sites
Ken Roy

all in utf8_general_ci

in administration tng = ISO-8859-1

but I've never had trouble with accents before this script.

look : http://www.tngforum.us/index.php?showtopic=5846

encoding caractere working finally...

Grrrrrrrrr!

The database in MySQL 5 itself is utf8. When you say all utf8_general_ci are you looking at the individual Collation field for each table in phpMyAdmin? If that is truly utf8, then you should change your TNG character set to UTF-8. Otherwise there is translation of character set encoding going on.

My previous reply recommendations stand, since not every TNG user is using UTF-8.

However, I don't think you are either, since if I change the character encoding in the browser, then all your other accented characters get mangled.

--- French

La base de données dans MySQL 5 elle-même est utf8. Quand vous dites all in utf8_general_ci

est que ce sont les champs individuel sous la colonne de la collation pour chaque table dans le phpMyAdmin ? Si c'est vraiment utf8, alors vous devriez changer votre jeu de caractères de TNG en UTF-8. Autrement il y a traduction du codage de jeu de caractères continuant.

Mes recommandations dans la réponse précédente se tiennent, puisque chaque utilisateur de TNG n'emploie pas UTF-8.

Cependant, je ne pense pas que vous employer UTF-8 non plus, puisque si je change le codage de caractère dans le navigateur, alors tous vos autres caractères accentués sont mutilés.

Ken

Share this post


Link to post
Share on other sites
genhcn

Nat,

My guess is that the following line 28 in cm_comment.php

$_SESSION['cm_encoding'] = "UTF-8";
is what causes the problem. This code should be using the TNG character encoding variable - $charset rather than forcing UTF-8 encoding. However this will also require that the tables be created with the correct collation sequence. --- French Ma conjecture est que la ligne 28 dans cm_comment.php
$_SESSION['cm_encoding'] = "UTF-8";

est ce qui pose ce problème.

Ce code devrait employer la variable de codage de caractère de TNG - $charset plutôt que forcer le codage en UTF-8 cependant ceci exigera également que les tables soient créées avec l'ordre lexicographique correct.

Ken

From the beginning = "UTF-8" in cm_comment.php catches my eye

J'ai mis :

$_SESSION['cm_encoding'] = "$charset";

it's ok?

After, delete table et remake?

Ceci est correct?

CREATE TABLE IF NOT EXISTS `cm_comments` (

`id` int(10) unsigned NOT NULL AUTO_INCREMENT,

`name` varchar(128) NOT NULL,

`url` varchar(255) NOT NULL DEFAULT '',

`email` varchar(255) NOT NULL DEFAULT '',

`body` text NOT NULL,

`dt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,

`mediaID` int(11) NOT NULL,

PRIMARY KEY (`id`)

) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×