php-general Digest 21 May 2007 01:15:29 -0000 Issue 4802

Topics (messages 255248 through 255260):

Re: PHP Data Mining/Data Scraping
        255248 by: Johan Holst Nielsen
        255249 by: Stut
        255252 by: itoctopus

Re: Marketplace Framework
        255250 by: Stut
        255251 by: itoctopus

inconsistency in SimpleXML
        255253 by: Vesselin Kenashkov

Re: Adserver programming with php
        255254 by: Colin Guthrie
        255258 by: WeberSites LTD

php5 cert
        255255 by: Danial Rahmanzadeh
        255257 by: Larry Garfield

Re: showing source
        255256 by: tedd

Re: can not fork
        255259 by: Jochem Maas

Confused about handling bytes
        255260 by: Joe Veldhuis

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Shannon Whitty wrote:
Hi,

I'm looking for a piece of software or coding that will let me post a form to another URL, accept the response, search it for a specific "success" string and then let me continue processing the rest of my program.

I want to accept queries on behalf of my supplier, forward it to them behind the scenes, accept their response and display it within my website.

Has anyone had any experience with this? Is there a simple, basic utility to let me do this?

I was kind of hoping I could avoid developing it myself.

cURL should be able to help you with that :)

www.php.net/curl

--
Johan Holst Nielsen
Freelance PHP Developer - http://phpgeek.dk

--- End Message ---
--- Begin Message ---
Shannon Whitty wrote:
Hi,

I'm looking for a piece of software or coding that will let me post a form to another URL, accept the response, search it for a specific "success" string and then let me continue processing the rest of my program.

I want to accept queries on behalf of my supplier, forward it to them behind the scenes, accept their response and display it within my website.

Has anyone had any experience with this? Is there a simple, basic utility to let me do this?

I was kind of hoping I could avoid developing it myself.

http://php.net/curl

-Stut

--- End Message ---
--- Begin Message ---
In case you have no control on the other URL, then CURL is probably your 
best solution.
Otherwise, a better way to do it is probably to interact with a web service 
installed on the other website.

-- 
itoctopus - http://www.itoctopus.com
""Shannon Whitty"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hi,
>
> I'm looking for a piece of software or coding that will let me post a form 
> to another URL, accept the response, search it for a specific "success" 
> string and then let me continue processing the rest of my program.
>
> I want to accept queries on behalf of my supplier, forward it to them 
> behind the scenes, accept their response and display it within my website.
>
> Has anyone had any experience with this?  Is there a simple, basic utility 
> to let me do this?
>
> I was kind of hoping I could avoid developing it myself.
>
> Thanks
> Shannon 

--- End Message ---
--- Begin Message ---
PHP Mailing List wrote:
Is there any PHP's framework for developing a marketplace site ?

Not totally sure what you mean by "a marketplace site", but if you mean an ecommerce site (online shop) then please search the list archives - this topic comes up a lot here and has been discussed at length.

-Stut

--- End Message ---
--- Begin Message ---
Try osCommerce

-- 
itoctopus - http://www.itoctopus.com
"PHP Mailing List" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hi All,
>
> Is there any PHP's framework for developing a marketplace site ?
>
> Regards,
>
> Dino 

--- End Message ---
--- Begin Message ---
Hello everybody,

An year ago I was playing with the SimpleXML in php and found some issues
and abandoned php5 for a year. Now I'm back to it and I found that the
issius are still there.

Here is the first one - how one can find does a SimpleXMLElement has child
nodes?
Here is an example:
--------
$str = '<rootnode><subnode></subnode></rootnode>';
$x = new SimpleXMLElement($str);

if($x->subnode->children())
   print 'yes';
   else
       print 'no';
---------
will print 'no';

If the
$str='<rootnode><subnode><newnode></newnode></subnode></rootnode>';
it will print yes.
But the same will happen if the subnode has an attribute like:
$str = '<rootnode><subnode id="2"></subnode></rootnode>';

But if we use foreach($x->subnode->children() as $key=>$value)
in the latter example we will not get anything.
I think is wrong the children() method to return object when there are no
child objects and the node has attributes.

The workaround I use is to extend the SimpleXMLElement
--------
class SimpleXMLElement2 extends SimpleXMLElement
{
public function has_children()
   {
   foreach($this->children() as $node)
       return true;
   return false;
   }

}
------
And then we can check with if($x->subnode->has_children())



Issue #2:
Xpath on nodes.
Let we have the example:
-----------------
$str =
'<rootnode><level1_node1><level2_node1></level2_node1></level1_node1><level1_node2></level1_node2></rootnode>';
$x = new SimpleXMLElement($str);

$r1 = $x->xpath('/*');
print $r1[0]->getName();//prints rootnode

$r2 = $x->level1_node1[0]->xpath('/*');
print $r2[0]->getName();//prints rootnode

$z = clone $x->level1_node1[0];
$r3 = $z->xpath('/*');
print $r3[0]->getName();//prints rootnode

//print $z->getName();//ok
------------------
I personally think that the xpath must be evaluated against the node which
method is called, not always against the rootnode.
So in the second example I would expect it to return level1_node1, and
especially in the thirds example.
Even in the third example the xpath is evaluated against the original XML
structure, not the subnode (level1_node1).
I think this is incorrect and leads to a confusion - for example we can pass
a node to a function like:
--------
function do_something($node)
   {
   //print $node->getName();//prints correct - the name of the supplied
node - level1_node1
   $r1 = $node->xpath('/*');
   print $r1[0]->getName();
   }

do_something(clone $x->level1_node1[0]);
--------
The do_something function is not aware at all about the full xml structure
and one could think that the expression will be evaluated just against the
supplied node, but it is not that the case.
And I do not have a workaround for that for the moment.
Any comments, solutions, and opinions about that SimpleXML functionality are
welcome.

Vesselin Kenashkov

--- End Message ---
--- Begin Message ---
Merlin wrote:
> Hi there,
> 
> I am thinking about creating a kind of adserver which is customized for
> my needs. As I would be most confident in doing this with php, I am
> asking myself if this is the right choice or if it would be wiser to
> take a C++ aproach for example to get a higher performance just in case
> the site grows fast.
> Do you guys think that a php build webserver would be able to scale and
> perform well enough for serving millions of adimpressions daily?

Depending on your needs and the license etc. you could take a look at
phpadsnew or (after quick google) OpenAds as it is now called:

http://www.openads.org/

Perhaps customising that code will save you some time?

Col.

--- End Message ---
--- Begin Message ---
Not sure why you would want to build something from scratch when you can use

Openads : http://www.openads.org/

berber 

-----Original Message-----
From: Merlin [mailto:[EMAIL PROTECTED] 
Sent: Sunday, May 20, 2007 2:16 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Adserver programming with php

Hi there,

I am thinking about creating a kind of adserver which is customized for my
needs. As I would be most confident in doing this with php, I am asking
myself if this is the right choice or if it would be wiser to take a C++
aproach for example to get a higher performance just in case the site grows
fast.
Do you guys think that a php build webserver would be able to scale and
perform well enough for serving millions of adimpressions daily?

Thank you for any advice,

Merlin

--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
are volcan exams really harder than actual php5 exam as phparch asserted?

--- End Message ---
--- Begin Message ---
Actually I found the real exam harder than the test exam.  It may have just 
been the question set I ended up with, but it was a lot more nitpicky on 
details that I rarely use in my work.

On Sunday 20 May 2007, Danial Rahmanzadeh wrote:
> are volcan exams really harder than actual php5 exam as phparch asserted?


-- 
Larry Garfield                  AIM: LOLG42
[EMAIL PROTECTED]               ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

--- End Message ---
--- Begin Message ---
At 12:16 PM +0200 5/18/07, Christian Haensel wrote:
Why don't you use:
highlight_file(__FILE__) ?

OMG

I have been coding that thing for MONTHS now... just to get syntax highlighting for my tutorial blog... maybe I shouldn't write tutorials... maybe I should rather read them *g*

Thanks for this short, but awesome answer :o) I wasn't the one asking the question, but nonetheless you have just wrecked my weekend :oP If I could kick my own rear end, I would do so´for the next two days...

Cheers mate, and have a great weekend!

Chris

Chris:

There might come a time where you do not want to show ALL of the inter-workings of your script, if so, then please review this:

http://sperling.com/a/show-code/

Cheers,

tedd
--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
Rajiv Man Karmacharya wrote:
> [EMAIL PROTECTED]
> 
> while trying to use exec('IECapt.exe ' . escapeshellarg($website_url) . ' ' . 
> escapeshellarg($cached_filename)); i get the following error
> 
> Warning: exec() [function.exec]: Unable to fork [IECapt.exe 
> "http://www.nepalnews.com.np"; 
> "C:/Inetpub/wwwroot/5531ed95934bee318939d9270b2db620.png"] ...................
> 
> This piece of code is from 
> http://www.zubrag.com/scripts/website-thumbnail-generator.php
> 
> I couldn't figure out why this Unable to fork is occuring. I search php.net 
> as well and it says, it might be related to permission issues.
> 
> I'm using winxp and iis.
> 
> I hope someone would help me with this.

probably permissions is the problem - i.e. IIS doesn't have the right to run a 
shell and/or the binary in question.

BUT who cares ... you shouldn't be using exec() in a script that's evoked via a 
webserver if you can really help it.

it seems you have a binary that takes a url and makes a visual snapshot of the 
resulting webpage as seen in IE, I
would suggest that you run a background task that regularly updates a cache of 
such images using the exec() technique
given above (maybe using a database as a source of urls to check) and then have 
you web scripts use the cached data
as needed.

otherwise your off into the dark woods of windows/IIS permissions (can't help 
you there I'm afraid)

> 
> Regards
> Rajiv

--- End Message ---
--- Begin Message --- While I'm sure this is a stupid question and the solution will be obvious to everyone here, this is confusing me.

I'm trying to control a device over a serial port using a PHP script, and one of the things I need to do is read a 26-byte string from an EEPROM, using a command that returns two bytes at a time, and write similar strings using a similar command. For example, to read the first two bytes of one such string beginning at address 0x484, I would send:

04 84 00 00 BB

Here's the code I've written so far:

$string = 1; //which of 200 strings I want to read
$base = pack("H*",dechex((($string-1)*hexdec(0x1a))+hexdec(0x484))); //calculate the base address of the string (the first starts at 0x484)
for($i=0;$i < 13;$i++) { //iterate 13 times (26 bytes / 2 bytes at a time)
dio_write($serial,$base."\x00\x00\xbb",5); //send the command
$output[] = dio_read($serial,1);  // read first byte
$output[] = dio_read($serial,1); // read second byte
$base = pack("H*",dechex(hexdec(bin2hex($base))+2)); //increment address
}

There are two things wrong with this. First, the final line isn't doing what it's supposed to. Instead of adding 2 to the value of $base each time, It's producing a pattern like this:

0x484, 0x486, 0x73, 0x73, 0x73, 0x488, 0x48a, 0x48c, 0x48e, 0x490, 0x74, 0x74, 0x74

Second, the format of $base doesn't seem to be handled correctly in line 4 of the above code. Given a value of 0x484, this line should write the bytes "04 84", but it is obviously not doing so, given the response I get from the device (it sends "FF FF" instead of the expected value at that address, which I get when I remove the variable and manually specify the address).

What are the solutions to these problems?

Thanks,
-Joe Veldhuis

--- End Message ---

Reply via email to