vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   PHP Parse Error? (https://vborg.vbsupport.ru/showthread.php?t=322128)

greigeh 03-15-2016 06:47 PM

PHP Parse Error?
 
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?

Dave 03-15-2016 06:52 PM

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'] )
{

Dave 03-15-2016 07:56 PM

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

HTML Code:

$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:
Code:

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

Quote:

Originally Posted by squidsk (Post 2567327)
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:
Code:

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.

Dave 03-15-2016 09:44 PM

So the following is still literally in the PHP code of the hook?
PHP Code:

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. :)


All times are GMT. The time now is 10:23 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01082 seconds
  • Memory Usage 1,811KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (1)bbcode_html_printable
  • (1)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete