PDA

View Full Version : Parse Error in Showthread help needed please


Booyakan
12-17-2010, 10:03 PM
I am getting this error when I try to use my code below.. can anyone please help me fix it?

Parse error: syntax error, unexpected $end in home/xxx/xxx/showthread.php(2169) : eval()'d code(10) : eval()'d code on line 1

Parse error: syntax error, unexpected T_ENDIF in home/xxx/xxx/showthread.php(2169) : eval()'d code(12) : eval()'d code on line 1

Here is the code for the beginning of my showthread.

<head>
<if condition="in_array($thread['forumid'], array(22, 30, 31, 32, 33, 34)) AND !is_member_of($bbuserinfo, 6, 7, 10)">

<script type="text/javascript">ap_loaded = false;</script>
<script type="text/javascript" src="http://ad.leadbolt.net/show_cu.js?section_id=xxxx"></script>
<script type="text/javascript">if (!ap_loaded) { window.location = 'http://ad.leadbolt.net/adblock?section_id=xxxx'; }</script>

<?php if (strpos($_SERVER['HTTP_USER_AGENT'],'Googlebot') !== false) : ?>
<noscript><meta http-equiv="refresh" content="0;url='http://ad.leadbolt.net/noscript?section_id=xxxx'" /></noscript>
<?php endif ?>

</if>

$headinclude

kh99
12-17-2010, 10:14 PM
I think the problem is in plugin code. It looks like hook location 'showthread_complete'. You might be able to look at the plugin manager and see which product it is.

Booyakan
12-17-2010, 10:42 PM
OK, I don't understand... I've never had this problem before until I put in this part of the code, and it's not a plugin. Could you please be more specific?

<script type="text/javascript">ap_loaded = false;</script>
<script type="text/javascript" src="http://ad.leadbolt.net/show_cu.js?section_id=xxxx"></script>
<script type="text/javascript">if (!ap_loaded) { window.location = 'http://ad.leadbolt.net/adblock?section_id=xxxx'; }</script>

<?php if (strpos($_SERVER['HTTP_USER_AGENT'],'Googlebot') !== false) : ?>
<noscript><meta http-equiv="refresh" content="0;url='http://ad.leadbolt.net/noscript?section_id=xxxx'" /></noscript>
<?php endif ?>

kh99
12-17-2010, 10:45 PM
Oh yeah, sorry, I'm wrong. I Jumped to that conclusion because that's the same error you get when a plugin has a problem, but you're right, it's obviously something in that template.

ETA: I don't use the :/endif thing so I'm not sure, but doesn't it need a ; after the endif?

BTW - are you even allowed to put php in a template like that?

Boofo
12-17-2010, 11:25 PM
I've never run across a php if statement in a template.

EDIT: I found where you missed it. Try this for the endif statement. You forgot the trailing ;

<?php endif; ?>

Booyakan
12-18-2010, 12:03 AM
Hi,

I tried <?php endif; ?> and now the error changed just a bit to this... (I bolded the changes)

Parse error: syntax error, unexpected $end in home/xxx/xxx/showthread.php(2169) : eval()'d code(12) : eval()'d code on line 1

Parse error: syntax error, unexpected T_ENDIF in home/xxx/xxx/showthread.php(2169) : eval()'d code(14) : eval()'d code on line 1

calorie
12-18-2010, 12:16 AM
Try getting rid of the red lines:

<head>
<if condition="in_array($thread['forumid'], array(22, 30, 31, 32, 33, 34)) AND !is_member_of($bbuserinfo, 6, 7, 10)">

<script type="text/javascript">ap_loaded = false;</script>
<script type="text/javascript" src="http://ad.leadbolt.net/show_cu.js?section_id=xxxx"></script>
<script type="text/javascript">if (!ap_loaded) { window.location = 'http://ad.leadbolt.net/adblock?section_id=xxxx'; }</script>

<?php if (strpos($_SERVER['HTTP_USER_AGENT'],'Googlebot') !== false) : ?>
<noscript><meta http-equiv="refresh" content="0;url='http://ad.leadbolt.net/noscript?section_id=xxxx'" /></noscript>
<?php endif ?>

</if>

$headinclude

Booyakan
12-19-2010, 07:54 AM
That does work, but is there anyway I can still implement:

if (strpos($_SERVER['HTTP_USER_AGENT'],'Googlebot') !== false) :

I want to hide the no script section of my code from Googlebot.

Boofo
12-19-2010, 08:40 AM
This won't work?

<if condition="strpos($_SERVER['HTTP_USER_AGENT'],'Googlebot') !== false">

Booyakan
12-19-2010, 08:48 AM
Thanks for the suggestion, but it didn't work.... I got this when I clicked save.

The following template conditional expression contains function calls:

<if condition="strpos($_SERVER['HTTP_USER_AGENT'],'Googlebot') !== false">

Function Name Usage in Expression
strpos strpos($_SERVER['HTTP_USER_AGENT'],'Googlebot')

With a few exceptions, function calls are not permitted in template conditional expressions. Please go back and re-write this expression.

The following functions are allowed in template conditional expressions:
in_array() is_array() is_numeric() isset() empty() defined() array() can_moderate() can_moderate_calendar() exec_switch_bg() is_browser() is_member_of()

Boofo
12-19-2010, 09:02 AM
Ah, okay. I've never tried doing it before. t was just an idea, albeit a bad one, it seems.

kh99
12-19-2010, 09:36 AM
You can only use a small set of functions in conditionals (see the manual here): http://www.vbulletin.com/docs/html/main/functions_in_conditionals (like the list in the error message)

So the way around that of course is to make a plugin for the code which sets a variable that you can check in your template.

Something I just noticed recently - you can actually allow other functions in templates (see the bottom user comment on the above page), but that also requires a plugin.

Booyakan
12-19-2010, 09:45 AM
Ok I believe I got it, if there is another "right" way please someone let me know... but for anyone that wants to know, here is what I did and it seems to work.

It was fairly simple...I followed the instructions here (http://www.vbulletin.com/forum/showthread.php?173937-How-to-Include-a-PHP-or-HTML-File&p=1066718#post1066718)and made a simple plugin.

Thanks for everyone that answered this post!

**Kh99 I saw your last post right after I got done figuring this out and posting on here! lol

Boofo
12-19-2010, 09:50 AM
Aren't hooks great? :)