Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 09-30-2010, 08:43 AM
janaf janaf is offline
 
Join Date: Dec 2009
Posts: 169
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Problem with php-direct "hello world" reading arguments

I have a php direct eval page but have problems after 4.0.7 update.

Functionally, the code depends on this line, which is not working:
PHP Code:
$mystring=vB::$vbulletin->input->clean_gpc('r''mystring'TYPE_STR); 
$output=$mystring
The code should read URL arguments: <myurl>&mystring=Hello
Now, it returns nothing, $mystring is empty. Does anyone have a suggestion how to make this work? Workarounds?

I have also tried this syntax:
PHP Code:
$mystring=$vbulletin->input->clean_gpc('r''mystring'TYPE_STR); 
but get: Fatal error: Call to a member function clean_gpc() on a non-object in <url>

A slightly longer version with the cycle of what the page does is here; it has a form with a drop-down posting values to itself:

PHP Code:
$mystring=vB::$vbulletin->input->clean_gpc('r''mystring'TYPE_STR); 
$output=$mystring;
$output.='<br><form action="" method="POST">'
$output.='<input type="hidden" name="securitytoken" value="'.vb::$vbulletin->userinfo[securitytoken].'" />'
$output.='<select name="nominalsize"><option value="">[Say Hello]</option><option value="Hello World">Hello World</option></select><br>';
$output.='<input type="submit" value="   Submit   " />'
$output.='</form>'
This page where I used this code used to have a few thousand pageviews daily, and is now at stand-still for more than a week

A long version with my full code is here;

https://vborg.vbsupport.ru/showthread.php?t=250920

But the key to the problem is the first line here, so the longer version may just be confusing...

Please help! My vb-coding experience is low, I'm depending on you guys.....
Reply With Quote
  #2  
Old 10-01-2010, 01:39 AM
Deceptor's Avatar
Deceptor Deceptor is offline
 
Join Date: Dec 2008
Location: England
Posts: 514
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This should do the trick
PHP Code:
$vbulletin->input->clean_array_gpc('r', array(
    
'mystring' => TYPE_STR,
));

$mystring $vbulletin->GPC['mystring']; 
Reply With Quote
  #3  
Old 10-01-2010, 09:55 AM
janaf janaf is offline
 
Join Date: Dec 2009
Posts: 169
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks deceptor,

I have found that the problem is a caching problem. All the time the cache refresh time has been set to zero but still old content is displayed, also even if the POST arguments are changed. I remember now that I had the caching problem when I originally wrote the first code, but it was solved by setting caching to zero for the vB content. But this seems to be back now. I can read the argument once, after saving the code, but then that result "sticks" enen after a page refresh. So if the page is read first time without arguments, then none are read until some time has passed. Can I codewise explicitly disable caching?



With your syntax I am getting:

Fatal error: Call to a member function clean_array_gpc() on a non-object in <url>phpeval.php(97) : eval()'d code on line 1

Can you confirm this syntax works with a 4.0.7? Something wrong with my vb installation?

This also works, no error message, but with the caching problem:

PHP Code:
vB::$vbulletin->input->clean_array_gpc('r', array('mystring' => TYPE_STR));
$mystring =vB::$vbulletin->GPC['mystring']; 
Reply With Quote
  #4  
Old 10-01-2010, 01:46 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Deceptor just forgot the vB:: , otherwise they are the same.

There is a bug with cache set to 0. The fix is posted in the bug report over in Jira.
Reply With Quote
  #5  
Old 10-01-2010, 08:59 PM
janaf janaf is offline
 
Join Date: Dec 2009
Posts: 169
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Lynne,

Before reading your post I made a bug report http://tracker.vbulletin.com/browse/VBIV-9336

I found your solution suggested here:
http://www.vbulletin.com/forum/showt...e+refresh+time
and the bug tracker here http://tracker.vbulletin.com/browse/VBIV-8082

However, it did not work for me. I tried the suggested code changes, flushed the CMS cache several times, even re-started Apache.

I also tried other more drastic code changes in execphp.php like:

PHP Code:
if (!isset($config['cache_ttl']) )
        {
            
$config['cache_ttl'] = 0;

and
PHP Code:
if ($config['cache_ttl'] > 999999)...... 
But it seems that whatever I do, the php direct content was still cached. Maybe pending some site specific setting?

Also this does not work for me:

ACP => Options => Add No-Cache HTTP Headers => Help Cookies and HTTP Header Options = yes

This works perfectly but of course degrades the site performance:

ACP => Options => Server Settings and Optimization Options =>Disable Content Caching

I tested mostly with this one-line php direct evaluation code

PHP Code:
$output=vB::$vbulletin->input->clean_gpc('r''mystring'TYPE_STR); 
And calling the page with a browser call like <url>&mystring=xxxxxx

So any ideas on what I can do?
Reply With Quote
  #6  
Old 10-01-2010, 09:25 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Actually, I was thinking about the wrong thing above. Your code isn't in a widget which is the bug report I was thinking of. So, changing the cache code in the widget isn't going to help you out at all.
Reply With Quote
  #7  
Old 10-01-2010, 10:56 PM
janaf janaf is offline
 
Join Date: Dec 2009
Posts: 169
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ah, the "execphp.php" looked right to me.

I can see there is a /packages/vbcms/content/phpeval.php which has two suspect lines:

on line 60:
PHP Code:
'cache_ttl' => '60'
and on line 67
PHP Code:
protected $cache_ttl 60
So it caching is hardcoded to 60 minutes there?

I tried setting these to zero but that did not help
Reply With Quote
  #8  
Old 10-01-2010, 11:02 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

To be honest, I don't know. I really don't know much about the caching in the CMS.
Reply With Quote
  #9  
Old 10-01-2010, 11:21 PM
janaf janaf is offline
 
Join Date: Dec 2009
Posts: 169
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

For now, I am running the site all un-cached, working acceptably. It's on a dedicated server and is not heavily loaded. I can keep it that way until I see what comes out of the bug report / Jira....

http://www.41hz.com/forums/content.php?253-TSdb
Reply With Quote
  #10  
Old 10-13-2010, 08:57 PM
LizP LizP is offline
 
Join Date: Apr 2010
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is just a hack, but I had to solve this problem ASAP and here's what I did... I basically turned off rendering a cached page for direct PHP eval pages, which honestly if I'm using the eval pages it's likely b/c the content is dynamically being created so I don't want to use a cached page anyway.

On line 60 of packages/vbcms/item/content/phpeval.php:

// if ($preview_only OR $this->rendered['rendered_text'])
if ($preview_only)

That's it. Keep in mind, this hack will be overwritten by future upgrades, but hopefully vb will have the issue resolved by then. Hope this helps get you running today though!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:51 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04246 seconds
  • Memory Usage 2,271KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (10)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete