You are here: Re: Feeback wanted on site with PHP exercices « PHP Programming Language « IT news, forums, messages
Re: Feeback wanted on site with PHP exercices

Posted by tom pester on 09/08/05 05:02

Hallo Tim,

Vriendelijke groetjes uit Antwerpen :)

Thanks for sharing that code. That class seems very powerful (more info at
sourceforge : http://sourceforge.net/projects/simpletest/).

I had to change

> preg_match('#How much is (\d+) \+ (\d+) \?#', $content, $matches);
> $ua->setField('humanSum', $matches[0][1] + $matches[0][2]);

to

preg_match_all('/How much is (\d+) \+ (\d+)/', $content, $matches);
$ua->setField('humanSum', $matches[1][0] + $matches[2][0] );

Could you tell me why your code is a bit different. Is it because I develop
on a windows system?

I also would like to subscribe to your blog but it errors currently.

Groetjes,
Tom Pester



> On 2005-09-07, Philip Ronan <invalid@invalid.invalid> wrote:
>
>> "tom pester" wrote:
>>
>>> Hi Phil,
>>>
>>>> On the other hand, extracting two numbers from the HTML source of a
>>>> web page and adding them together is ridiculously easy. A
>>>> combination of file_get_contents() and simple string matching is
>>>> all you need.
>>>>
>>> My point is that there is no real difference between the turing
>>> numbers and the addition other than turing number are more difficult
>>> to read (fo now).
>>>
>> This took 2 minutes to write:
>>
>> =====================================================
>> $s =
>> file_get_contents("http://thereference.dyndns.org:30000/MailPage.php"
>> );
>> $re = "/much is ([0-9]+) \+ ([0-9]+) .* humanGuid"
>> value="([^"]+)"/m";
>> if (preg_match($re,$s,$m)) {
>> echo 'Access code = ' . (1*$m[1]+1*$m[2]) . '\r\n';
>> echo 'Session ID = ' . $m[3];
>> } else echo "Couldn't find numbers";
>> =====================================================
>> Now I have the answer to your addition sum, and the session ID from
>> your "hidden" field. That wasn't difficult, was it?
>>
> With the simpletest browser you only need to change those fields that
> you are interested in ;) (No need to keep track of hidden stuff..)
>
> <?php
>
> ini_set('error_reporting', E_ALL);
> ini_set('display_errors', TRUE);
> require_once('simpletest/browser.php');
> $ua =& new SimpleBrowser;
> $ua->get('http://thereference.dyndns.org:30000/MailPage.php');
> $content = $ua->getContentAsText();
> preg_match('#How much is (\d+) \+ (\d+) \?#', $content, $matches);
> $ua->setField('humanSum', $matches[0][1] + $matches[0][2]);
> $ua->setField('email', 'pester.1.timvw@spamgourmet.com');
> $ua->setField('url', 'here we go...');
> $ua->clickSubmit('Send email');
> ?>
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация