View Full Version : PHP Parse Error?
greigeh
03-15-2016, 06:47 PM
hello!
I just viewed my error log and notice (i assume every time someone posts) there appears an error in the log which is:
"[13-Mar-2016 20:16:28 UTC] PHP Parse error: syntax error, unexpected '=' in /home/forumaccount/public_html/showpost.php(258) : eval()'d code on line 71"
line 71 is
70 - "$vbulletin->input->clean_array_gpc('r', array(
71 - 'highlight' => TYPE_STR,
72 - 'postcount' => TYPE_UINT,
73 - ));
"
does anyone know why this is? and could it be the reason for double posts?
It's caused by a plugin, not by the file showpost.php.
If you look at line 258 in showpost.php you will see that the showpost_post hook is called. Go to your plugin manager and find a plugin that uses the showpost_post hook. If there's more than one plugin using it, disable them one by one until you find which one is causing it.
Once you found the culprit, past the code of the hook here and we can take a look.
greigeh
03-15-2016, 07:15 PM
Ok thank you! I found the code. It's from a long time ago a developer added additional script to our likes script. (I assume it's line 71 of this code though?)
see below:
foreach( $data['dislikes'] as $key => $value )
{
[line 71] if( ( ( $post['dislikes'] == 1 && $has['dislikes'] == 0 ) ) && $key != $vbulletin->userinfo['userid'] )
{
$dislikesHTML .= '<a href="member.php?u=' . $key . '">' . trim( $value ) . '</a>, ';
} elseif( $i < 10 && ( $i < ( $post['dislikes'] - 1 ) ) && $key != $vbulletin->userinfo['userid'] )
{
Hmm that piece of code looks fine to me.
greigeh
03-15-2016, 08:38 PM
I did think it looked OK, no idea why it's giving off this error but sure am gunna have a Britney Spears kind of meltdown soon if I can't get to the bottom of this, lol.
squidsk
03-15-2016, 08:44 PM
Could you post the entire code in that plugin in case you're counting lines incorrectly.
greigeh
03-15-2016, 09:02 PM
$postLikes = $db->query_read('SELECT DISTINCT `live_dbtech_thanks_entry`.*, `live_user`.`username`, `live_user`.`displaygroupid` FROM `live_dbtech_thanks_entry` JOIN `live_user` ON (`live_user`.`userid` = `live_dbtech_thanks_entry` .`userid`) WHERE `contentid` = \'' . $post['postid'] . '\'');
name="dbtech_thanks_button" data-postid="{$post[postid]}" data-button="{$button[varname]}
$data = array('likes' => array(), 'dislikes' => array(), 'STFU' => array());
$has = array('likes' => 0, 'dislikes' => 0, 'STFU' => 0);
while( ( $fetch = $db->fetch_array( $postLikes ) ) != false )
{
$member = array(
'userid' => $fetch['userid'],
'username' => $fetch['username'],
'displaygroupid' => $fetch['displaygroupid']
);
$data[ strtolower( $button['varname'] ) ][ $fetch['userid'] ] = fetch_musername( $member );
if( $fetch['userid'] == $vbulletin->userinfo['userid'] )
{
$has[ strtolower( $button['varname'] ) ] = 1;
}
}
$post['hasLiked'] = $has['likes'];
$post['hasDisliked'] = $has['dislikes'];
$post['hasSTFU'] = $has['STFU'];
$post['likes'] = count( $data['likes'] );
$post['dislikes'] = count( $data['dislikes'] );
$post['STFU'] = count( $data['STFU'] );
$likesHTML = '';
$dislikesHTML = '';
$STFUHTML = '';
if( $post['likes'] > 0 )
{
$likesHTML = ( ( $has['likes'] == 1 ) ? '<span class="you">You' . ( $post['likes'] > 2 ? ',' : ' ' ) . ' </span> ' : '<span class="you"></span> ' );
$i = 0;
$extraHTML = '';
$extra = 0;
foreach( $data['likes'] as $key => $value )
{
if( ( ( $post['likes'] == 1 && $has['likes'] == 0 ) ) && $key != $vbulletin->userinfo['userid'] )
{
$likesHTML .= '<a href="member.php?u=' . $key . '">' . trim( $value ) . '</a>, ';
} elseif( $i < 10 && ( $i < ( $post['likes'] - 1 ) ) && $key != $vbulletin->userinfo['userid'] )
{
$likesHTML .= '<a href="member.php?u=' . $key . '">' . trim( $value ) . '</a>, ';
} elseif( $i >= 10 && ( $i < $post['likes'] ) && $key != $vbulletin->userinfo['userid'] )
{
$extraHTML .= trim( strip_tags( $value ) ) . ', ';
++$extra;
}
++$i;
}
$lastUser = end( $data['likes'] );
$lastUserID = key( $data['likes'] );
$likesHTML = substr( $likesHTML, 0, -2 ) . ( ( ( ( $post['likes'] > 1 && $extra == 0 && $has['like'] == 0 ) || ( $post['likes'] > 2 && $extra == 0 && $has['like'] == 1 ) ) && $lastUserID != $vbulletin->userinfo['userid'] ) ? ' and <a href="member.php?u=' . $lastUserID . '">' . $lastUser . '</a>' : ( ( $post['likes'] > 1 && $extra > 0 ) ? ' and <a href="#" class="tooltip" title=\'' . substr( $extraHTML, 0, -2 ) . '\'>' . $extra . ' others</a>' : '') ) . ' ' . ( ( $has['likes'] == 0 && $post['likes'] > 1 ) ? 'like' : ( ( $has['likes'] == 0 && $post['likes'] == 1 ) ? 'likes' : 'like' ) ) . ' this';
}
if( $post['dislikes'] > 0 )
{
$dislikesHTML = ( ( $has['dislikes'] == 1 ) ? '<span class="you">You' . ( $post['dislikes'] > 2 ? ',' : ' ' ) . ' </span> ' : '<span class="you"></span> ' );
$i = 0;
$extraHTML = '';
$extra = 0;
foreach( $data['dislikes'] as $key => $value )
{
if( ( ( $post['dislikes'] == 1 && $has['dislikes'] == 0 ) ) && $key != $vbulletin->userinfo['userid'] )
{
$dislikesHTML .= '<a href="member.php?u=' . $key . '">' . trim( $value ) . '</a>, ';
} elseif( $i < 10 && ( $i < ( $post['dislikes'] - 1 ) ) && $key != $vbulletin->userinfo['userid'] )
{
$dislikesHTML .= '<a href="member.php?u=' . $key . '">' . trim( $value ) . '</a>, ';
} elseif( $i >= 10 && ( $i < $post['dislikes'] ) && $key != $vbulletin->userinfo['userid'] )
{
$extraHTML .= trim( strip_tags( $value ) ) . ', ';
++$extra;
}
++$i;
}
$lastUser = end( $data['dislikes'] );
$lastUserID = key( $data['dislikes'] );
$dislikesHTML = substr( $dislikesHTML, 0, -2 ) . ( ( ( ( $post['dislikes'] > 1 && $extra == 0 && $has['like'] == 0 ) || ( $post['dislikes'] > 2 && $extra == 0 && $has['like'] == 1 ) ) && $lastUserID != $vbulletin->userinfo['userid'] ) ? ' and <a href="member.php?u=' . $lastUserID . '">' . $lastUser . '</a>' : ( ( $post['dislikes'] > 1 && $extra > 0 ) ? ' and <a href="#" class="tooltip" title=\'' . substr( $extraHTML, 0, -2 ) . '\'>' . $extra . ' others</a>' : '') ) . ' ' . ( ( $has['dislikes'] == 0 && $post['dislikes'] > 1 ) ? 'dislike' : ( ( $has['dislikes'] == 0 && $post['dislikes'] == 1 ) ? 'dislikes' : 'dislike' ) ) . ' this';
}
if( $post['STFU'] > 0 )
{
$STFUHTML = ( ( $has['STFU'] == 1 ) ? '<span class="you">You' . ( $post['STFU'] > 2 ? ',' : ' ' ) . ' </span> ' : '<span class="you"></span> ' );
$i = 0;
$extraHTML = '';
$extra = 0;
foreach( $data['STFU'] as $key => $value )
{
if( ( ( $post['STFU'] == 1 && $has['STFU'] == 0 ) ) && $key != $vbulletin->userinfo['userid'] )
{
$STFUHTML .= '<a href="member.php?u=' . $key . '">' . trim( $value ) . '</a>, ';
} elseif( $i < 10 && ( $i < ( $post['STFU'] - 1 ) ) && $key != $vbulletin->userinfo['userid'] )
{
$STFUHTML .= '<a href="member.php?u=' . $key . '">' . trim( $value ) . '</a>, ';
} elseif( $i >= 10 && ( $i < $post['STFU'] ) && $key != $vbulletin->userinfo['userid'] )
{
$extraHTML .= trim( strip_tags( $value ) ) . ', ';
++$extra;
}
++$i;
}
$lastUser = end( $data['STFU'] );
$lastUserID = key( $data['STFU'] );
$STFUHTML = substr( $STFUHTML, 0, -2 ) . ( ( $post['STFU'] > 1 && $extra == 0 && $lastUserID != $vbulletin->userinfo['userid'] ) ? ' and <a href="member.php?u=' . $lastUserID . '">' . $lastUser . '</a>' : ( ( $post['STFU'] > 1 && $extra > 0 ) ? ' and <a href="#" class="tooltip" title="' . substr( $extraHTML, 0, -2 ) . '">' . $extra . ' others</a>' : '') ) . ' ' . ( ( $has['STFU'] == 0 && $post['STFU'] > 1 ) ? 'said' : ( ( $has['STFU'] == 0 && $post['STFU'] == 1 ) ? 'says' : 'say' ) ) . ' STFU';
}
$post['likeshtml'] = $likesHTML;
$post['dislikeshtml'] = $dislikesHTML;
$post['STFUhtml'] = $STFUHTML;
$post['systemhtml'] = '
<script>var admin = ' . ( ( $vbulletin->userinfo['displaygroupid'] == 6 ) ? 'true' : 'false' ) . '</script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.js"></script>
<script src="/assets/tipsy.js"></script>
<script src="/assets/global.js"></script>
<script src="clientscript/vbulletin_ajax_reputation.js?v=387" type="text/javascript" ></script>
<style>@import url( /assets/likes.css );</style>';
squidsk
03-15-2016, 09:26 PM
I ran that through the php lint and it didn't turn up any errors, but line 3 looks like it doesn't belong in a php file.
Line 3:
name="dbtech_thanks_button" data-postid="{$post[postid]}" data-button="{$button[varname]}
This looks like it belongs to a template, not php code.
greigeh
03-15-2016, 09:37 PM
I ran that through the php lint and it didn't turn up any errors, but line 3 looks like it doesn't belong in a php file.
Line 3:
name="dbtech_thanks_button" data-postid="{$post[postid]}" data-button="{$button[varname]}
This looks like it belongs to a template, not php code.
Just realised the snippet of code you posted is missing the " at the end of data-button which has resolved the issue. Crazy.
So the following is still literally in the PHP code of the hook?
name="dbtech_thanks_button" data-postid="{$post[postid]}" data-button="{$button[varname]}"
If that's the case, you have to remove it since it's not PHP code. :)
greigeh
03-15-2016, 10:49 PM
So the following is still literally in the PHP code of the hook?
name="dbtech_thanks_button" data-postid="{$post[postid]}" data-button="{$button[varname]}"
If that's the case, you have to remove it since it's not PHP code. :)
I'd remove it but i'm not sure what it does and may break it :confused: :(?
squidsk
03-16-2016, 01:05 AM
I'd remove it but i'm not sure what it does and may break it :confused: :(?
It doesn't do anything since it isn't valid php.
Gio~Logist
03-16-2016, 02:01 AM
Not sure how that ended up there, it definitely may be causing the error. However, don't go crazy removing all html in your plugins either... As php plugins may also have html. As you can see, part of that plugin actually stores and compiles html in a variable.
It doesn't do anything in this case though. It's not stored in any variable nor does it have any purpose in that hook.
Gio~Logist
03-16-2016, 07:47 AM
Yea, haha, it was beyond random there. Almost looks like someone accidentally pasted it there while coding and somehow had the wrong c&p in their clipboard :erm:
greigeh
03-16-2016, 09:51 PM
Thank you for all your help!
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.