4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: V@no on May 24, 2003, 06:10:27 PM

Title: [Mod] Rating Button Disabled After Vote
Post by: V@no on May 24, 2003, 06:10:27 PM
Many people asked me post the code that will disable "rate form" after visitor voted. (no more error message "Sorry, u have voted ones recently") u can try it youself here (http://gallery.vano.org/7570)
what it does:
1. could be anable/disable to show what was your vote for each picture. (it will show your vote number in the dropdown, but it will be disabled and u wont be able vote again for that image)
2. could be anabled/disabled ability vote for one image by different members who share one computer. (right now, if u and your brother use the same computer, and u visit 4images sites with different login names, after vote either of u, cookies set that nobody else can vote for the same image from same computer)
3. rate form generates automaticaly based on MAX_RATING set in /includes/constants.php

Open /includes/page_header.php
Find:
Code: [Select]
//-----------------------------------------------------
//--- Save Rating -------------------------------------
//-----------------------------------------------------
if ($action == "rateimage" && $id) {
  $rating = intval($HTTP_POST_VARS['rating']);
  $cookie_name = (defined("COOKIE_NAME")) ? COOKIE_NAME : "4images_";
  $cookie_rated = isset($HTTP_COOKIE_VARS[$cookie_name.'rated']) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookie_name.'rated'])) : array();
  if ($rating && $rating <= MAX_RATING && $id) {
    if (!isset($session_info['rated_imgs'])) {
      $session_info['rated_imgs'] = $site_sess->get_session_var("rated_imgs");
    }   
    $split_list = array();
    if (!empty($session_info['rated_imgs'])) {
      $split_list = explode(" ", $session_info['rated_imgs']);
    }
    if (!in_array($id, $split_list) && !in_array($id, $cookie_rated)) {
      $session_info['rated_imgs'] .= " ".$id;
      $session_info['rated_imgs'] = trim($session_info['rated_imgs']);
      $site_sess->set_session_var("rated_imgs", $session_info['rated_imgs']);
      $cookie_rated[] = $id;
      $cookie_expire = time() + 60 * 60 * 24 * 4;
      setcookie($cookie_name.'rated', serialize($cookie_rated), $cookie_expire, COOKIE_PATH, COOKIE_DOMAIN, COOKIE_SECURE);
      update_image_rating($id, $rating);
      $msg = $lang['voting_success'];
    }
    else {
      $msg = $lang['already_voted'];
    }
  }
  else {
    $msg = $lang['voting_error'];
  }
}

//-----------------------------------------------------
//--- Parse Header & Footer ---------------------------
//-----------------------------------------------------
Replace with:
Code: [Select]
//-----------------------------------------------------
//--- Save Rating -------------------------------------
//-----------------------------------------------------

//----- Settings ------------

//change to $rate_suffix = ""; if u dont want remmber votes for different users on same computer
$rate_suffix = "_".$user_info['user_id'];

//--- End Settings ----------

if ($action == "rateimage" && $id) {
  $rating = intval($HTTP_POST_VARS['rating']);
  $cookie_name = (defined("COOKIE_NAME")) ? COOKIE_NAME : "4images_";
  $cookie_rated_array = isset($HTTP_COOKIE_VARS[$cookie_name.'rated'.$rate_suffix]) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookie_name.'rated'.$rate_suffix])) : array();
  if ($rating && $rating <= MAX_RATING && $id) {
    if (!isset($session_info['rated_imgs'.$rate_suffix])) {
      $session_info['rated_imgs'.$rate_suffix] = $site_sess->get_session_var("rated_imgs".$rate_suffix);
    }
    $split_list_array = array();
    if (!empty($session_info['rated_imgs'.$rate_suffix])) {
      $split_list_array = explode(" ", $session_info['rated_imgs'.$rate_suffix]);
    }
    $split_list = array();
    foreach ($split_list_array as $key) {
      $key = explode(",", $key);
      $split_list[] = $key[0];
    }
    $cookie_rated = array();
    foreach ($cookie_rated_array as $key) {
      $key = explode(",", $key);
      $cookie_rated[] = $key[0];
    }
    if (!in_array($id, $split_list) && !in_array($id, $cookie_rated)) {
      $session_info['rated_imgs'.$rate_suffix] .= " ".$id.",".$rating;
      $session_info['rated_imgs'.$rate_suffix] = trim($session_info['rated_imgs'.$rate_suffix]);
      $site_sess->set_session_var("rated_imgs".$rate_suffix, $session_info['rated_imgs'.$rate_suffix]);
      $cookie_rated_array[] = $id.",".$rating;
      $cookie_expire = time() + 60 * 60 * 24 * 4;
      setcookie($cookie_name.'rated'.$rate_suffix, serialize($cookie_rated_array), $cookie_expire, COOKIE_PATH, COOKIE_DOMAIN, COOKIE_SECURE);
      update_image_rating($id, $rating);
      $msg = $lang['voting_success'];
    }
    else {
      $msg = $lang['already_voted'];
    }
  }
  else {
    $msg = $lang['voting_error'];
  }
}

//-----------------------------------------------------
//--- Parse Header & Footer ---------------------------
//-----------------------------------------------------


Open /includes/functions.php
Find:
Code: [Select]
    $site_template->register_vars("rate", $lang['rate']);
    $rate_form = $site_template->parse_template("rate_form");
  }
  $site_template->register_vars("rate_form", $rate_form);
  return true;
}
Replace with:
Code: [Select]
    $rate_form = rate_form($image_row['image_id'], $rate_suffix, $rating);
  }
  $site_template->register_vars("rate_form", $rate_form);

  return true;
}

function rate_form($id, $rate_suffix = "", $rating = ""){
 global $site_template, $session_info, $lang, $site_sess, $HTTP_COOKIE_VARS, $rate_suffix;

  //----- Settings ------------

  //change to $rate_show = 0; if u dont want to show what was your vote for an image
  $rate_show = 1;

  //--- End Settings ----------

  $cookie_name = (defined("COOKIE_NAME")) ? COOKIE_NAME : "4images_";
  $cookie_rated_array = isset($HTTP_COOKIE_VARS[$cookie_name.'rated'.$rate_suffix]) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookie_name.'rated'.$rate_suffix])) : array();
  $split_list_array = array();
  if (!empty($session_info['rated_imgs'.$rate_suffix])) {
    $split_list_array = explode(" ", $session_info['rated_imgs'.$rate_suffix]);
  }
  $cookie_rated = array();
  foreach ($cookie_rated_array as $key) {
    $split = explode(",", $key);
    $cookie_rated[] = $split[0];
    if ($id == $split[0]) {
      $rating = $split[1];
    }
  }
  $split_list = array();
  foreach ($split_list_array as $key) {
    $split = explode(",", $key);
    $split_list[] = $split[0];
    if ($id == $split[0]) {
      $rating = $split[1];
    }
  }
  $no_rateform = (in_array($id, $split_list) || in_array($id, $cookie_rated)) ? "disabled" : 0;
  $rate_options = "<option value=\"\">--</option>\n";
  for ($i = MAX_RATING; $i; $i--){
    $rate_options .= "<option value=\"".$i."\"".(($i == $rating && $rate_show) ? "selected" : "").">".$i."</option>\n";
  }
  $site_template->register_vars(array(
          "rate" => ($no_rateform && !(check_permission("auth_vote", $image_row['cat_id']) && $no_rateform)) ?  "rated" : $lang['rate'],
          "rate_options" => $rate_options,
          "rate_button" => ($no_rateform) ? $no_rateform : ""

    ));
  $rate_form = $site_template->parse_template("rate_form");
  return $rate_form;
}

*In each changed parts u'll find //----- Settings ---------


Open /templates/<yourtemplate>/rate_form.html
replace the code with this:
Code: [Select]
<table border="0" cellspacing="0" cellpadding="1">
  <form method="post" action="{self}">
    <tr>
      <td class="head1">
        <table border="0" cellspacing="0" cellpadding="3" class="row1">
          <tr>
            <td valign="bottom">
              <select name="rating" class="select" {rate_button}>
                {rate_options}
              </select>
            </td>
            <td>
              <input type="hidden" name="action" value="rateimage" />
              <input type="hidden" name="id" value="{image_id}" />
              <input type="submit" value="{rate}" class="button" name="submit" {rate_button} />
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </form>
</table>
Title: [Mod] Rating Button Disabled After Vote
Post by: Xwall on June 01, 2003, 11:24:27 AM
Works well  :wink:

Only one thing, not all people speak english.  :?
Rated -> Calificación

/includes/functions.php

Code: [Select]
"rate" => ($no_rateform && !(check_permission("auth_vote", $image_row['cat_id']) && $no_rateform)) ?  "Calificación" : $lang['rate'],
Title: [Mod] Rating Button Disabled After Vote
Post by: V@no on June 01, 2003, 04:35:33 PM
Quote from: Xwall
Only one thing, not all people speak english.  :?
Rated -> Calificación

/includes/functions.php

Code: [Select]
"rate" => ($no_rateform && !(check_permission("auth_vote", $image_row['cat_id']) && $no_rateform)) ?  "Calificación" : $lang['rate'],

yes, u are right, I just wasnt feel like I want add multilanguage support here...;)
u can replace "Calificación" with $lang['rated'] and then add
$lang['rated'] = "Calificación"; in your /lang/<yourlanguage>/main.php
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: universal on April 23, 2005, 06:50:25 PM
Uch, I tought, that to modify it will be easyer, but look at my rate_form.html
I just want to hide the form after vote...

Code: [Select]
<form action="{self}" method="post" name="RateMe" id="RateMe">
  <table cellspacing="0" cellpadding="1" border="0" style="border-color:#999999; border-style:solid; border-width:1px; ">
    <tr>
      <td> <table cellspacing="0" cellpadding="3" border="0">
          <tr>
            <td width="0" valign="middle"><strong>Ávertink:</strong></td>
            <td width="1" valign="middle"><input onClick="document.RateMe.submit()" type="radio" value="1" name="rating" /></td>
            <td width="1" valign="middle">1</td>
            <td width="1" valign="middle"><input onClick="document.RateMe.submit()" type="radio" value="2" name="rating" /></td>
            <td width="1" valign="middle">2</td>
            <td width="1" valign="middle"><input onClick="document.RateMe.submit()" type="radio" value="3" name="rating" /></td>
            <td width="1" valign="middle">3</td>
            <td width="1" valign="middle"><input onClick="document.RateMe.submit()" type="radio" value="4" name="rating" /></td>
            <td width="1" valign="middle">4</td>
            <td width="1" valign="middle"><input onClick="document.RateMe.submit()" type="radio" value="5" name="rating" /></td>
            <td width="1" valign="middle">5</td>
            <td rowspan="2"> <input type="hidden" name="action" value="rateimage" />
              <input type="hidden" name="id" value="{image_id}" /> </td>
          </tr>
        </table></td>
    </tr>
  </table>
</form>
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: V@no on April 23, 2005, 06:57:42 PM
either install "{ifno ..} {endifno ..}" mod and use {ifno rate_button} and {endifno rate_button} around your form, or in includes/functions.php find:
Code: [Select]
         "rate_options" => $rate_options,insert below:
Code: [Select]
          "show_rate_form" => ($no_rateform) ? 0 : 1,then in your rate_form.html use {if show_rate_form} and {endif show_rate_form} tags ;)
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: universal on April 23, 2005, 10:06:43 PM
great! :) thanks again... ;)
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: V@no on April 23, 2005, 10:12:26 PM
I've told u its easier modify already existing mod then start from scratch ;)
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: graficalicus on May 05, 2005, 07:49:52 PM
V@no - this seems to "expire" after cookies are deleted - seems like there was another "disable rating after vote" thing I used before that just posted a message "Sorry, but you've already voted..."

here's my code from page_header.php:
Code: [Select]
/* //-----------------------------------------------------
//--- Save Rating -------------------------------------
//-----------------------------------------------------
if ($action == "rateimage" && $id) {
  $rating = intval($HTTP_POST_VARS['rating']);
if ($user_info['user_level'] != GUEST) {
$voted_array = array();
if (!empty($user_info['user_voted'])) {
$voted_array = explode(" ", $user_info['user_voted']);
}
$list_rated = array();
foreach ($voted_array as $key) {
$split = explode(",", $key);
$list_rated[] = $split[0];
if ($id == $split[0]) {
$rating = $split[1];
}
}
$rated = in_array($id, $list_rated);
}else{
$rated = FALSE;
}
  $cookie_name = (defined("COOKIE_NAME")) ? COOKIE_NAME : "4images_";
  $cookie_rated = isset($HTTP_COOKIE_VARS[$cookie_name.'rated']) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookie_name.'rated'])) : array();
  if ($rating && $rating <= MAX_RATING && $id) {
    if (!isset($session_info['rated_imgs'])) {
      $session_info['rated_imgs'] = $site_sess->get_session_var("rated_imgs");
    }   
    $split_list = array();
    if (!empty($session_info['rated_imgs'])) {
      $split_list = explode(" ", $session_info['rated_imgs']);
    }
    if (!in_array($id, $split_list) && !in_array($id, $cookie_rated) && !$rated) {

      $session_info['rated_imgs'] .= " ".$id;
      $session_info['rated_imgs'] = trim($session_info['rated_imgs']);
      $site_sess->set_session_var("rated_imgs", $session_info['rated_imgs']);
      $cookie_rated[] = $id;
      $cookie_expire = time() + 60 * 60 * 24 * 4;
      setcookie($cookie_name.'rated', serialize($cookie_rated), $cookie_expire, COOKIE_PATH, COOKIE_DOMAIN, COOKIE_SECURE);
      update_image_rating($id, $rating);
      $msg = $lang['voting_success'];
    }
    else {
      $msg = $lang['already_voted'];
    }
  }
  else {
    $msg = $lang['voting_error'];
  }
}  */
//-----------------------------------------------------
//--- Save Rating -------------------------------------
//-----------------------------------------------------

//----- Settings ------------

//change to $rate_suffix = ""; if u dont want remmber votes for different users on same computer
$rate_suffix = "_".$user_info['user_id'];

//--- End Settings ----------

if ($action == "rateimage" && $id) {
  $rating = intval($HTTP_POST_VARS['rating']);
  $cookie_name = (defined("COOKIE_NAME")) ? COOKIE_NAME : "4images_";
  $cookie_rated_array = isset($HTTP_COOKIE_VARS[$cookie_name.'rated'.$rate_suffix]) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookie_name.'rated'.$rate_suffix])) : array();
  if ($rating && $rating <= MAX_RATING && $id) {
    if (!isset($session_info['rated_imgs'.$rate_suffix])) {
      $session_info['rated_imgs'.$rate_suffix] = $site_sess->get_session_var("rated_imgs".$rate_suffix);
    }
    $split_list_array = array();
    if (!empty($session_info['rated_imgs'.$rate_suffix])) {
      $split_list_array = explode(" ", $session_info['rated_imgs'.$rate_suffix]);
    }
    $split_list = array();
    foreach ($split_list_array as $key) {
      $key = explode(",", $key);
      $split_list[] = $key[0];
    }
    $cookie_rated = array();
    foreach ($cookie_rated_array as $key) {
      $key = explode(",", $key);
      $cookie_rated[] = $key[0];
    }
    if (!in_array($id, $split_list) && !in_array($id, $cookie_rated)) {
      $session_info['rated_imgs'.$rate_suffix] .= " ".$id.",".$rating;
      $session_info['rated_imgs'.$rate_suffix] = trim($session_info['rated_imgs'.$rate_suffix]);
      $site_sess->set_session_var("rated_imgs".$rate_suffix, $session_info['rated_imgs'.$rate_suffix]);
      $cookie_rated_array[] = $id.",".$rating;
      $cookie_expire = time() + 60 * 60 * 24 * 4;
      setcookie($cookie_name.'rated'.$rate_suffix, serialize($cookie_rated_array), $cookie_expire, COOKIE_PATH, COOKIE_DOMAIN, COOKIE_SECURE);
      update_image_rating($id, $rating);
      $msg = $lang['voting_success'];
    }
    else {
      $msg = $lang['already_voted'];
    }
  }
  else {
    $msg = $lang['voting_error'];
  }
}

//-----------------------------------------------------
//--- Parse Header & Footer ---------------------------
//-----------------------------------------------------

I simply commented out what was already there and added this new code - - but users can still vote again the next day - - is this one based on cookies?

thx -
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: V@no on May 05, 2005, 08:26:11 PM
are u saing that if u delete the cookies, u can again vote? - well, yes, what do u expect ;)
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: graficalicus on May 05, 2005, 08:52:06 PM
Quote
if u delete the cookies, u can again vote

but the earlier one stored in the DB, so if a user votes, he can't vote again, ever.  not sure what was different between these two MODS....   :?
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: V@no on May 05, 2005, 09:05:07 PM
these are completly different mods ;)
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: graficalicus on May 06, 2005, 01:44:29 AM
 :lol:   but, as usual, I want to combine 2 MODS   :!:

I like the idea of the rating box showing a user's last rating, but the cookie never expiring so they can't vote again   8)

(nothing's ever good enough for me, as my mom often told me....  :|  )
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: marius26 on November 06, 2005, 11:56:34 PM
and i want one like is on V@no site  :twisted:
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: Lucifix on December 01, 2005, 06:56:20 PM
@veno: remember my problem?  :roll:

This is how my rate_form.html looks like:

Code: [Select]
<table border="0" cellspacing="0" cellpadding="3" class="row1">
                      <tr>
                        <td> <input type="radio" name="rating" value="0">
                          0 - {lang_rate_zero}<br>
<input type="radio" name="rating" value="1.0">
                          1 - {lang_rate_one}<br>
                          <input type="radio" name="rating" value="2.0">
                          2 - {lang_rate_two}<br>
  <input type="radio" name="rating" value="3.0">
                          3 - {lang_rate_three}<br>
                          <input type="radio" name="rating" value="4.0">
                          4 - {lang_rate_four}<br>
                          <input type="radio" name="rating" value="5.0">
                          5 - {lang_rate_five}
</td>
                      </tr>
                    </table>

Can anyone help me solve this problem?
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: Acidgod on December 01, 2005, 07:45:47 PM
this is the first time you post in this thread, so we don´t now your Problem... (o:
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: por4a on December 01, 2005, 11:22:50 PM
Hello, V@no!

How I can do it your code for my template 'rate-form.html'?

Preview my vote:
(http://plmag.com/pix/img.jpg)

I have this code:
Quote
<!-- start rate_form.html -->
<table border="0" align="left" cellpadding="1" cellspacing="0">
              <tr>
      <form method="post" action="{self}">
                <td>
                    <input type="hidden" name="action" value="rateimage" />
                    <input type="hidden" name="id" value="{image_id}" />                   
                  <input type="hidden" name="rating" value="1" />
                    <input src="{template_url}/images/1.gif" type="image" name="Mangelhaft" value="Mangelhaft" alt="Mangelhaft" title="1"/>
                  </td></form><form method="post" action="{self}">
                <td>
                    <input type="hidden" name="action" value="rateimage" />
                    <input type="hidden" name="id" value="{image_id}" />
                    <input type="hidden" name="rating" value="2" />
                    <input src="{template_url}/images/2.gif" type="image" name="Ausreichend" value="Ausreichend" alt="Ausreichend" title="2"/>
                  </td></form><form method="post" action="{self}">
                <td>
                    <input type="hidden" name="action" value="rateimage" />
                    <input type="hidden" name="id" value="{image_id}" />
                    <input type="hidden" name="rating" value="3" />
                    <input src="{template_url}/images/3.gif" type="image" name="Befriedigend" value="Befriedigend" alt="Befriedigend" title="3"/>
                  </td></form><form method="post" action="{self}">
                <td>
                    <input type="hidden" name="action" value="rateimage" />
                    <input type="hidden" name="id" value="{image_id}" />
                    <input type="hidden" name="rating" value="4" />
                    <input src="{template_url}/images/4.gif" type="image" name="Gut" value="Gut" alt="Gut" title="4"/>
                  </td></form><form method="post" action="{self}">
                <td>
                    <input type="hidden" name="action" value="rateimage" />
                    <input type="hidden" name="id" value="{image_id}" />
                    <input type="hidden" name="rating" value="5" />
                    <input src="{template_url}/images/5.gif" type="image" name="Sehr gut" value="Sehr gut" alt="Sehr gut" title="5"/>
              </td></form></tr>
             </td>
      </table>
<!-- end rate_form.html -->
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: V@no on December 02, 2005, 12:19:00 AM
mmm...did u try add {rate_button} inside your "image" button?
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: por4a on December 02, 2005, 12:50:22 AM
Yes!
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: Lucifix on December 02, 2005, 07:07:54 AM
this is the first time you post in this thread, so we don´t now your Problem... (o:

I posted this problem before forum was hecked ;)
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: TIMT on February 06, 2006, 10:35:57 PM
Hi V@no, hi  mawenzi

I have implemented the following MOD:
Votes saved in DB / Version A
http://www.4homepages.de/forum/index.php?topic=6123.0

Now I have installed this MOD.

Now, the vote is stored in the DB, but after deleting Cookies, it is possible to vote again (although the vote is stored in the DB).

Is it possible, that a user can vote only once and disabled the dropdown after voting?

Thanks for helping me!

TIMT
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: TIMT on February 08, 2006, 09:11:17 PM
Anyone else who can give me an answer?
Thanks!
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: fgallery on February 10, 2006, 01:27:53 AM
@TIMT
http://www.4homepages.de/forum/index.php?topic=5853.msg35441#msg35441
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: V@no on February 10, 2006, 01:30:47 AM
http://www.4homepages.de/forum/index.php?topic=6123.msg60531#msg60531
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: Eagle Eye on February 11, 2006, 04:06:13 PM
I wanted to show the download button after rating, like with an info:

please rate this image to get the download link  (before rating)
Thank you for rating this image, your donwload link:  (after rating)

how can i do this ;)
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: Amosnet on September 14, 2006, 10:48:45 PM
Thanks for this great Mod!  :P

I use the phpbb Mod and if i logout, and login i can vote again.
Seems like the cookie is not really stored.

The phpBB Mod dont use the 4image_ Cookie.

 :?: How can i store the Cookie that i rated at my 4images - phpBB Gallery?
How do i set the rate in the phpBB Cookie?

Thank you
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: hyde101 on September 23, 2006, 03:46:14 AM
i think last version has this already built in, but it does not gray out the vote after the first vote..
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: fgabriel on January 07, 2007, 08:40:27 PM
V@no
i installed the mod now when i access for search.php this give me many errors on functions.php
?
do you know wath is this, page_header?


Notice: Undefined variable: rate_suffix in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 464

Notice: Undefined variable: rating in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 464

Notice: Undefined offset: 1 in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 492

Notice: Undefined variable: image_row in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 509

Notice: Undefined variable: rate_suffix in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 464

Notice: Undefined variable: rating in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 464

Notice: Undefined variable: image_row in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 509
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: fgabriel on January 07, 2007, 09:09:34 PM
V@no
i installed the mod now when i access for search.php this give me many errors on functions.php
?
do you know wath is this, page_header?


Notice: Undefined variable: rate_suffix in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 464

Notice: Undefined variable: rating in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 464

Notice: Undefined offset: 1 in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 492

Notice: Undefined variable: image_row in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 509

Notice: Undefined variable: rate_suffix in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 464

Notice: Undefined variable: rating in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 464

Notice: Undefined variable: image_row in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 509



when i go to:
search.php?search_new_images=1

errors:

Notice: Undefined variable: rate_suffix in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 464

Notice: Undefined variable: rating in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 464

Notice: Undefined offset: 1 in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 492

Notice: Undefined variable: image_row in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 509

Notice: Undefined variable: rate_suffix in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 464

Notice: Undefined variable: rating in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 464

Notice: Undefined variable: rate_suffix in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 464

Notice: Undefined variable: rating in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 464

Notice: Undefined variable: image_row in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 509

Notice: Undefined variable: rate_suffix in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 464

Notice: Undefined variable: rating in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 464

Notice: Undefined variable: image_row in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 509

Notice: Undefined variable: rate_suffix in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 464

Notice: Undefined variable: rating in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 464


functions.php 451-516

  if (!empty($additional_image_fields)) {
    $additional_field_array = array();
    foreach ($additional_image_fields as $key => $val) {
      $additional_field_array[$key] = (!empty($image_row[$key])) ? format_text($image_row[$key], 1) : REPLACE_EMPTY;
      $additional_field_array['lang_'.$key] = $val[0];
    }
    if (!empty($additional_field_array)) {
      $site_template->register_vars($additional_field_array);
    }
  }

  $rate_form = "";
  if (check_permission("auth_vote", $image_row['cat_id'])) {
    $rate_form = rate_form($image_row['image_id'], $rate_suffix, $rating);
  }
  $site_template->register_vars("rate_form", $rate_form);

  return true;
}

function rate_form($id, $rate_suffix = "", $rating = ""){
 global $site_template, $session_info, $lang, $site_sess, $HTTP_COOKIE_VARS, $rate_suffix;

  //----- Settings ------------

  //change to $rate_show = 0; if u dont want to show what was your vote for an image
  $rate_show = 1;

  //--- End Settings ----------

  $cookie_name = (defined("COOKIE_NAME")) ? COOKIE_NAME : "4images_";
  $cookie_rated_array = isset($HTTP_COOKIE_VARS[$cookie_name.'rated'.$rate_suffix]) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookie_name.'rated'.$rate_suffix])) : array();
  $split_list_array = array();
  if (!empty($session_info['rated_imgs'.$rate_suffix])) {
    $split_list_array = explode(" ", $session_info['rated_imgs'.$rate_suffix]);
  }
  $cookie_rated = array();
  foreach ($cookie_rated_array as $key) {
    $split = explode(",", $key);
    $cookie_rated[] = $split[0];
    if ($id == $split[0]) {
      $rating = $split[1];
    }
  }
  $split_list = array();
  foreach ($split_list_array as $key) {
    $split = explode(",", $key);
    $split_list[] = $split[0];
    if ($id == $split[0]) {
      $rating = $split[1];
    }
  }
  $no_rateform = (in_array($id, $split_list) || in_array($id, $cookie_rated)) ? "disabled" : 0;
  $rate_options = "<option value=\"\">--</option>\n";
  for ($i = MAX_RATING; $i; $i--){
    $rate_options .= "<option value=\"".$i."\"".(($i == $rating && $rate_show) ? "selected" : "").">".$i."</option>\n";
  }
  $site_template->register_vars(array(
          "rate" => ($no_rateform && !(check_permission("auth_vote", $image_row['cat_id']) && $no_rateform)) ?  "rated" : $lang['rate'],
          "rate_options" => $rate_options,
          "rate_button" => ($no_rateform) ? $no_rateform : ""

    ));
  $rate_form = $site_template->parse_template("rate_form");
  return $rate_form;
}




Title: Re: [Mod] Rating Button Disabled After Vote
Post by: fgabriel on January 07, 2007, 11:25:14 PM
  $rate_form = "";
  $image_row = "";
  $rating = "";
  $rate_suffix = "";
  if (check_permission("auth_vote", $image_row['cat_id'])) {  -------------------------------------------this is 466
    $rate_form = rate_form($image_row['image_id'], $rate_suffix, $rating);
  }
  $site_template->register_vars("rate_form", $rate_form);

  return true;
}

i insert this variables but a error stills:

Notice: Uninitialized string offset: 0 in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 466



V@no
i installed the mod now when i access for search.php this give me many errors on functions.php
?
do you know wath is this, page_header?


Notice: Undefined variable: rate_suffix in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 464

Notice: Undefined variable: rating in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 464

Notice: Undefined offset: 1 in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 492

Notice: Undefined variable: image_row in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 509

Notice: Undefined variable: rate_suffix in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 464

Notice: Undefined variable: rating in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 464

Notice: Undefined variable: image_row in /home/nfnorte/public_html/galerianfn/includes/functions.php on line 509

Title: Re: [Mod] Rating Button Disabled After Vote
Post by: orb42 on January 19, 2007, 04:57:52 PM
Hi,

I got the same error as fgabriel does when I call "New images" link   (http://www.xx.com/search.php?search_new_images=1).

Code: [Select]
Notice: Undefined variable: rate_suffix in /mnt/107/sdc/a/1/x/includes/functions.php on line 446
Notice: Undefined variable: rating in /mnt/107/sdc/a/1/x/includes/functions.php on line 446
Notice: Undefined variable: rate_suffix in /mnt/107/sdc/a/1/x/includes/functions.php on line 446
Notice: Undefined variable: rating in /mnt/107/sdc/a/1/x/includes/functions.php on line 446
Notice: Undefined variable: rate_suffix in /mnt/107/sdc/a/1/x/includes/functions.php on line 446
Notice: Undefined variable: rating in /mnt/107/sdc/a/1/x/includes/functions.php on line 446
Notice: Undefined variable: rate_suffix in /mnt/107/sdc/a/1/x/includes/functions.php on line 446
Notice: Undefined variable: rating in /mnt/107/sdc/a/1/x/includes/functions.php on line 446
Notice: Undefined variable: rate_suffix in /mnt/107/sdc/a/1/x/includes/functions.php on line 446
Notice: Undefined variable: rating in /mnt/107/sdc/a/1/x/includes/functions.php on line 446
Notice: Undefined variable: rate_suffix in /mnt/107/sdc/a/1/x/includes/functions.php on line 446
Notice: Undefined variable: rating in /mnt/107/sdc/a/1/x/includes/functions.php on line 446
Notice: Undefined variable: rate_suffix in /mnt/107/sdc/a/1/x/includes/functions.php on line 446
Notice: Undefined variable: rating in /mnt/107/sdc/a/1/x/includes/functions.php on line 446

This "functions.php" line 445/446 :

 
Code: [Select]
if (check_permission("auth_vote", $image_row['cat_id'])) {
    $rate_form = rate_form($image_row['image_id'], $rate_suffix, $rating);

Anybody helps please? thanks
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: fgabriel on January 19, 2007, 09:36:08 PM
Hi,

I got the same error as fgabriel does when I call "New images" link   (http://www.xx.com/search.php?search_new_images=1).

Code: [Select]
Notice: Undefined variable: rate_suffix in /mnt/107/sdc/a/1/x/includes/functions.php on line 446
Notice: Undefined variable: rating in /mnt/107/sdc/a/1/x/includes/functions.php on line 446
Notice: Undefined variable: rate_suffix in /mnt/107/sdc/a/1/x/includes/functions.php on line 446
Notice: Undefined variable: rating in /mnt/107/sdc/a/1/x/includes/functions.php on line 446
Notice: Undefined variable: rate_suffix in /mnt/107/sdc/a/1/x/includes/functions.php on line 446
Notice: Undefined variable: rating in /mnt/107/sdc/a/1/x/includes/functions.php on line 446
Notice: Undefined variable: rate_suffix in /mnt/107/sdc/a/1/x/includes/functions.php on line 446
Notice: Undefined variable: rating in /mnt/107/sdc/a/1/x/includes/functions.php on line 446
Notice: Undefined variable: rate_suffix in /mnt/107/sdc/a/1/x/includes/functions.php on line 446
Notice: Undefined variable: rating in /mnt/107/sdc/a/1/x/includes/functions.php on line 446
Notice: Undefined variable: rate_suffix in /mnt/107/sdc/a/1/x/includes/functions.php on line 446
Notice: Undefined variable: rating in /mnt/107/sdc/a/1/x/includes/functions.php on line 446
Notice: Undefined variable: rate_suffix in /mnt/107/sdc/a/1/x/includes/functions.php on line 446
Notice: Undefined variable: rating in /mnt/107/sdc/a/1/x/includes/functions.php on line 446

This "functions.php" line 445/446 :

 
Code: [Select]
if (check_permission("auth_vote", $image_row['cat_id'])) {
    $rate_form = rate_form($image_row['image_id'], $rate_suffix, $rating);

Anybody helps please? thanks


im not alone,
i think nobody wants to help orb42  :(
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: orb42 on January 22, 2007, 07:58:49 AM
For this mod, I really don't understand the way the code was insered in "functions.php".

The code insertion proposed is an aberation because it introduces in a function some variables that are not previously defined in the page.

I would like to know what's thinking about the mod's author..
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: urmasmuld on February 19, 2007, 12:04:36 PM
I've same problem =(

Notice: Undefined variable: rate_suffix in /www/01/xxx/xxx/xxx/functions.php on line 449

Notice: Undefined variable: rating in /www/01/xxx/xxx/xxx/functions.php on line 449
 
 
Title: Re: [Mod] Rating Button Disabled After Vote - Bug Fixed
Post by: MacroWorld on April 30, 2007, 11:35:26 AM
Open includes/functions.php

Find:
Code: [Select]
if (check_permission("auth_vote", $image_row['cat_id'])) {
Insert Above:
Code: [Select]
  $rate_suffix = "";
  $rating = "";

Find Next:
Code: [Select]
$site_template->register_vars(array(
          "rate" => ($no_rateform && !(check_permission("auth_vote", $image_row['cat_id']) && $no_rateform)) ?  "rated" : $lang['rate'],
          "rate_options" => $rate_options,
          "rate_button" => ($no_rateform) ? $no_rateform : ""

    ));

Insert Above
Code: [Select]
$image_row = 0;
everything will be OK  :D
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: winracer on November 18, 2009, 07:15:57 PM
my page_header.php looks like this because of other mods.

I would like to have greyed out after user votes and do not want to remmeber the users computer just the username. can this be done using both mods?


Code: [Select]
//-----------------------------------------------------
//--- Save Rating -------------------------------------
//-----------------------------------------------------
if ($action == "rateimage" && $id) {
  $rating = intval($HTTP_POST_VARS['rating']);

  if ($user_info['user_level'] != GUEST) {
    $sql = "SELECT user_id, image_id, vote
            FROM ".VOTED_TABLE."
            WHERE image_id = ".$id." AND user_id = ".$user_info['user_id'];
    $rated = $site_db->query_firstrow($sql);
    $rating = ($rated['vote']) ? $rated['vote'] : $rating;
  }else{
    $rated = FALSE;
  }
  $cookie_name = (defined("COOKIE_NAME")) ? COOKIE_NAME : "4images_";
  $cookie_rated = isset($HTTP_COOKIE_VARS[$cookie_name.'rated']) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookie_name.'rated'])) : array();
  if ($rating && $rating <= MAX_RATING && $id) {
    if (!isset($session_info['rated_imgs'])) {
      $session_info['rated_imgs'] = $site_sess->get_session_var("rated_imgs");
    }
    $split_list = array();
    if (!empty($session_info['rated_imgs'])) {
      $split_list = explode(" ", $session_info['rated_imgs']);
    }
    if (!in_array($id, $split_list) && !in_array($id, $cookie_rated) && !$rated) {
      $session_info['rated_imgs'] .= " ".$id;
      $session_info['rated_imgs'] = trim($session_info['rated_imgs']);
      $site_sess->set_session_var("rated_imgs", $session_info['rated_imgs']);
      $cookie_rated[] = $id;
      $cookie_expire = time() + 60 * 60 * 24 * 4;
      setcookie($cookie_name.'rated', serialize($cookie_rated), $cookie_expire, COOKIE_PATH, COOKIE_DOMAIN, COOKIE_SECURE);
      update_image_rating($id, $rating);
      $msg = $lang['voting_success'];
    }
    else {
      $msg = $lang['already_voted'];
    }
  }
  else {
    $msg = $lang['voting_error'];
  }
}

Title: Re: [Mod] Rating Button Disabled After Vote
Post by: V@no on November 19, 2009, 02:13:28 AM
Sorry, I'm not sure what exactly is your question about...
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: winracer on November 19, 2009, 02:24:13 PM
Sorry, I'm not sure what exactly is your question about...

never mind, I changed my mind and installing the star mod. sorry
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: x23piracy on November 23, 2010, 09:53:44 PM
Hi,

is there an easy way to check before the tag {rate_form} is displayed to check
the user has allready voted before he tries to vote again?

Out of the box he can try it again and the {msg} tag is filled with the you have
allready voted message.

Why the check is not made before a revote try?

Something like: {ifnot user_voted}{rate_form}{endifnot user_voted}


Greetz X23
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: V@no on November 24, 2010, 12:10:59 AM
Your question is not clear. The point of this mod is to disable the rate button after the user's vote...
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: x23piracy on November 24, 2010, 12:16:32 AM
Your question is not clear. The point of this mod is to disable the rate button after the user's vote...

Hi,

you're right but im searching for the right change that makes it possible that the rate_form is
only displayed if the user not allready voted for that image, for example (i wish) with a tag like
{ifnot user_voted}...

Should i start a new thread?


Greetz X23
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: V@no on November 24, 2010, 02:31:20 AM
I see now.
Use {ifno rate_button} ..
Title: Re: [Mod] Rating Button Disabled After Vote
Post by: SweD on November 02, 2011, 11:06:41 AM
Great! Work! I liked it!

Demo: http://www.all-live.ru/