Zikry.Z.Azhar (@zikry) |
Why does every member to add as a friend, and when the last member clicks approving error ???<br />
This image !!! help me please..<br />
[img]http://i41.tinypic.com/29bn9zn.jpg[/img]
I get an error that relates to "includes/libs/common.inc.php" every time I approve a friend request. It actually does the approval, but members wouldn't know it from the white errors screen.
I've tried replacing both "friends.module.php" and "common.inc.php" and haven't found the solution yet. And the function for approval - I tried fiddling with that but nothing either.
I recently upgraded from v5pro to v7pro, but even replacing with the v5 of those files didn't help. If anyone has a fix, it would be greatly appreciated!!
[b]####ADDED:[/b]
THIS IS THE ERROR I GET:
[code]Warning: Invalid argument supplied for foreach() in /includes/libs/common.inc.php on line 228
Warning: implode() [function.implode]: Invalid arguments passed in /includes/libs/common.inc.php on line 231
Warning: Cannot modify header information - headers already sent by (output started at /includes/libs/common.inc.php:228) in /includes/libs/common.inc.php on line 313[/code]
And this is my "function approve":
[code]function approve($uid) {
global $client, $ubase;
if (!$user = valid_user($uid)) die('wrong uid');
//
$res = sql_query("select from ".tb()."friend_reqs
where uid='$uid' and fid={$client['id']} ");
if (sql_counts($res)) {
$res = sql_query("select from ".tb()."friends
where uid='$uid' and fid={$client['id']} ");
//
if (!sql_counts($res)) {
sql_query("insert into ".tb()."friends
(uid,fid,created) values ($uid,{$client['id']},".time().")");
sql_query("insert into ".tb()."friends
(uid,fid,created) values ({$client['id']},$uid,".time().")");
}
//
sql_query("delete from ".tb()."friend_reqs
where uid=$uid and fid={$client['id']} ");
sql_query("delete from ".tb()."friend_reqs
where uid={$client['id']} and fid=$uid ");
//
stream_publish(
t(
'became a friend of {1}',
url('u/'.$user['username'],$user['username'],'','',1)
)
);
mail_notice('dismail_friend_request_c',$user['username'],t('{1} confirmed your friend request',$client['fullname']),t('{1} confirmed your friend request',$client['fullname']) );
redirect($ubase.'friends', 1);
}
}[/code]
[b]#####ADDED[/b]
I tried this but it still didn't work:
[code]stream_publish(
t(
'became a friend of {1}',
url('u/'.$user['username'],$user['username']),'','',1
)
);[/code]
[b]As well as without the extra arguments, which is how it was originally, to no avail:[/b]
[code]stream_publish(
t(
'became a friend of {1}',
url('u/'.$user['username'],$user['username'])
)
);[/code]
[b]##### NEW:[/b]
I've determined it's not the Friend Approve function. I deleted the whole 'stream_publish' portion and still got the same errors. So I'm deciding it must be in the "common.inc.php" file.
The errors indicate two lines (228, 231) in 'function url' and one line (313) in 'function redirect'.
[code]function url($link,$name = '',$target='',$gets=array()) {
GLOBAL $ubase, $uhome;
if (preg_match("/^http/i",$link)) {
$url = $link;
}
else {
if (preg_match("/^account/i",$link) || preg_match("/^admin/i",$link) || preg_match("/^login/i",$link) || $link == 'logout') {
$url = $uhome.'/index.php?p='.$link;
}
else {
$url = $ubase.$link;
}
}
if (count($gets) > 0) {
[b]foreach ($gets as $key=>$val) { ##LINE 228[/b]
$pars[] = $key.'='.urlencode($val);
}
[b]$getss = implode('&',$pars); ##LINE 231[/b]
if (preg_match("/\?/",$url)) {
$url = $url.'&'.$getss;
}
else {
$url = $url.'?'.$getss;
}
}
if ($name == 'ohno' || $name == '') {
return $url;
}
if (preg_match("/delete/i",$link)) {
$cfm = cfm();
}
if ($target)
$target = ' target="'.$target.'"';
return '<a href="'.$url.'"'.$target.$cfm.'>'.$name.'</a>';
}[/code]
[code]function redirect($url, $message = 0) {
global $ubase;
clear_as();
if (!preg_match("/^http/i",$url)) {
$url = $ubase.$url;
}
if (!$message) {
header("Location:$url");
exit;
}
elseif ($message == 1) {
if (preg_match("/index\.php/i",$url)) {
$url = $url.'&succ=1';
}
else {
$url = $url.'?succ=1';
}
[b]header("Location:$url"); ##LINE 313[/b]
exit;
redirecting($url, t('Operation success'),'auto');
}
else {
redirecting($url, $message);
}
}[/code]
Can we get some help on this? It's killing our site!
[b]##### SOLUTION !!! #####
I included an array check: [/b]
[code]function url($link,$name = '',$target='',$gets=array()) {
GLOBAL $ubase, $uhome;
if (preg_match("/^http/i",$link)) {
$url = $link;
}
else {
if (preg_match("/^account/i",$link) || preg_match("/^admin/i",$link) || preg_match("/^login/i",$link) || $link == 'logout') {
$url = $uhome.'/index.php?p='.$link;
}
else {
$url = $ubase.$link;
}
}
if (count($gets) > 0) {
[b]if(is_array($gets)){[/b]
foreach ($gets as $key=>$val) {
$pars[] = $key.'='.urlencode($val);
}
$getss = implode('&',$pars);[b]}[/b]
if (preg_match("/\?/",$url)) {
$url = $url.'&'.$getss;
}
else {
$url = $url.'?'.$getss;
}
}
if ($name == 'ohno' || $name == '') {
return $url;
}
if (preg_match("/delete/i",$link)) {
$cfm = cfm();
}
if ($target)
$target = ' target="'.$target.'"';
return '<a href="'.$url.'"'.$target.$cfm.'>'.$name.'</a>';
}[/code]
S |
Scott Bearden @scott
154 months ago (Updated: 154 months ago)
|
in friends.module.php
function approve
[code]
stream_publish(
t(
'became a friend of {1}',
url('u/'.$user['username'],$user['username'][b])[/b],'','',1
)
);
[/code]
see bold )
Jcow Master @falcone
154 months ago (Updated: 154 months ago)
|
In V4.31,I am still facing same problem.when admin approve a friend request, members know it.But when a member approve a friend request from other member.It actually does the approval,but members wouldn't know it from the white errors screen.:-/
I don't know,how to resolve this?
ramesh ten @ramesht
152 months ago
|