Subject:*
<
Name/Email:*
<
Message Icon:*
<
Select*
<
Message:*
<



Click the Preview to see the content in action.
Options:*
<
Confirmation Code*
<
2 + 2 = ?  
Input the result from the expression
Maximum attempts you can try: 10
*
<
     
query("SELECT ratinguser FROM ".$xoopsDB->prefix("users_votedata")." WHERE uid=$uid"); while(list($ratinguserDB)=$xoopsDB->fetchRow($result)) { if ($ratinguserDB==$ratinguser) { redirect_header("userinfo.php?uid=$uid",4,_US_VOTEONCE); exit(); } } // Check if ANONYMOUS user is trying to vote more than once per day. if ($ratinguser==0){ $yesterday = (time()-(86400 * $anonwaitdays)); $result=$xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("users_votedata")." WHERE uid=$uid AND ratinguser=0 AND ratinghostname = '$ip' AND ratingtimestamp > $yesterday"); list($anonvotecount) = $xoopsDB->fetchRow($result); if ($anonvotecount >= 1) { redirect_header("userinfo.php?uid=$uid",4,_US_VOTEONCE); exit(); } } //All is well. Add to Line Item Rate to DB. $newid = $xoopsDB->genId("users_votedata_ratingid_seq"); $datetime = time(); $xoopsDB->query("INSERT INTO ".$xoopsDB->prefix("users_votedata")." (ratingid, uid, ratinguser, rating, ratinghostname, ratingtimestamp) VALUES ($newid, $uid, $ratinguser, $rating, '$ip', $datetime)") or $eh("0013"); //All is well. Calculate Score & Add to Summary (for quick retrieval & sorting) to DB. //updates rating data in itemtable for a given item $query = "select rating FROM ".$xoopsDB->prefix("users_votedata")." WHERE uid = $uid"; $voteresult = $xoopsDB->query($query); $votesDB = $xoopsDB->getRowsNum($voteresult); $totalrating = 0; while(list($rating)=$xoopsDB->fetchRow($voteresult)){ $totalrating += $rating; } $finalrating = $totalrating/$votesDB; $finalrating = number_format($finalrating, 4); $query = "UPDATE ".$xoopsDB->prefix("users")." SET rating=$finalrating, votes=$votesDB WHERE uid = $uid"; $xoopsDB->query($query); $ratemessage = _US_VOTEAPPRE."".sprintf(_US_THANKYOU,$xoopsConfig[sitename]); redirect_header("userinfo.php?uid=$uid",4,$ratemessage); exit(); } else { include(XOOPS_ROOT_PATH."/header.php"); OpenTable(); $result=$xoopsDB->query("SELECT uname FROM ".$xoopsDB->prefix("users")." WHERE uid=$uid"); list($uname) = $xoopsDB->fetchRow($result); $uname = $myts->makeTboxData4Show($uname); echo " $uname "._US_VOTEONCE." "._US_RATINGSCALE." "._US_BEOBJECTIVE." "._US_DONOTVOTE.""; echo " --"; for($i=10;$i>0;$i--){ echo "".$i."\n"; } echo ""; echo " \n"; echo ""; CloseTable(); } include XOOPS_ROOT_PATH."/footer.php"; ?> [/code] Create a newfiletexte ,paste all contents ,and rename it "user_rate.php" and send it in XOOPS racine (where is userinfo.php" 2 - Open userinfo.php and add this line just before "$gperm_handler" [code]//hack compteur de visite du profil $page = !empty($HTTP_GET_VARS['page']) ? trim($HTTP_GET_VARS['page']) : ''; if ($page != '') { $page = $HTTP_GET_VARS['page']; } else { $xoopsDB->queryF("update ".$xoopsDB->prefix("users")." set hits=hits+1 where uid=$uid "); } //fin du hack[/code] Add this both line after this line :$xoopsTpl->assign('lang_avatar', _US_AVATAR); [code]$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);[/code] 3 - Open kernel\user.php and add this 3 lines 108 [code] $this->initVar('votes', XOBJ_DTYPE_OTHER, null, false); $this->initVar('hits', XOBJ_DTYPE_OTHER, null, false); $this->initVar('rating', XOBJ_DTYPE_OTHER, null, false);[/code] 4 - Open language\english\user.php and add this lines at end [code]define("_US_VOTEAPPRE","Votre vote est apprécié."); define("_US_THANKYOU","Merci de prendre le temps pour votez pour un membre ici sur %s"); // %s is your site name define("_US_VOTEONCE","Merci de ne pas voter pour le même membre plus d'une fois."); define("_US_RATINGSCALE","L'échelle est 1 - 10, avec 1 étant faible et 10 étant excellent."); define("_US_BEOBJECTIVE","Merci d'être objectif, si tous reçoivent un 1 ou un 10, les notations ne sont pas très utiles."); define("_US_DONOTVOTE","Ne votez pas pour vous memes."); define("_US_RATEIT","Votez pour ce membre !"); define("_US_CANCEL","Annuler !"); define("_US_NORATING","Vous avez annuler le vote!");[/code] define in your language ,look in module mydownloads what is writting for example 5 - Open modules\system\template\system_userinfo.html and add this lines where you want this is vote button ,the best place is at beginning [code][/code] Remplace your table "statistics" by this table ,they will display usr visit statistics and user votes statistics now [code] [/code] 6 - The last operation ,before to beginning save your database ok go in your MySQL database ,click on "sql" and past this folder lines,and click on execute [code] ALTER TABLE `xoops_users` ADD `hits` int(11) NOT NULL default '0', ADD `rating` double(6,4) NOT NULL default '0.0000', ADD `votes` int(5) unsigned NOT NULL default '0', -- -- Structure de la table `xoops_users_votedata` -- CREATE TABLE `xoops_users_votedata` ( `ratingid` int(11) unsigned NOT NULL auto_increment, `uid` int(11) unsigned NOT NULL default '0', `ratinguser` int(11) NOT NULL default '0', `rating` tinyint(3) unsigned NOT NULL default '0', `ratinghostname` varchar(60) NOT NULL default '', `ratingtimestamp` int(10) NOT NULL default '0', PRIMARY KEY (`ratingid`), KEY `ratinguser` (`ratinguser`), KEY `ratinghostname` (`ratinghostname`), KEY `pid` (`uid`) ) ENGINE=MyISAM ; [/code] Don't forget to change prefix if your prefixe is not "xoops" :-D that's all,normally your hack work as well now best regards[/quote]" />

Re: Adding users vote + user visit counter in your members profils
by soulhex on 2007/9/23 22:40:57

Everything is done about userinfo.php.it is running carefully. But I have problem with user_rate.php. it is not running. I see only a blank page. Anyone can help me about this ? or can you send me the running version of user_rate.php ?
Re: Adding users vote + user visit counter in your members profils
by jordi_rc on 2006/10/25 5:19:19

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
Re: Adding users vote + user visit counter in your members profils
by daviddu54 on 2006/10/25 0:31:42

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?
Re: Adding users vote + user visit counter in your members profils
by jordi_rc on 2006/10/23 13:29:59

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
Re: Adding users vote + user visit counter in your members profils
by jordi_rc on 2006/10/22 17:38:42

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.

Who's Online

133 user(s) are online (81 user(s) are browsing Support Forums)


Members: 0


Guests: 133


more...

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!

Latest GitHub Commits