Need help with "Profile Views Mod"

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   Need help with "Profile Views Mod"
BombSquad
CZ Super Newbie
 Codezwiz Site Donator
BombSquad has been a member for over 20 year's 20 Year Member
usa.gif alabama.gif
Gender: Male
Status: Offline
Joined: Apr 02, 2004
0.00 posts per day
Posts: 35
Points: 3,162
   
I am trying to install a mod into my forums that lets people see how many times their profile has been viewed. But I keep getting an error saying that the table doesnt exist for "PROFILE_VIEWS_TABLE". I am using a modified version of CZ Enhanced 7.0.

Here is the code for the mod:

#
#-----[ SQL ]-------------------------------------------
#
ALTER TABLE phpbb_users ADD user_profile_views mediumint( 8 ) NOT NULL;

#
#-----[ SQL ]-------------------------------------------
#
CREATE TABLE phpbb_profile_views (   user_id      mediumint( 8 )   NOT NULL,
               time      int( 11 )   NOT NULL,
               ip_address   char( 20 )   NOT NULL );

#
#-----[ OPEN ]------------------------------------------
#
includes/usercp_viewprofile.php

#
#-----[ FIND ]------------------------------------------
#
if ( empty($HTTP_GET_VARS[POST_USERS_URL]) || $HTTP_GET_VARS[POST_USERS_URL] == ANONYMOUS )
{
   message_die(GENERAL_MESSAGE, $lang['No_user_id_specified']);
}
$profiledata = get_userdata($HTTP_GET_VARS[POST_USERS_URL]);

#
#-----[ AFTER, ADD ]------------------------------------------
#
// Profile Views MOD, By Manipe (Begin)
$current_time = time();
$delete_time = $current_time - 86400;

//
// Delete old entries
//
$sql = "DELETE FROM " . PROFILE_VIEWS_TABLE . "
   WHERE time < '$delete_time'";
if ( !($result = $db->sql_query($sql)) )
{
   message_die(GENERAL_ERROR, 'Could not update profile views', '', __LINE__, __FILE__, $sql);
}

//
// Find out if the same person has visited the same user profile
//
$sql = "SELECT ip_address
   FROM " . PROFILE_VIEWS_TABLE . "
   WHERE ip_address = '$user_ip'
      AND user_id = '" . $profiledata['user_id'] . "'";
if ( !($result = $db->sql_query($sql)) )
{
   message_die(GENERAL_ERROR, 'Could not update profile views', '', __LINE__, __FILE__, $sql);
}
$is_ip_there = $db->sql_fetchrow($result);
$db->sql_freeresult($result);

//
// If so, don't incriment the profile views counter
//
if ( empty($is_ip_there['ip_address'][0]))
{
   $sql = "INSERT INTO " . PROFILE_VIEWS_TABLE . " (user_id, time, ip_address)
      VALUES ('" . $profiledata['user_id'] . "', '$current_time', '$user_ip')";
   if ( !($result = $db->sql_query($sql)) )
   {
      message_die(GENERAL_ERROR, 'Could not update profile views', '', __LINE__, __FILE__, $sql);
   }

   $sql = "UPDATE " . USERS_TABLE . "
      SET user_profile_views = user_profile_views + 1
      WHERE user_id = '" . $profiledata['user_id'] . "'";
   if ( !($result = $db->sql_query($sql)) )
   {
      message_die(GENERAL_ERROR, 'Could not update profile views', '', __LINE__, __FILE__, $sql);
   }
}

//
// Retrieve the number of views
//
$sql = "SELECT user_profile_views
   FROM " . USERS_TABLE . "
   WHERE user_id = " . $profiledata['user_id'];
if ( !($result = $db->sql_query($sql)) )
{
   message_die(GENERAL_ERROR, 'Could not retreive profile views', '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
$total_profile_views =  ( $row['user_profile_views'] ) ? $row['user_profile_views'] : 0;
$db->sql_freeresult($result);
// Profile Views MOD, By Manipe (End)

#
#-----[ FIND ]------------------------------------------
#
   'YIM_IMG' => $yim_img,
   'YIM' => $yim,

#
#-----[ AFTER, ADD ]------------------------------------------
#
// Profile Views MOD, By Manipe (Begin)
   'L_PROFILE_VIEWS' => $lang['Profile_views'],
   'PROFILE_VIEWS' => $total_profile_views,
// Profile Views MOD, By Manipe (End)

#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_main.php

#
#-----[ FIND ]------------------------------------------
#
//
// That's all, Folks!

#
#-----[ BEFORE, ADD ]------------------------------------------
#
// Profile Views MOD, By Manipe (Begin)
$lang['Profile_views'] = 'Profile Views';
// Profile Views MOD, By Manipe (End)

#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/profile_view_body.tpl

#
#-----[ FIND ]------------------------------------------
#
      <tr>
        <td valign="middle" align="right" nowrap="nowrap"><span class="gen">{L_JOINED}:&nbsp;</span></td>
        <td width="100%"><b><span class="gen">{JOINED}</span></b></td>
      </tr>

#
#-----[ BEFORE, ADD ]------------------------------------------
#
      <tr>
        <td valign="middle" align="right" nowrap="nowrap"><span class="gen">{L_PROFILE_VIEWS}:&nbsp;</span></td>
        <td width="100%"><b><span class="gen">{PROFILE_VIEWS}</span></b></td>
      </tr>

#
#-----[ OPEN ]------------------------------------------
#
includes/constants.php

#
#-----[ FIND ]------------------------------------------
#
define('VOTE_USERS_TABLE', $table_prefix.'vote_voters');

#
#-----[ AFTER, ADD ]------------------------------------------
#
// Profile Views MOD, By Manipe (Begin)
define('PROFILE_VIEWS_TABLE', $table_prefix.'profile_views');
// Profile Views MOD, By Manipe (End)

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#

# EoM



Back to top Reply with quote
#2   re: Need help with "Profile Views Mod"
BombSquad
CZ Super Newbie
 Codezwiz Site Donator
BombSquad has been a member for over 20 year's 20 Year Member
usa.gif alabama.gif
Gender: Male
Status: Offline
Joined: Apr 02, 2004
0.00 posts per day
Posts: 35
Points: 3,162
   
Can a Mod or Admin move this topic to "BBtoNuke Mods Help". I posted in the wrong place again, sorry...



Back to top Reply with quote
#3   re: Need help with "Profile Views Mod"
Taut
PayPal Donation
CZ Revered Member
 Codezwiz Site Donator
usa.gif california.gif
Occupation: Entrepreneur
Gender: Female
Fav. Sports Team: SF Giants
Status: Offline
Joined: May 27, 2003
0.70 posts per day
Posts: 5530
Points: 481,695
   
that's cause it didnt create the table in your db. Your SQL file is telling it to create in

ALTER TABLE phpbb_users

which is only for stand alone phpbb forums. The Nuke forums should start with

nuke_users not phpbb_users

Try changing it to that



Back to top Reply with quote
#4   re: Need help with "Profile Views Mod"
BombSquad
CZ Super Newbie
 Codezwiz Site Donator
BombSquad has been a member for over 20 year's 20 Year Member
usa.gif alabama.gif
Gender: Male
Status: Offline
Joined: Apr 02, 2004
0.00 posts per day
Posts: 35
Points: 3,162
   
I added the tables as you suggested, but it didnt work right. Kept getting the same error.



Back to top Reply with quote
#5   re: Need help with "Profile Views Mod"
Taut
PayPal Donation
CZ Revered Member
 Codezwiz Site Donator
usa.gif california.gif
Occupation: Entrepreneur
Gender: Female
Fav. Sports Team: SF Giants
Status: Offline
Joined: May 27, 2003
0.70 posts per day
Posts: 5530
Points: 481,695
   
did you add them directly thru phpmyadmin?



Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum