Author Topic: PHP 5.3 issue  (Read 8686 times)

0 Members and 1 Guest are viewing this topic.

Offline batu544

  • Sr. Member
  • ****
  • Posts: 336
    • View Profile
    • Free Celebrity wallpapers
PHP 5.3 issue
« on: May 11, 2012, 11:26:55 PM »
Hi,

Recently I moved into a server where PHP 5.3 is available.. and  I am getting following error message.  .

Could anyone please suggest me how can I fix it.. ?

Error:
Code: [Select]
Warning: strpos() expects parameter 1 to be string, array given in /home/batu544/public_html/includes/sessions.php on line 234

Code on 234 line :

Code: [Select]
if ($ref_url==false) return false;
$ref_domain = str_replace("www.", "", $ref_url['host']);
if ($ref_domain=='') $ref_domain = $ref_url ;
if (strpos($ref_domain, $domain_name)===false)
{
$sql = "SELECT * FROM ".FRIENDS_TABLE." WHERE `url` REGEXP 'http(s)*://(([^/\.])*(/|\.){0,1}){0,1}$ref_domain(/){0,1}.*' ";
$result = $site_db->query($sql);

234 line ==> if (strpos($ref_domain, $domain_name)===false)


Any help will be appreciated.. :)

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: PHP 5.3 issue
« Reply #1 on: May 12, 2012, 09:06:46 PM »
The problem seems to be in this line:
Code: [Select]
if ($ref_domain=='') $ref_domain = $ref_url ;

Can you show the entire function where this code is from?
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline batu544

  • Sr. Member
  • ****
  • Posts: 336
    • View Profile
    • Free Celebrity wallpapers
Re: PHP 5.3 issue
« Reply #2 on: May 12, 2012, 10:55:34 PM »
Hi V@no,

Thanks for your reply..

This is a new code added by me to record friends block hit.. Here is the code details..

Code: [Select]
  function start_session($user_id = GUEST, $login_process = 0) {
    global $site_db;

    $this->user_info = $this->load_user_info($user_id);
    if ($this->user_info['user_id'] != GUEST && !$login_process) {
      if ($this->read_cookie_data("userpass") == $this->user_info['user_password'] && $this->user_info['user_level'] > USER_AWAITING) {
        $this->set_cookie_data("userpass", $this->user_info['user_password']);
      }
      else {
        $this->set_cookie_data("userpass", "", 0);
        $this->user_info = $this->load_user_info(GUEST);
      }
    }

    //if (!$login_process) {
      $sql = "REPLACE INTO ".SESSIONS_TABLE."
              (session_id, session_user_id, session_lastaction, session_location, session_ip)
              VALUES
              ('".addslashes($this->session_id)."', ".$this->user_info['user_id'].", $this->current_time, '$this->user_location', '$this->user_ip')";
      $site_db->query($sql);
    //}

    $this->session_info['session_user_id'] = $this->user_info['user_id'];
    $this->session_info['session_lastaction'] = $this->current_time;
    $this->session_info['session_location'] = $this->user_location;
    $this->session_info['session_ip'] = $this->user_ip;

//**** added for recording friends referal ***************/
$hour = date('H');
if ($hour==0)
{
$sql = "UPDATE ".FRIENDS_TABLE." SET
`daily_visits`=0, `reset_flag`=0
WHERE `reset_flag`=1";
$site_db->query($sql);
}
if ($hour==1)
{
$sql = "UPDATE ".FRIENDS_TABLE." SET
`reset_flag`=1";
$site_db->query($sql);
}

$arr_dom = explode(".", $_SERVER['SERVER_NAME']);
if (count($arr_dom)>2)
{
if (strlen($arr_dom[count($arr_dom)-2])<=3 and strlen($arr_dom[count($arr_dom)-1])==2)
{
$domain_name = $arr_dom[count($arr_dom)-3].".".$arr_dom[count($arr_dom)-2].".".$arr_dom[count($arr_dom)-1];
}
else  {
$domain_name = $arr_dom[count($arr_dom)-2].".".$arr_dom[count($arr_dom)-1];
}
}
else {
$domain_name = $arr_dom[0].".".$arr_dom[1];
}
$ref_url = parse_url(urldecode($_SERVER['HTTP_REFERER'])) ;

if ($ref_url==false) return false;
$ref_domain = str_replace("www.", "", $ref_url['host']);
if ($ref_domain=='') $ref_domain = $ref_url ;
if (strpos($ref_domain, $domain_name)===false)
{
$sql = "SELECT * FROM ".FRIENDS_TABLE." WHERE `url` REGEXP 'http(s)*://(([^/\.])*(/|\.){0,1}){0,1}$ref_domain(/){0,1}.*' ";
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);
$friend = array();
while ($row = $site_db->fetch_array($result)) {
if (preg_match("'http(s)*://(([^/\.])*([/|\.]){1}){0,1}".$ref_domain."(/){0,1}.*'i", $row['url'])==1)
{
$friend = $row;
}

}
if (count($friend)>0) {

$sql = "SELECT * FROM ".FRIENDS_REF_TABLE." WHERE
`ip`='".$_SERVER['REMOTE_ADDR']."'
AND `friend_id`='".$friend['id']."'
AND NOW()<DATE_ADD(`created`, INTERVAL 1 DAY) ";
$check_day = $site_db->query_firstrow($sql);


if (!$check_day)
{
$sql = "INSERT INTO ".FRIENDS_REF_TABLE." SET
`ip`='".$_SERVER['REMOTE_ADDR']."',
`host`='".gethostbyaddr($_SERVER['REMOTE_ADDR'])."',
`created`=NOW(),
`friend_id`='".$friend['id']."'
";
$site_db->query($sql);

$sql = "UPDATE ".FRIENDS_TABLE." SET
`total_visits`=`total_visits`+1,
`daily_visits`=`daily_visits`+1
WHERE `id`='".$friend['id']."'
";
$site_db->query($sql);
}
}
}


//**********************************************************
    if ($this->user_info['user_id'] != GUEST) {
      $this->user_info['user_lastvisit'] = (!empty($this->user_info['user_lastaction'])) ? $this->user_info['user_lastaction'] : $this->current_time;
      $sql = "UPDATE ".USERS_TABLE."
              SET ".get_user_table_field("", "user_lastaction")." = $this->current_time, ".get_user_table_field("", "user_location")." = '$this->user_location', ".get_user_table_field("", "user_lastvisit")." = ".$this->user_info['user_lastvisit']."
              WHERE ".get_user_table_field("", "user_id")." = ".$this->user_info['user_id'];
      $site_db->query($sql);
    }
    $this->set_cookie_data("lastvisit", $this->user_info['user_lastvisit']);
    $this->set_cookie_data("userid", $this->user_info['user_id']);
    return true;
  }


Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: PHP 5.3 issue
« Reply #3 on: May 13, 2012, 09:24:25 AM »
I think replacing the line I mentioned above with this should work:
Code: [Select]
if ($ref_domain=='') return false;
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline wallward

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
Re: PHP 5.3 issue
« Reply #4 on: October 21, 2014, 09:14:30 PM »
thank you , solved :)  :idea: