*

wp180

  • **
  • 74
    • Punk-Noz.fr
listviewswinks.php / visitors
« on: February 27, 2013, 12:17:25 PM »
Hello.

If i look who was visiting my profile, i want to see only the last visit of a user (at the moment every visit is in the list).
Also i want to show how many visitors was there since registration.

So what i have to change in listviewswinks.php to do this?

wp180
Osdate 2.6
PHP 5.4.21
MsSQL 5.1.72

*

Vink

  • *****
  • 329
    • NedDate.nl
Re: listviewswinks.php / visitors
« Reply #1 on: February 27, 2013, 07:05:18 PM »
Here you find the answer.. its to large to post so follow the url..
http://forum.tufat.com/showthread.php?t=43821
Regards
Vink
osDate 2.19a | PHP 5.3.8 | MySQL  5.0.91

*

wp180

  • **
  • 74
    • Punk-Noz.fr
Re: listviewswinks.php / visitors
« Reply #2 on: February 28, 2013, 07:19:11 PM »
Thanks, thats it :)

For all other interesting people:

The solution for Osdate 2.5.4+:

Open showprofile.php and search this:

Code: [Select]
$byuser = (isset($_SESSION['UserId']) && $_SESSION['UserId']>0)?$_SESSION['UserId']:-1;

     if (isset($_SESSION['UserId']) && $_REQUEST['id'] != $_SESSION['UserId'] && !isset($_REQUEST['ratingid']) && $byuser != '-1') {

          $osDB->query('insert into ! (userid, ref_userid, act_time, act) values (?, ?, ?, ?)', array( VIEWS_WINKS_TABLE, $_REQUEST['id'], $byuser, time(), 'V' ) );

}

and replace with (the prefix at the database is osdate_..., if not, change it):

Code: [Select]
//Begin Views Fix

$viewer = ($_SESSION['UserId']>0)?$_SESSION['UserId']:-1; //The userid of the person viewing the profile
$viewed = $_REQUEST['id']; //The userid of the profile owner

//Note: In the following line, the prefix of osdate will have to be changed to whatever
//your views_winks table name is, if you have changed the default.
$query = "SELECT * FROM osdate_views_winks WHERE userid=$viewed AND ref_userid=$viewer AND act='V'";
$result = mysql_query($query); //Run the query
$num_rows = mysql_num_rows($result); //Get the query results, if any

if ($num_rows == 0) { //If the user has not already viewed the profile

$sql = 'insert into ! (userid, ref_userid, act_time, act) values (?, ?, ?, ?)'; //Set the query

if ($_REQUEST['id'] != $_SESSION['UserId'] && !isset($_REQUEST['ratingid']) ) { //If the user is not viewing their own profile
$osDB->query($sql, array( VIEWS_WINKS_TABLE, $_REQUEST['id'], $viewer, time(), 'V' ) ); //Add the view to the db
}
} else {
$sql = 'UPDATE ! SET act_time = ? WHERE userid = ? AND ref_userid = ? AND act = ?';

    $osDB->query( $sql, array( VIEWS_WINKS_TABLE, time(), $_REQUEST['id'], $viewer, 'V' ) );

}

//End Views Fix

Go into your database in phpMyAdmin, click on your osdate_views_winks table (or the same table depending on your table prefix), and click "Empty" at the top of phpMyAdmin. This will empty your existing rows in just this table which will probably contain many duplicates, which this mod eliminates for the future...but it won't clean up old entries, so you must empty just this table for this mod to work correctly.

Regards, wp180
Osdate 2.6
PHP 5.4.21
MsSQL 5.1.72