Welcome to weSEO

Login

Welcome back, nice to see you again.

Register - it's free!

Comment, spread your love, communicate

facebookuser_idlogin form

Welcome back!

Nickname:

Password:

Lost your Password?

Create your new Account

Sign in with Twitter

Nickname:

Mailadress:

Mark Comments as read

Are there any new Comments? You can't realy tell when you come back to a webSPELL-Site. Let's change that, using the same method used to mark Forumthreads as read/unread.

We need a new Column in the ws_user-Table called "comments", Type: Text.
Here is the code of my installer:

Code:
1.
2.
3.
4.
5.
6.
<?php 
 mysql_query("ALTER TABLE `".PREFIX."user` ADD `comments` TEXT");
 mysql_query("UPDATE ".PREFIX."user SET comments='|'");
 
 echo "Column \"comments\" added to PREFIX_user. - <strong style=\"color:red;\">Delete this file now!</strong>";
?>

(you can put this code into "install_comments_read.php", upload it and open it as "yourdomain.com/index.php?site=install_comments_read")

Let's start by editing the comments.php

We have 3 ways of getting new Comments.
1) A Guest posts a new Comment
2) A User posts a new Comment
3) You post a new Comment (we don't need to be notified here)

The first case:
Code:
1.
2.
// Add comment to unread
safe_query("UPDATE ".PREFIX."user SET comments=CONCAT(comments, '".$parentID."+".$type."|') WHERE comments NOT LIKE '%|".$parentID."+".$type."|%'"); // update unread comments, format: |oldstring| => |oldstring|parentID+type|


add this underneath:
Code:
1.
unset($_SESSION['comments_message']);


The second and third case:
Code:
1.
2.
// Add comment to unread
          safe_query("UPDATE ".PREFIX."user SET comments=CONCAT(comments, '".$parentID."+".$type."|') WHERE comments NOT LIKE '%|".$parentID."+".$type."|%' AND userID!='".$userID."'"); // update unread comments, format: |oldstring| => |oldstring|parentID+type|

As you see, we've got almost the same code, only difference is we are leaving the Comment-Poster (case 3) out.

add this unterneath:
Code:
1.
safe_query("INSERT INTO ".PREFIX."comments ( parentID, type, userID, date, comment ) values( '".$parentID."', '".$type."', '".$userID."', '".$date."', '".$message."' ) ");


We are now adding Unseen Comments, now we need to delete them again, after the User has read them.
Code:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
// viewed comments
     if(mysql_num_rows(safe_query("SELECT userID FROM ".PREFIX."user WHERE comments LIKE '%|".$parentID."+".$type."|%'"))) {
          
          $gv=mysql_fetch_array(safe_query("SELECT comments FROM ".PREFIX."user WHERE userID='$userID'"));
          $array=explode("|", $gv['comments']);
          $new='|';
          
          foreach($array as $split) {
               if($split != "" AND $split!=$parentID."+".$type) $new = $new.$split.'|';
          }
          safe_query("UPDATE ".PREFIX."user SET comments='".$new."' WHERE userID='$userID'");
     }
          
     // end viewed comments


This Code can be placed at the end of the comments.php just above:
Code:
1.
2.
}
?>


We now add comments as unseen, and also mark them as seen. What's left is showing the User that there is something new, here is an example for the articles.php:
Code:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
if($userID==0) {
   $hasnewcomment = '<img src="images/comments_old.png" alt="No new Comments" title="No new Comments" style="cursor:help;" />';
   $yesterday = time()-(24*60*60); // Hours*Minutes*Seconds
   
   $newcommis=safe_query("SELECT * FROM ".PREFIX."comments WHERE date>'".$yesterday."' AND type='ar' AND parentID='".$ds['articlesID']."'");
   $anzcommis=mysql_num_rows($newcommis);
   
   if($anzcommis) $hasnewcomment =  '<img src="images/comments_new.png" alt="New Comment" title="New Comment within last 24h" style="cursor:help;" />';
}
else {
     $is_unread = mysql_num_rows(safe_query("SELECT userID FROM ".PREFIX."user WHERE comments LIKE '%|".$ds['articlesID']."+ar|%' AND userID='".$userID."'"));
     if($is_unread) {
          $hasnewcomment =  '<img src="images/comments_new.png" alt="New Comment" title="New Comment" style="cursor:help;" />';
     }
     else {
          $hasnewcomment = '<img src="images/comments_old.png" alt="No new Comments" title="No new Comments" style="cursor:help;" />';
     }
}

As you can see, we tell Guests that there has been a new Comment if it has been posted within the last 24h, Users see the New Comments hint if they haven't visited the Article since there was a new Comment.

This should be added underneath:
Code:
1.
2.
3.
$title='<a href="index.php?site=articles&action=show&articlesID='.$ds['articlesID'].'">'.clearfromtags($ds['title']).'</a>';
$poster='<a href="index.php?site=profile&id='.$ds['poster'].'"><b>'.getnickname($ds['poster']).'</b></a>';
$viewed=$ds['viewed'];


To add this to you News/Clanwars/etc. all you need is to change the two Querys.
Code:
1.
"SELECT * FROM ".PREFIX."comments WHERE date>'".$yesterday."' AND type='ar' AND parentID='".$ds['articlesID']."'

and
Code:
1.
"SELECT userID FROM ".PREFIX."user WHERE comments LIKE '%|".$ds['articlesID']."+ar|%' AND userID='".$userID."'"

You need to change the type (see quote below) and the parendID, which obviously is the articlesID, newsID, etc.

types wrote:

ar=articles
ne=news
ga=gallery
cw=clanwars
de=demos
po=polls
st=static pages


Questions? Feel free to ask in the comments.

Facebook Like for News

Facebook-Like-Button
After Google+ Button for News and Tweet Button for webSPELL here is a quick guide how you can add the Facebook-Like-Button to your webSPELL News.more

Google+ Button for News


As Google+ is getting popular at the moment here is a quick guide on how to use it on your webSPELL-News.

You should give the +1 button API a read first. After you've added the Javascript to your index.php you can add this part into your templates/news.html:

Code:
1.
<g:plusone href="http://$hp_url/index.php?site=news_comments&newsID=$newsID"></g:plusone>


We give the plusone-button the address to the News that is to be +'ed this way it even works on the News-Overview-Page (index.php?site=news).

You might also like: Tweet Button for webSPELL

Delete unactivated Users

Yesterday I was taking a look at weSEO's User-Table in our Database. There were a lot (about 700) Accounts that were not activated and had Mail-addresses that proved my suspicion that these Accounts never would have been activated.

What I've done now is deleting the Accounts that are older then 48h and haven't been activated.

Here is the Code I use:
I have placed it into the register.php
I've also added a notice into the Mail the User gets (edit /languages/**/register.php for that) so he knows that the Link is only valid for 48h.

Login with your Email Address or Username

Tastatur
Ever had the experience that you tried to Login to a Website but you couldn't remember your Username? If you don't want your Users to go through this your simply have to change 2 lines of code in the checklogin.php more