11
m0nty
Re: Adding users vote + user visit counter in your members profils
  • 2006/10/20 21:42

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


try removing the single quotes surrounding $ip.

also the $HTTP_POST_VARS vars should be changed to short vars ie. $_POST etc..

and if (!$xoopsUser) is better to use > if (!is_object($xoopsUser)) on line 35, this won't solve the issue you have but it's better to us is_object here.

hopefully that might do the trick

12
irmtfan
Re: Adding users vote + user visit counter in your members profils
  • 2006/10/20 21:54

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


works great in 2.0* in my local.

but i falied to implement it at my 2.2* runing site.

13
jordi_rc
Re: Adding users vote + user visit counter in your members profils
  • 2006/10/21 19:55

  • jordi_rc

  • Not too shy to talk

  • Posts: 114

  • Since: 2006/8/21


Hello again

Thanks m0nty for the advice, but again, that way code is more perfect but it happens the same.
Now I know it is my fault, because of this:

I think the problem is in userinfo.php file. There are many places where to add the lines this hacks says, so I had added the lines in the "if" when one is admin and user. I don't know where is the exact place to add those lines. They have to be placed after defining $thisuser string, so I don't know where.

Can someone that has implemented this hack in his/her XOOPS site with success PLEASE email me the file userinfo.php ? Or maybe can the hack developer explain exactly where to put those lines in that file, or better, post the file as it is after the hack ?

m0nty have you some idea where must I place the lines in userinfo?

Jordi-
"Battles are fought by those with the courage to believe. They are won by those who find the heart to share." -MANOWAR

14
m0nty
Re: Adding users vote + user visit counter in your members profils
  • 2006/10/21 21:04

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


you would add the lines in userinfo.php around line 44 (xoops 2.0.15)

so the userinfo.php would then look like this >

if (!is_object($xoopsUser)) {
redirect_header('index.php',3,_NOPERM);
exit();
}
//hack compteur de visite du profil
    
$page = !empty($_GET['page']) ? trim($_GET['page']) : '';
    if (
$page != '') {
        
$page $_GET['page'];
    } else {
        
$xoopsDB->queryF("update ".$xoopsDB->prefix("users")." set hits=hits+1 where uid=$uid ");
    }
//fin du hack
$gperm_handler = & xoops_gethandler'groupperm' );
$groups is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;

15
jordi_rc
Re: Adding users vote + user visit counter in your members profils
  • 2006/10/22 8:37

  • jordi_rc

  • Not too shy to talk

  • Posts: 114

  • Since: 2006/8/21


Hello again m0nty.

Thanks. I will test if I placed that well.
I think the problem goes on where add this part:

Quote:



Add this both line after this line :$xoopsTpl->assign('lang_avatar', _US_AVATAR);

$xoopsTpl->assign('lang_ratethisuser', _US_RATETHISUSER);
$xoopsTpl->assign('lang_votes', _US_VOTES);
$xoopsTpl->assign('user_votes', $thisUser->getVar('votes'));
$xoopsTpl->assign('lang_hits', _US_HITSC);
$xoopsTpl->assign('user_hits', $thisUser->getVar('hits'));
$rating = $thisUser->getVar("rating");
if (!empty($rating)) {
$xoopsTpl->assign('user_rating', number_format($rating, 2));
}
$xoopsTpl->assign('lang_ratingc', _US_RATINGC);






there are many lines that repeat the line
Quote:

$xoopsTpl->assign('lang_avatar', _US_AVATAR);



So where do you add those lines?

The problem is there, because I added them in the if that sees if one is XOOPS user and admin. But the place to add it for any XOOPS user is not clear for me, as the userinfo.php file is a bit complex.

Where should I add those lines to get the hack working?

Thanks again.

Jordi
"Battles are fought by those with the courage to believe. They are won by those who find the heart to share." -MANOWAR

16
jordi_rc
Re: Adding users vote + user visit counter in your members profils
  • 2006/10/22 9:27

  • jordi_rc

  • Not too shy to talk

  • Posts: 114

  • Since: 2006/8/21


Greetings!


I think it would be easier to get help from you if I paste all my userinfo.php here. As you can see, it comes with the great hack userphoto by m0nty, highly recommended.

Quote:

<?php
// $Id: userinfo.php 2 2005-11-02 18:23:29Z skalpa $
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
// Copyright (c) 2000 XOOPS.org //
// <https://xoops.org/> //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// You may not change or alter any portion of this comment or credits //
// of supporting developers from this source code or any supporting //
// source code which is considered copyrighted (c) material of the //
// original comment or credit authors. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
// ------------------------------------------------------------------------ //

$xoopsOption['pagetype'] = 'user';
include 'mainfile.php';
include_once XOOPS_ROOT_PATH.'/class/module.textsanitizer.php';

include_once XOOPS_ROOT_PATH . '/modules/system/constants.php';

$uid = intval($_GET['uid']);
if ($uid <= 0) {
redirect_header('index.php', 3, _US_SELECTNG);
exit();
}

//hack compteur de visite du profil
$page = !empty($_GET['page']) ? trim($_GET['page']) : '';
if ($page != '') {
$page = $_GET['page'];
} else {
$xoopsDB->queryF("update ".$xoopsDB->prefix("users")." set hits=hits+1 where uid=$uid ");
}
//fin du hack

$gperm_handler = & xoops_gethandler( 'groupperm' );
$groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;

$isAdmin = $gperm_handler->checkRight( 'system_admin', XOOPS_SYSTEM_USER, $groups); // isadmin is true if user has 'edit users' admin rights

if (is_object($xoopsUser)) {
if ($uid == $xoopsUser->getVar('uid')) {
$config_handler =& xoops_gethandler('config');
$xoopsConfigUser =& $config_handler->getConfigsByCat(XOOPS_CONF_USER);
$xoopsOption['template_main'] = 'system_userinfo.html';
include XOOPS_ROOT_PATH.'/header.php';
$xoopsTpl->assign('user_ownpage', true);
$xoopsTpl->assign('lang_editprofile', _US_EDITPROFILE);
$xoopsTpl->assign('lang_avatar', _US_AVATAR);
// hack votos usuarios
$thisUser =& $xoopsUser;
$xoopsTpl->assign('lang_ratethisuser', _US_RATETHISUSER);
$xoopsTpl->assign('lang_votes', _US_VOTES);
$xoopsTpl->assign('user_votes', $thisUser->getVar('votes'));
$xoopsTpl->assign('lang_hits', _US_HITSC);
$xoopsTpl->assign('user_hits', $thisUser->getVar('hits'));
$rating = $thisUser->getVar("rating");
if (!empty($rating)) {
$xoopsTpl->assign('user_rating', number_format($rating, 2));
}
$xoopsTpl->assign('lang_ratingc', _US_RATINGC);
// fin hack
$xoopsTpl->assign('lang_inbox', _US_INBOX);
$xoopsTpl->assign('lang_photo', _US_PHOTO); // added by m0nty for photo hack
$xoopsTpl->assign('lang_logout', _US_LOGOUT);
if ($xoopsConfigUser['self_delete'] == 1) {
$xoopsTpl->assign('user_candelete', true);
$xoopsTpl->assign('lang_deleteaccount', _US_DELACCOUNT);
} else {
$xoopsTpl->assign('user_candelete', false);
}
$thisUser =& $xoopsUser;
// hack user rating

$xoopsTpl->assign('lang_ratethisuser', _US_RATETHISUSER);
$xoopsTpl->assign('lang_votes', _US_VOTES);
$xoopsTpl->assign('user_votes', $thisUser->getVar('votes'));
$xoopsTpl->assign('lang_hits', _US_HITSC);
$xoopsTpl->assign('user_hits', $thisUser->getVar('hits'));
$rating = $thisUser->getVar("rating");
if (!empty($rating)) {
$xoopsTpl->assign('user_rating', number_format($rating, 2));
}
$xoopsTpl->assign('lang_ratingc', _US_RATINGC);
// fin hack
} else {
$member_handler =& xoops_gethandler('member');
$thisUser =& $member_handler->getUser($uid);
if (!is_object($thisUser) || !$thisUser->isActive() ) {
redirect_header("index.php",3,_US_SELECTNG);
exit();
}
$xoopsOption['template_main'] = 'system_userinfo.html';
include XOOPS_ROOT_PATH.'/header.php';
$xoopsTpl->assign('user_ownpage', false);

}
} else {
$member_handler =& xoops_gethandler('member');
$thisUser =& $member_handler->getUser($uid);
if (!is_object($thisUser) || !$thisUser->isActive()) {
redirect_header("index.php",3,_US_SELECTNG);
exit();
}
$xoopsOption['template_main'] = 'system_userinfo.html';
include(XOOPS_ROOT_PATH.'/header.php');
$xoopsTpl->assign('user_ownpage', false);
}
$myts =& MyTextSanitizer::getInstance();
if ( is_object($xoopsUser) && $isAdmin ) {
$xoopsTpl->assign('lang_editprofile', _US_EDITPROFILE);
$xoopsTpl->assign('lang_deleteaccount', _US_DELACCOUNT);
$xoopsTpl->assign('user_uid', $thisUser->getVar('uid'));
}
$xoopsTpl->assign('lang_allaboutuser', sprintf(_US_ALLABOUT,$thisUser->getVar('uname')));
$xoopsTpl->assign('lang_avatar', _US_AVATAR);
// hack votos usuarios
$xoopsTpl->assign('lang_ratethisuser', _US_RATETHISUSER);
$xoopsTpl->assign('lang_votes', _US_VOTES);
$xoopsTpl->assign('user_votes', $thisUser->getVar('votes'));
$xoopsTpl->assign('lang_hits', _US_HITSC);
$xoopsTpl->assign('user_hits', $thisUser->getVar('hits'));
$rating = $thisUser->getVar("rating");
if (!empty($rating)) {
$xoopsTpl->assign('user_rating', number_format($rating, 2));
}
$xoopsTpl->assign('lang_ratingc', _US_RATINGC);
// fin hack
$xoopsTpl->assign('user_avatarurl', 'uploads/'.$thisUser->getVar('user_avatar'));
$xoopsTpl->assign('lang_photo', _US_PHOTO); // added by m0nty for photo hack
$xoopsTpl->assign('user_photourl', 'uploads/'.$thisUser->getVar('user_photo')); // added by m0nty for photo hack
$xoopsTpl->assign('lang_realname', _US_REALNAME);
$xoopsTpl->assign('user_realname', $thisUser->getVar('name'));
$xoopsTpl->assign('lang_website', _US_WEBSITE);
$xoopsTpl->assign('user_websiteurl', '<a href="'.$thisUser->getVar('url', 'E').'" target="_blank">'.$thisUser->getVar('url').'</a>');
$xoopsTpl->assign('lang_email', _US_EMAIL);
$xoopsTpl->assign('lang_privmsg', _US_PM);
$xoopsTpl->assign('lang_icq', _US_ICQ);
$xoopsTpl->assign('user_icq', $thisUser->getVar('user_icq'));
$xoopsTpl->assign('lang_aim', _US_AIM);
$xoopsTpl->assign('user_aim', $thisUser->getVar('user_aim'));
$xoopsTpl->assign('lang_yim', _US_YIM);
$xoopsTpl->assign('user_yim', $thisUser->getVar('user_yim'));
$xoopsTpl->assign('lang_msnm', _US_MSNM);
$xoopsTpl->assign('user_msnm', $thisUser->getVar('user_msnm'));
// -------------- profile fields hack by m0nty ------------------
//$xoopsTpl->assign('lang_birth', _US_AGE);
//$xoopsTpl->assign('user_birth', $thisUser->getVar('user_birth'));
//$xoopsTpl->assign('user_age', CalcAge($thisUser->getVar('user_birth')));
$xoopsTpl->assign('lang_gender', _US_GENDER);
$xoopsTpl->assign('user_gender', $thisUser->getVar('user_gender'));
$xoopsTpl->assign('lang_starsign', _US_STARSIGN);
$xoopsTpl->assign('user_starsign', $thisUser->getVar('user_starsign'));
// ----------- end profile fields hack by m0nty ------------------
$xoopsTpl->assign('lang_location', _US_LOCATION);
$xoopsTpl->assign('user_location', $thisUser->getVar('user_from'));
//$xoopsTpl->assign('lang_occupation', _US_OCCUPATION);
//$xoopsTpl->assign('user_occupation', $thisUser->getVar('user_occ'));
// -------------- profile fields hack by m0nty ------------------
$xoopsTpl->assign('lang_passion', _US_PASSION);
$xoopsTpl->assign('lang_love', _US_LOVE);
$xoopsTpl->assign('user_love', $myts->makeTareaData4Show($thisUser->getVar('user_love', 'N'),0,1,1));
$xoopsTpl->assign('lang_nolove', _US_NOLOVE);
$xoopsTpl->assign('user_nolove', $myts->makeTareaData4Show($thisUser->getVar('user_nolove', 'N'),0,1,1));
$xoopsTpl->assign('lang_playlist', _US_PLAYLIST);
$xoopsTpl->assign('lang_music1', _US_CHAN1);
$xoopsTpl->assign('user_music1', $thisUser->getVar('user_music1'));
$xoopsTpl->assign('lang_music2', _US_CHAN2);
$xoopsTpl->assign('user_music2', $thisUser->getVar('user_music2'));
$xoopsTpl->assign('lang_music3', _US_CHAN3);
$xoopsTpl->assign('user_music3', $thisUser->getVar('user_music3'));
$xoopsTpl->assign('lang_music4', _US_CHAN4);
$xoopsTpl->assign('user_music4', $thisUser->getVar('user_music4'));
$xoopsTpl->assign('lang_music5', _US_CHAN5);
$xoopsTpl->assign('user_music5', $thisUser->getVar('user_music5'));
$xoopsTpl->assign('lang_filmlist', _US_FILMLIST);
$xoopsTpl->assign('lang_film1', _US_FILM1);
$xoopsTpl->assign('user_film1', $thisUser->getVar('user_film1'));
$xoopsTpl->assign('lang_film2', _US_FILM2);
$xoopsTpl->assign('user_film2', $thisUser->getVar('user_film2'));
$xoopsTpl->assign('lang_film3', _US_FILM3);
$xoopsTpl->assign('user_film3', $thisUser->getVar('user_film3'));
$xoopsTpl->assign('lang_film4', _US_FILM4);
$xoopsTpl->assign('user_film4', $thisUser->getVar('user_film4'));
$xoopsTpl->assign('lang_film5', _US_FILM5);
$xoopsTpl->assign('user_film5', $thisUser->getVar('user_film5'));
$xoopsTpl->assign('lang_extras', _US_EXTRAS);
// ----------- end profile fields hack by m0nty ------------------
$xoopsTpl->assign('lang_interest', _US_INTEREST);
$xoopsTpl->assign('user_interest', $thisUser->getVar('user_intrest'));
$xoopsTpl->assign('lang_extrainfo', _US_EXTRAINFO);
$xoopsTpl->assign('user_extrainfo', $myts->makeTareaData4Show($thisUser->getVar('bio', 'N'),0,1,1));
$xoopsTpl->assign('lang_statistics', _US_STATISTICS);
$xoopsTpl->assign('lang_membersince', _US_MEMBERSINCE);
$xoopsTpl->assign('user_joindate', formatTimestamp($thisUser->getVar('user_regdate'),'s'));
$xoopsTpl->assign('lang_rank', _US_RANK);
$xoopsTpl->assign('lang_posts', _US_POSTS);
$xoopsTpl->assign('lang_basicInfo', _US_BASICINFO);
$xoopsTpl->assign('lang_more', _US_MOREABOUT);
$xoopsTpl->assign('lang_myinfo', _US_MYINFO);
$xoopsTpl->assign('user_posts', $thisUser->getVar('posts'));
$xoopsTpl->assign('lang_lastlogin', _US_LASTLOGIN);
$xoopsTpl->assign('lang_notregistered', _US_NOTREGISTERED);

$xoopsTpl->assign('lang_signature', _US_SIGNATURE);
$xoopsTpl->assign('user_signature', $myts->makeTareaData4Show($thisUser->getVar('user_sig', 'N'),0,1,1));

if ($thisUser->getVar('user_viewemail') == 1) {
$xoopsTpl->assign('user_email', $thisUser->getVar('email', 'E'));
} else {
if (is_object($xoopsUser)) {
// All admins will be allowed to see emails, even those that are not allowed to edit users (I think it's ok like this)
if ($xoopsUserIsAdmin || ($xoopsUser->getVar("uid") == $thisUser->getVar("uid"))) {
$xoopsTpl->assign('user_email', $thisUser->getVar('email', 'E'));
} else {
$xoopsTpl->assign('user_email', '&nbsp;');
}
}
}
if (is_object($xoopsUser)) {
$xoopsTpl->assign('user_pmlink', "<a href=\"javascript:openWithSelfMain('".XOOPS_URL."/pmlite.php?send2=1&to_userid=".$thisUser->getVar('uid')."', 'pmlite', 450, 380);\"><img src=\"".XOOPS_URL."/images/icons/pm.gif\" alt=\"".sprintf(_SENDPMTO,$thisUser->getVar('uname'))."\" /></a>");
} else {
$xoopsTpl->assign('user_pmlink', '');
}
$userrank =& $thisUser->rank();
if ($userrank['image']) {
$xoopsTpl->assign('user_rankimage', '<img src="'.XOOPS_UPLOAD_URL.'/'.$userrank['image'].'" alt="" />');
}
$xoopsTpl->assign('user_ranktitle', $userrank['title']);
$date = $thisUser->getVar("last_login");
if (!empty($date)) {
$xoopsTpl->assign('user_lastlogin', formatTimestamp($date,"m"));
}


$module_handler =& xoops_gethandler('module');
$criteria = new CriteriaCompo(new Criteria('hassearch', 1));
$criteria->add(new Criteria('isactive', 1));
$mids =& array_keys($module_handler->getList($criteria));

foreach ($mids as $mid) {
// Hack by marcan : only return results of modules for which user has access permission
if ( $gperm_handler->checkRight('module_read', $mid, $groups)) {
$module =& $module_handler->get($mid);
$results =& $module->search('', '', 5, 0, $thisUser->getVar('uid'));
$count = count($results);
if (is_array($results) && $count > 0) {
for ($i = 0; $i < $count; $i++) {
if (isset($results[$i]['image']) && $results[$i]['image'] != '') {
$results[$i]['image'] = 'modules/'.$module->getVar('dirname').'/'.$results[$i]['image'];
} else {
$results[$i]['image'] = 'images/icons/posticon2.gif';
}

if (!preg_match("/^http[s]*:\/\//i", $results[$i]['link'])) {
$results[$i]['link'] = "modules/".$module->getVar('dirname')."/".$results[$i]['link'];
}

$results[$i]['title'] = $myts->makeTboxData4Show($results[$i]['title']);
$results[$i]['time'] = $results[$i]['time'] ? formatTimestamp($results[$i]['time']) : '';
}
if ($count == 5) {
$showall_link = '<a href="search.php?action=showallbyuser&mid='.$mid.'&uid='.$thisUser->getVar('uid').'">'._US_SHOWALL.'</a>';
} else {
$showall_link = '';
}
$xoopsTpl->append('modules', array('name' => $module->getVar('name'), 'results' => $results, 'showall_link' => $showall_link));
}
unset($module);
}
}
include XOOPS_ROOT_PATH.'/footer.php';
?>




That's all. Where is the error? I think I made a mistake in where I mentioned in the preceding email.



Jordi.
"Battles are fought by those with the courage to believe. They are won by those who find the heart to share." -MANOWAR

17
jordi_rc
Re: Adding users vote + user visit counter in your members profils
  • 2006/10/22 17:38

  • jordi_rc

  • Not too shy to talk

  • Posts: 114

  • Since: 2006/8/21


Hi all Xoopies

I think I fixed it.

There is a line that is included in userinfo.php if one is admin and user:

Quote:

$xoopsTpl->assign('user_uid', $thisUser->getVar('uid'));


What does this line mean? I think it is included if one is admin because stores the uid of the member that is being seen in profile,in order to modify something. In this case it is the member rating and vote.

AM I RIGHT OR THIS IS DANGEROUS?

This must be included in order to get all members to vote. If I don't do so, uid of member voted is not posted to function.

Also in addition not only 'id' must be between '', seems that I must put all variables in line 75 between '' to work well.

Strange but works.

Jordi.
"Battles are fought by those with the courage to believe. They are won by those who find the heart to share." -MANOWAR

18
jordi_rc
Re: Adding users vote + user visit counter in your members profils
  • 2006/10/23 13:29

  • jordi_rc

  • Not too shy to talk

  • Posts: 114

  • Since: 2006/8/21


It is ok to add this line? Am I right?
If you don't answer I think it is ok.

You should add this line to the hack at least for XOOPS 2.0.15

Jordi
"Battles are fought by those with the courage to believe. They are won by those who find the heart to share." -MANOWAR

19
daviddu54
Re: Adding users vote + user visit counter in your members profils
  • 2006/10/25 0:31

  • daviddu54

  • Just popping in

  • Posts: 22

  • Since: 2006/8/1 2


hi jordi

Sorry for the late answere

you need to edit userinfo.php only if you dont see the button.

what is your problem? button display or sql request error?

20
jordi_rc
Re: Adding users vote + user visit counter in your members profils
  • 2006/10/25 5:19

  • jordi_rc

  • Not too shy to talk

  • Posts: 114

  • Since: 2006/8/21


Hi daviddu54

I saw that if I include this line

Quote:

$xoopsTpl->assign('user_uid', $thisUser->getVar('uid'));


before the hack in userinfo it works all ok.

All is right now and working.
Thanks.

Jordi
"Battles are fought by those with the courage to believe. They are won by those who find the heart to share." -MANOWAR

Login

Who's Online

281 user(s) are online (149 user(s) are browsing Support Forums)


Members: 0


Guests: 281


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits