Welcome to Geeklog, Anonymous Thursday, March 28 2024 @ 08:48 am EDT

Geeklog Forums

Weird PHP behavior


Status: offline

IdahoEv

Forum User
Newbie
Registered: 04/02/03
Posts: 7

I'm developing a hack to get geeklog to ping weblogs.com when new stories are submitted, but I came up against a strange bug/unusual PHP behavior in GL that I don't know how to tackle.

I set it up to do it by sending an XML-RPC message; I'm using the XML-RPC for PHP package. Setting up the code was actually pretty easy; I wrote it in a few minutes.

When it didn't work, I tracked the problem down to the fact that xmlrpc functions behave differently (broken) inside GL than they do in a standalone PHP file. I'm hoping someone can tell me where to start looking to figure out why this is happening. I've set up a simple demonstration of this behavior.

If I take the following code snippet:

include("xmlrpc.inc");
$v=new xmlrpcval("foobar","string");
$retval = "value is:
" .
htmlentities($v->serialize()) . "
";
print $retval;

and run it in a PHP file, I get a useful output:

value is:foobar

Yet if I take the same code and put it in a PHP block (changing print $retval to return $retval), I get what appears to be an empty value! This shows, to me that either the xmlrpcval() constructor, or $v->serialize(), or both, are not working correctly inside GL:

 value is:

You can see these behaviors in action on my blog. Go to http://www.idahoev.com/vardemo.php for the first behavior in a standalone PHP file. For the second, go to my blog and click on the "Testing Grounds" topic. the lower-right block has the above code in it.

If anyone can suggest where to start looking as to why this code breaks if used inside GL, I'd greatly appreciate it.

Thanks,IdahoEv
IdahoEv's Rants: www.idahoev.com
 Quote

Status: offline

IdahoEv

Forum User
Newbie
Registered: 04/02/03
Posts: 7
Darnit! All my & g t ; etc. got converted to actual bracket characters when the post above was moderated, and subsequently disappeared. (HTML-formatted posts in GL do this... you can enter them as special characters, but then they get converted to brackets in the textarea when one edits or moderates ... and then they disappear when it's resubmitted!) The code fragment and outputs in the original story are all screwed up. Let me try posting them in POT mode. Incidentally, you don't necessarily have to know anything about XMLRPC or it's PHP implementation to understand this code or the problem. Just know that xlmrpcval is an object that is serializable, and it's behavior breaks if it's used from inside GL. The code fragment I'm running is: function phpblock_rpcserialize() { include("xmlrpc.inc"Wink; $v=new xmlrpcval("foobar","string"Wink; $retval = "value is:<BR><PRE>" . htmlentities($v->serialize()) . "</PRE>"; return $retval; } xmlrpc.inc contains the definition of the xmlrpcval object. Alternatively, I can just put this in its own PHP file, and just use print $retval; for the last line. In a plain PHP file, the code gives this output: value is: <value><string>foobar</string></value> But in a block (or any other place within GL), the same code gives a different output: value is: <value></value> Clearly, GL is somehow interfering with xmlrpcval's ability to function correctly; either to set, store, or serialize values. I'm not sure if I should be looking for GL identifiers that interfere with identifiers in xmlrpc.inc, or what. I'm not so familiar with PHP that I have a handle on whether variable scope could be an issue or not. ---IdahoEv's Rants: www.idahoev.com
IdahoEv's Rants: www.idahoev.com
 Quote

Status: offline

Blaine

Forum User
Moderator
Registered: 07/16/02
Posts: 1232
Location:Canada
I don't have the answer for you but I would use COM_errorLOG to send the return of $v->serialize() so I could see the result. COM_errorlog will send the output to error.log Example: COM_errorLOG("The value of retval is $retval"Wink; COM_errorLOG("My user id is: {$_USER['uid']}"Wink;
Geeklog components by PortalParts -- www.portalparts.com
 Quote

Anonymous

Anonymous
I'm guessing here but could GL be stripping the tags out because they aren't defined in the allowable html in your config.php?
 Quote

Anonymous

Anonymous
Thank you... this is the kind of answer I need (as is the allowable HTML post by another kind user). I'm fairly familiar with PHP, but just now getting used to the many things going on inside GL. I'll try dumping the output to the error log and see what it looks like. Thanks! Evan
 Quote

All times are EDT. The time is now 08:48 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content