vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Problem with php-direct "hello world" reading arguments (https://vborg.vbsupport.ru/showthread.php?t=251402)

janaf 09-30-2010 08:43 AM

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 :mad:

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

Deceptor 10-01-2010 01:39 AM

This should do the trick
PHP Code:

$vbulletin->input->clean_array_gpc('r', array(
    
'mystring' => TYPE_STR,
));

$mystring $vbulletin->GPC['mystring']; 


janaf 10-01-2010 09:55 AM

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?

:confused:

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']; 


Lynne 10-01-2010 01:46 PM

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.

janaf 10-01-2010 08:59 PM

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?

Lynne 10-01-2010 09:25 PM

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.

janaf 10-01-2010 10:56 PM

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 :o

Lynne 10-01-2010 11:02 PM

To be honest, I don't know. I really don't know much about the caching in the CMS.

janaf 10-01-2010 11:21 PM

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

LizP 10-13-2010 08:57 PM

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!


All times are GMT. The time now is 09:11 AM.

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.01174 seconds
  • Memory Usage 1,764KB
  • 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
  • (10)bbcode_php_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