PHP Rating code problem

Discussion in 'PHP' started by Talat50, Oct 2, 2010.

  1. #1
    Hello sir i m having problem regarding my work.
    i m having this warning.

    Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of ip_valid(). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer. in functions.php on line 68


    my code.


    1: <?php
    2:
    3: function insert_rating($rating, $article_id)
    4: {
    5: if(mysql_num_rows(mysql_query("SELECT ID FROM articles_ratings
    6: WHERE rater_ip='".mysql_real_escape_string(getIP())."'
    7: AND ID='".mysql_real_escape_string($article_id)."'"))==0)
    8: {
    9: if(mysql_query("INSERT INTO articles_ratings
    10: (`article_id`, `rating_value`, `rater_ip`)
    11: VALUES ('".mysql_real_escape_string($article_id)."',
    12: '".mysql_real_escape_string($rating)."',
    13: '".mysql_real_escape_string(getIP())."')"))
    14: {
    15: $response = 'Thank you for voting this article!';
    16: }
    17: else {
    18: $response = 'Ups. A problem. I was unable to save your rating!';
    19: }
    20: }
    21: else {
    22: $response = 'Sorry but you can only rate once';
    23: }
    24:
    25: $objResponse = new xajaxResponse();
    26: $objResponse->addAssign("response","innerHTML", $response);
    27: return $objResponse;
    28: }
    29:
    30: function ip_first($ips)
    31: {
    32: if (($pos = strpos($ips, ',')) != false)
    33: {
    34: return substr($ips, 0, $pos);
    35: }
    36: else {
    37: return $ips;
    38: }
    39: }
    40:
    41: function ip_valid($ips)
    42: {
    43: if (isset($ips))
    44: {
    45: $ip = ip_first($ips);
    46: $ipnum = ip2long($ip);
    47: if ($ipnum !== -1 && $ipnum !== false && (long2ip($ipnum) === $ip))
    48: {
    49: if (($ipnum < 167772160 || $ipnum > 184549375) &&
    50: ($ipnum < -1408237568 || $ipnum > -1407188993) &&
    51: ($ipnum < -1062731776 || $ipnum > -1062666241))
    52: return true;
    53: }
    54: }
    55: return false;
    56: }
    57:
    58: function getIP()
    59: {
    60: $check = array(
    61: 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_FORWARDED_FOR',
    62: 'HTTP_FORWARDED', 'HTTP_VIA', 'HTTP_X_COMING_FROM', 'HTTP_COMING_FROM',
    63: 'HTTP_CLIENT_IP'
    64: );
    65:
    66: foreach ($check as $c)
    67: {
    68: if (ip_valid(&$_SERVER[$c]))
    69: {
    70: return ip_first($_SERVER[$c]);
    71: }
    72: }
    73: return $_SERVER['REMOTE_ADDR'];
    74: }
    75: ?>


    plz help me to solve this...:
     
    Talat50, Oct 2, 2010 IP
  2. po_taka

    po_taka Peon

    Messages:
    14
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    replace
    68: if (ip_valid(&$_SERVER[$c]))
    with
    68: if (ip_valid($_SERVER[$c]))
     
    po_taka, Oct 2, 2010 IP