Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

star rating system

y2kbgy2kbg New
edited March 2007 in Vanilla 1.0 Help
well i am trying to in corparate this unobtrusive star rater( with my vanilla forum, just a bunch on a page manager page. I have it all working but not as an extension nor does it track vanilla username to limit votes(it tracks ip numbers) I found the part of each script where it says $ip = and switch it to context+>/..whatever it is to get the username and and amble echo the username from in the function but when used to assign to ip it just messed up. any one done this yet? or a sugestion/help(i think it may have something todo with a part i saw that said serialize bt i dont know what that does but am doing more research now.)


  • bumper* + info well am am able to get it to write vanilla username to database but it messes up when it tryes to process a vote.
  • and one other thing!! it works when i turn off javascript(tho it downgrades to having to refresh) so the problem is most likely in rpc.php i hope somepeople are look into this for me.
  • Well we cant see the contents of a php file so if you wanted us to look at what you believe the problem to be you'd need to paste the code for us.
  • y2kbgy2kbg New
    edited December 2006
    The link i gave had all of the source code

    this is not my website but the link to all the source:

    <?php /* Page: rpc.php Created: Aug 2006 This page handles the 'AJAX' type response if the user has Javascript enabled. --------------------------------------------------------- ryan masuga, [email protected] --------------------------------------------------------- */ header("Cache-Control: no-cache"); header("Pragma: nocache"); require('_config-rating.php'); // get the db connection info //getting the values $vote_sent = $_REQUEST['j']; $id_sent = $_REQUEST['q']; $ip_num = $_REQUEST['t']; $units = $_REQUEST['c']; //$ip = $_SERVER['REMOTE_ADDR']; $ip = $ip_num; //connecting to the database to get some information $query = mysql_query("SELECT total_votes, total_value, used_ips FROM $tableName WHERE id='$id_sent' ")or die(" Error: ".mysql_error()); $numbers = mysql_fetch_assoc($query); $checkIP = unserialize($numbers['used_ips']); echo $checkIP; $count = $numbers['total_votes']; //how many votes total $current_rating = $numbers['total_value']; //total number of rating added together and stored $sum = $vote_sent+$current_rating; // add together the current vote value and the total vote value $tense = ($count==1) ? "vote" : "votes"; //plural form votes/vote // checking to see if the first vote has been tallied // or increment the current number of votes ($sum==0 ? $added=0 : $added=$count+1); // if it is an array i.e. already has entries the push in another value ((is_array($checkIP)) ? array_push($checkIP,$ip_num) : $checkIP=array($ip_num)); $insertip=serialize($checkIP); if (($vote_sent >= 1 && $vote_sent <= $units) && ($ip == $ip_num)) { // keep votes within range, make sure IP matches - no monkey business! $update = "UPDATE $tableName SET total_votes='".$added."', total_value='".$sum."', used_ips='".$insertip."' WHERE id='$id_sent'"; $result = mysql_query($update); } // these are new queries to get the new values! $newtotals = mysql_query("SELECT total_votes, total_value, used_ips FROM $tableName WHERE id='$id_sent' ")or die(" Error: ".mysql_error()); $numbers = mysql_fetch_assoc($newtotals); $count = $numbers['total_votes'];//how many votes total $current_rating = $numbers['total_value'];//total number of rating added together and stored $tense = ($count==1) ? "vote" : "votes"; //plural form votes/vote $new_back = "<ul class="unit-rating" style="width:". $units*$unitwidth ."px;">n". "<li class="current-rating" style="width:". @number_format($current_rating/$count,2)*$unitwidth ."px;">Current rating.</li>n". "<li class="r1-unit">1</li>n". "<li class="r2-unit">2</li>n". "<li class="r3-unit">3</li>n". "<li class="r4-unit">4</li>n". "<li class="r5-unit">5</li>n". "<li class="r6-unit">6</li>n". "<li class="r7-unit">7</li>n". "<li class="r8-unit">8</li>n". "<li class="r9-unit">9</li>n". "<li class="r10-unit">10</li>n". "</ul>". "<p class="voted">$id_sent. Rating: <strong>".@number_format($sum/$added,1)."</strong>/".$units." (".$count." ".$tense." cast) ". "<span class="thanks">Thanks for voting!</span></p>";//show the updated value of the vote //name of the div id to be updated | the html that needs to be changed $output = "unit_long$id_sent|$new_back"; echo $output; ?>

    you can see where i changed $ip to the username, there are two files tho, one for ajax(this one) and another one that will degrade to a refreshing page if javascript is turned off. The i modifyed the degraded version and got it working so it is just the ajax version that needs to be fixed. i guess there could be another file where it is messed up(one of two .js files whitch can be found in the source.
  • What do you mean when you say it 'messes up' while processing a vote? Unfortunately I'm useless with JS anyway :(
  • no errors or warnings, when i hover over a link i can see that it has the corret link for the vote but when i click it it halfway sends it and there is some ajax but never gets written to database and when it redraws the stars it show with no new votes and no stars at all.
  • And you're sure it's not a browser compatability issue?
  • well when i allow $ip to be set to $_SERVER['REMOTE_ADDR'] (end user ip address) it works just fine. for some reason going from the real ip to assigning it the usename it messes something up

    i have working on this problem for weeks now.
  • i'm writing an extension for this at the moment y2kbg, so could i see how you did it on your site?
  • I guess maybe some of the variable handling in the JS is set to take a numeric value and doesnt like an alphanumeric value... Quick flick through the js files doesnt reveal anything to my untrained eye though, sorry.
  • minisweeper-->same here lol thats what i have been thinking but i dont know any java either

    Vincent-->well what is your problem right now getting the references correct? if so i never got them to work so i just installed the files into the same directory as vanillia but i really want to make it an extension.
  • which javascript and whats happening? does it refresh and work or still not work at all?
  • Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /www/ Rater/default.php on line 49

    but thats not the problem the prob is that it tryed to render the stars before i set up the database
  • TomTesterTomTester New
    edited March 2007
    I came across this post today:
    listing a bunch of WP star rating systems/methods including the one you mentioned...

    They list one that looks really good/simple and uses prototype lite (so should work with the default prototype too, not?):

    Not sure what your goals are, but this 'hosted service' looks easy too

    Note: FWIW, I tried inserting it here, but this cause a weird error in the preview.
    Fatal error: Call to undefined function: getunreadquerystring() in /applications/lussumo/community/extensions/PanelLists/default.php on line 72
This discussion has been closed.