Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Pages: [1] 2

Author Topic: [MOD] Highlighted admin comments (sNews 1.4)  (Read 12117 times)

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
[MOD] Highlighted admin comments (sNews 1.4)
« on: June 12, 2006, 09:12:02 am »

EDIT: this is fully functional mod. however, if you need additonal options , find my next post at the bottom of this page
finally did it :D ...last night i wrote some crappy snippet here and without testing... (thank god for editing mode)... but as always, the morning is smarter than the night

note: most of the credits for this mod should go to analyzerx because it was his idea at the first place ;)

here it is:

1. backupbackupbackup :cool:

2. in your css file (images/style.css) add this
Quote
.admincomments {your-style-goes-here}
3. find in //COMMENTS (snews.php)
Quote
//COMMENTS
...
$query  = "SELECT * FROM " .s('prefix'). "comments WHERE articleid = $articleid ORDER by id $comments_order LIMIT $offset, $results_per_page";
$result = mysql_query($query) or die(s('dberror'));
while ($r = mysql_fetch_array($result)) {
echo "

" .cleanXSS($r['comment']). "

";
...
4. and replace it with
Quote
//COMMENTS
...
$query  = "SELECT * FROM " .s('prefix'). "comments WHERE articleid = $articleid ORDER by id $comments_order LIMIT $offset, $results_per_page";
$result = mysql_query($query) or die(s('dberror'));
while ($r = mysql_fetch_array($result)) {
// check the first 6 letters in comment, if they are equal to #code# then display admin comment style
//think of the #code# as a password and change it to fit your (paranoid ;) ) needs
//hint: in this example #code# is a 6-digit string - you can change its size as well, but then you must also change the number in the function below

if (substr(cleanXSS($r['comment']), 0, 6) === '#code#')
{echo "

" .ltrim(cleanXSS($r['comment']), '#code#'). "

";}
else
{echo "

" .cleanXSS($r['comment']). "

";}
...
note: this is not a bulletproof solucija, but it should do as long as you keep your #code# secret

of course, suggestions and comments are always welcome :)

user manual:
- after you apply this mod to the snews.php, admin styled comments are simple to achieve - all you have to do is to type your #code# in comments form and then your comment
- you are strongly encouraged to change your admin style password according to notes provided in the mod itself
- hint: your password can be |your-pass| or ^your-pass^ or 123your-pass321... or any other alphanumeric "word" that's hard to guess by an average user. in my case it's #code# (including # just for distinction from rest of the text)

before (admin doesn't have to be logged in to perform this):


after (normal view):


EDIT: added user manual
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4867
  • I'm a self-made man and worships my creator.
    • p-ahlqvist.com
[MOD] Highlighted admin comments (sNews 1.4)
« Reply #1 on: June 12, 2006, 11:06:09 am »

Whohaaa. Nice. Gonna try this one. this is for highligtning my comments as an admin, right ? something like I do it already at my site by using the italic tag when answering comments made by others ???

P
Logged
"It's only dead fish that goes with the flow... "
Updated

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
[MOD] Highlighted admin comments (sNews 1.4)
« Reply #2 on: June 12, 2006, 11:19:20 am »

yep ;)
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4867
  • I'm a self-made man and worships my creator.
    • p-ahlqvist.com
[MOD] Highlighted admin comments (sNews 1.4)
« Reply #3 on: June 12, 2006, 12:12:43 pm »

El Greato thingo los made para tu :)
Logged
"It's only dead fish that goes with the flow... "
Updated

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4867
  • I'm a self-made man and worships my creator.
    • p-ahlqvist.com
[MOD] Highlighted admin comments (sNews 1.4)
« Reply #4 on: June 15, 2006, 05:35:59 pm »

Done. inserted and greatly working, Mika. Thanks a bunch for this handymod ;).
Logged
"It's only dead fish that goes with the flow... "
Updated

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
[MOD] Highlighted admin comments (sNews 1.4)
« Reply #5 on: June 15, 2006, 05:56:53 pm »

*thumbs-up* patric, i'm glad to see you're satisfied with it :)
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

David

  • Hero Member
  • *****
  • Karma: 7
  • Posts: 567
[MOD] Highlighted admin comments (sNews 1.4)
« Reply #6 on: June 15, 2006, 06:50:37 pm »

Yea...Great Mod Mika, works fine on my website too :)

Thanks for your work!

Avenir
Logged

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
[MOD] Highlighted admin comments (sNews 1.4)
« Reply #7 on: June 15, 2006, 10:41:37 pm »

Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

Luka

  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 36
  • Posts: 1717
    • http://www.snewscms.com
[MOD] Highlighted admin comments (sNews 1.4)
« Reply #8 on: June 15, 2006, 10:48:27 pm »

Hehe, imageshack... :)
Logged

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
[MOD] Highlighted admin comments (sNews 1.4)
« Reply #9 on: June 15, 2006, 11:43:04 pm »

what to say, you have a smiley addict here to cope with... :lol:

*two minutes later*

well, what are you waiting for? give us some more smilies!! :lol: :lol:
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4867
  • I'm a self-made man and worships my creator.
    • p-ahlqvist.com
[MOD] Highlighted admin comments (sNews 1.4)
« Reply #10 on: June 16, 2006, 07:47:35 am »

Here are  5-6 new smileys...: http://p-ahlqvist.com/examples/smileys.zip

P
Logged
"It's only dead fish that goes with the flow... "
Updated

bryn

  • Hero Member
  • *****
  • Karma: 2
  • Posts: 934
    • http://www.cssugly.com
[MOD] Highlighted admin comments (sNews 1.4)
« Reply #11 on: June 16, 2006, 09:36:12 am »

excellent work mika..exactly what I wanted for a project..thanks very much :D
Logged
Over 1,000 posts of joy, sNews is not only brilliant, but fun too! thanks guys :D

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
[MOD] Highlighted admin comments (sNews 1.4)
« Reply #12 on: June 16, 2006, 09:41:38 am »

ok, here's highlighted admin comments v0.2 for sNews1.4

changes:
- admin password is moved to the administration language variables so the user doesn't have to perform additional tweaks
- added admin editing mode
- updated user manual

1. backupbackupblahblah..

2. add this into //administration language variables (snews.php)
Quote
// ADMINISTRATION LANGUAGE VARIABLES
...
$l['enable_commenting'] = "Enable commenting";
$l['admin_comment_password'] = "#code#"; //password to unleash :D special "admin-style" comment look
$l['admin_edit_start'] = "#start#"; //start editing other user's post
$l['admin_edit_stop'] = "#stop#"; //stop editing other user's post

//think of the #code#, #start# and #stop# as they're passwords (actually they are) and change them to fit your (paranoid ;) ) needs
...
3. add this into // CLEAN - XSS stuff clean (snews.php)
Quote
// CLEAN - XSS stuff clean.
function cleanXSS($text) {
   $allowedtags = '

  • ';
    ...
    4. in your css file (images/style.css) add this
    Quote
    ...
    /*changes the whole comments div when admin is posting*/
    .admincomments {your-style-goes-here}
    /*changes only the admin text when editing user's post*/
    .admineditcomments {your-style-goes-here-too}
    ...
    5. find in //COMMENTS (snews.php)
    Quote
    //COMMENTS
    ...
    $query  = "SELECT * FROM " .s('prefix'). "comments WHERE articleid = $articleid ORDER by id $comments_order LIMIT $offset, $results_per_page";
    $result = mysql_query($query) or die(s('dberror'));
    while ($r = mysql_fetch_array($result)) {
    echo "

    " .cleanXSS($r['comment']). "

    ";
    ...
    6. and replace it with
    Quote
    //COMMENTS
    ...
    $query  = "SELECT * FROM " .s('prefix'). "comments WHERE articleid = $articleid ORDER by id $comments_order LIMIT $offset, $results_per_page";
    $result = mysql_query($query) or die(s('dberror'));
    while ($r = mysql_fetch_array($result)) {
    $r['comment'] = str_replace('l('admin_edit_start')', '', $r['comment']);
    $r['comment'] = str_replace('l('admin_edit_stop')', '
    ', $r['comment']);
    if (substr(cleanXSS($r['comment']), 0, strlen(l('admin_comment_password'))) === l('admin_comment_password'))
    {echo "

    " .ltrim(cleanXSS($r['comment']), l('admin_comment_password')). "

    ";}
    else
    {echo "

    " .cleanXSS($r['comment']). "

    ";}

    ...
    7. user manual is in the first post on top of this page and additonal admin editing options are here as follows:

    before (admin is logged in when editing unsuitable comments):


    after (normal view):
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4867
  • I'm a self-made man and worships my creator.
    • p-ahlqvist.com
[MOD] Highlighted admin comments (sNews 1.4)
« Reply #13 on: June 16, 2006, 11:58:37 am »

Ahhhh. mika-boy :) A variation of what I asked for... Will update my snews this weekend. Great job, mate.

Patric.
Logged
"It's only dead fish that goes with the flow... "
Updated

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
[MOD] Highlighted admin comments (sNews 1.4)
« Reply #14 on: June 16, 2006, 02:26:47 pm »

Quote from: "bryn"
excellent work mika..exactly what I wanted for a project..thanks very much
hi bryn and thx for the support...this goes to you all guys :)
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version
Pages: [1] 2