[PHP] problems in extension development

2012-02-16 Thread Rui Hu
hi,

I just started to write a simple PHP extension "hello", but encountered
some problems. I followed tutorials step by step:
1. ./ext_skel --extname=hello
2. modified hello.c and php_hello.h, and wrote function hello_world() which
simply return a string "hello world".
3. phpize
4. ./configure ; make ;
5. the I encountered error in make. I looked up in Makefile and found that
$(PHP_MODULE) is null, which I think is the reason. Makefile is
automatically generated by ./configure.

What mistake did I make? How to fix it?

Thanks!
Vic Hu


-- 
Best regards,

Rui Hu

State Key Laboratory of Networking & Switching Technology
Beijing University of Posts and Telecommunications(BUPT)
MSN: tchrb...@gmail.com
-


Re: [PHP] basic captcha

2012-02-16 Thread Simon Schick
Hi, all

When you ask for a captcha, I'd first ask what do you want to use it for.
If you read the first lines of Wikipedia it has been developed to differ
between a real user and a bot.

If you'd now say that you want to use it to protect spam in a formula I'd
give you the same explanation that you can find here in german (in a bit
more text): http://www.1ngo.de/web/captcha-spam.html
The author of this link says that captchas are not efficient enough and
give a new unnecessary barrier to all users. He also declaims that bots
nowadays are better than ever and can even read captchas that many humans
are not able to read.
For this reason he provides a list of extra stuff that you can use to
protect your formula against spam instead of a picture that's text should
be written in an input-field.

One of those is the honey-pot. You simply create an additional field (f.e. *
email2*) hide it for most visitors (using *css*) and ignore the comment if
there's text in here. As most of the bots cannot read css they'll fill a
valid email-address in here :) But then you also have to think about users
that have css disabled f.e. *ScreenReader*. Another disadvantage of this
issue is that you can use an auto-field-fill mechanism provided by the
browser who could fill this field ... But both cases should not be that
difficult. For the screenreder you can change the label for the field to
look like *Do not paste your email in here. Just leave it empty.* Just to
have the word email again in here ;)

Another good thing is to think about how fast this form can be submitted
when the user enters the formula for the first time. Also think about the
second time, when the user as entered some wrong values and you have to
show him a message.
If you have a formula that contains more than 5 fields it's quite unusual
that the user can submit that below 2 sec after receiving the response. You
could even add a feature by using javascript that the user cannot submit
this form or his request will be delayed for a view seconds (one or two).

If you want to know more about that, out there are plenty of plugins for
different systems where you can see what other possibilities you have. One
extension i like is the one from TYPO3. They have quite a bunch of such
things and you can give each of the checks a value. If the sum of the
values of the failing tests reaches a configured level, this
form-submission will be rejected.
http://typo3.org/extensions/repository/view/wt_spamshield/current/

Wordpress: http://antispambee.de/

Bye
Simon

2012/2/17 Savetheinternet 

> On Fri, Feb 17, 2012 at 3:40 PM, Donovan Brooke  wrote:
> > Hello,
> >
> > Does anyone know of a basic (open source or freeware) form captcha system
> > for PHP?
> >
> > TIA,
> > Donovan
> >
> >
> >
> >
> > --
> > D Brooke
> >
>
> Hi,
>
> There are plenty of free PHP captcha scripts out there. Just google
> "captcha PHP". Securimage (phpcaptcha.org) looks relatively okay.
>
> Thanks,
> Michael
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] basic captcha

2012-02-16 Thread Savetheinternet
On Fri, Feb 17, 2012 at 3:40 PM, Donovan Brooke  wrote:
> Hello,
>
> Does anyone know of a basic (open source or freeware) form captcha system
> for PHP?
>
> TIA,
> Donovan
>
>
>
>
> --
> D Brooke
>

Hi,

There are plenty of free PHP captcha scripts out there. Just google
"captcha PHP". Securimage (phpcaptcha.org) looks relatively okay.

Thanks,
Michael

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



Re: [PHP] basic captcha

2012-02-16 Thread Patrick Hafner
Hi,

have you tried reCAPTCHA by Google?
You can find the PHP library on the website.

Easy to use, customizable and free, but nothing to install on your server (no 
open source)

Best regards, 
Patrick Hafner

Am 17.02.2012 um 05:40 schrieb Donovan Brooke :

> Hello,
> 
> Does anyone know of a basic (open source or freeware) form captcha system for 
> PHP?
> 
> TIA,
> Donovan
> 
> 
> 
> 
> -- 
> D Brooke
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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



[PHP] basic captcha

2012-02-16 Thread Donovan Brooke

Hello,

Does anyone know of a basic (open source or freeware) form captcha 
system for PHP?


TIA,
Donovan




--
D Brooke

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



Re: [PHP] pathinfo or other

2012-02-16 Thread Donovan Brooke

Elbert F wrote:

SCRIPT_NAME is a server side path, try REQUEST_URI. This includes the query
string but it's easy to remove.

Elbert
http://swiftlet.org



Hi, I thought I should say that server side SCRIPT_NAME seems to be fine 
for me in this case. Thanks for the input.


Donovan




--
D Brooke

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



Re: [PHP] Turning a string into a condition

2012-02-16 Thread Marco Behnke
Am 16.02.12 22:37, schrieb Marc Guay:
> 2) The range of possibilities are broader than I indicated. They would
> like to be able to enter conditions of all sorts. i.e. ($x / $y) > 0.5
> (($a+$b+$c) / $d) < .75 etc. If you have any suggestions on how to
> increase the security while maintaning the flexibility, I'd be happy
> to hear it. Marc 

Is math all you want to use? Parsing will be an easy doing and I am
pretty sure there are a lot of examples around the web.
E.g.:
http://www.phpclasses.org/package/2695-PHP-Safely-evaluate-mathematical-expressions.html



-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] Turning a string into a condition

2012-02-16 Thread Matijn Woudt
On Thu, Feb 16, 2012 at 10:37 PM, Marc Guay  wrote:
>> It shouldn't be that hard to parse this type of expressions.
>
> I appreciate your concern, and will do my best to validate the input,
> but there are two things:
>
> 1)  The application will only be used by selected users.
> and

Even selected users can not be trusted, or it could be 'by accident',
though that seems unlikely.

> 2)  The range of possibilities are broader than I indicated.  They
> would like to be able to enter conditions of all sorts.  i.e.
>
> ($x / $y) > 0.5
> (($a+$b+$c) / $d) < .75
>
> etc.
>
> If you have any suggestions on how to increase the security while
> maintaning the flexibility, I'd be happy to hear it.
>
> Marc

A simple recursive PHP parser would work. You can find an example
here[1], though it handles probably more than you would like.

- Matijn

[1] http://aragon-online.net/forums/showthread.php?t=530

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



Re: [PHP] Re: Connect to Google

2012-02-16 Thread Matijn Woudt
On Thu, Feb 16, 2012 at 10:56 PM, Maciek Sokolewicz
 wrote:
> On 16-02-2012 03:56, John Taylor-Johnston wrote:
>>
>> I'm a teacher. I want to use PHP to interface with Google and see if a
>> student has plagiarized.
>>
>> I don't see many open-source projects on the subject, so I want to
>> create my own script.
>>
>> How can I use PHP to interface with Google and see if this text exists
>> on the internet?
>>
>> If this is possible, I need some ideas on how to parse the text and
>> input it into Google.
>>
>> Then I might like to get a percentage idea of how this text compares to
>> a site that Google has indexed.
>>
>>
>> $SampleText = "Lorem ipsum dolor sit amet, test link adipiscing elit.
>> Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc
>> iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet
>> at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa quis
>> luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget
>> metus. Maecenas ornare tortor. Donec sed tellus eget sapien fringilla
>> nonummy. Mauris a ante. Suspendisse quam sem, consequat at, commodo
>> vitae, feugiat in, nunc. Morbi imperdiet augue quis tellus."
>>
>> John
>>
> Hi, why don't you use one of existing tools for this? Our university (and
> most universities, and apparently also schools, in the Netherlands) use(s)
> ephorus (www.ephorus.com). As a tool it works quite well and does exactly
> what you asked for.
>
> I'm not sure about the costs though, though they claim them to be very low.
>
> The site seems to be experiencing difficulties right now, hopefuly it'll be
> up soon again.
>
> - Tul

It seems they are not very reliable as their site is down now.. ;)

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



Re: [PHP] Turning a string into a condition

2012-02-16 Thread Kevin Kinsey
On Thu, Feb 16, 2012 at 04:37:18PM -0500, Marc Guay wrote:
> > It shouldn't be that hard to parse this type of expressions.
> 
> I appreciate your concern, and will do my best to validate the input,
> but there are two things:
> 
> 1)  The application will only be used by selected users.
> and
> 2)  The range of possibilities are broader than I indicated.  They
> would like to be able to enter conditions of all sorts.  i.e.
> 
> ($x / $y) > 0.5
> (($a+$b+$c) / $d) < .75
> 
> etc.
> 
> If you have any suggestions on how to increase the security while
> maintaning the flexibility, I'd be happy to hear it.
> 
> Marc

You might try making a list of "dirty words" (in this case, not
the 4-letter type, but things you wouldn't want the user to be
able to do (mail() calls, filesystem type calls, etc.).

Another possibility might be to explode the contents of the
expression and run a call to function_exists() on it ... but
that might be a tad too broad as well.

HTH,

Kevin Kinsey

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



[PHP] Re: Connect to Google

2012-02-16 Thread Maciek Sokolewicz

On 16-02-2012 03:56, John Taylor-Johnston wrote:

I'm a teacher. I want to use PHP to interface with Google and see if a
student has plagiarized.

I don't see many open-source projects on the subject, so I want to
create my own script.

How can I use PHP to interface with Google and see if this text exists
on the internet?

If this is possible, I need some ideas on how to parse the text and
input it into Google.

Then I might like to get a percentage idea of how this text compares to
a site that Google has indexed.


$SampleText = "Lorem ipsum dolor sit amet, test link adipiscing elit.
Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc
iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet
at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa quis
luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget
metus. Maecenas ornare tortor. Donec sed tellus eget sapien fringilla
nonummy. Mauris a ante. Suspendisse quam sem, consequat at, commodo
vitae, feugiat in, nunc. Morbi imperdiet augue quis tellus."

John

Hi, why don't you use one of existing tools for this? Our university 
(and most universities, and apparently also schools, in the Netherlands) 
use(s) ephorus (www.ephorus.com). As a tool it works quite well and does 
exactly what you asked for.


I'm not sure about the costs though, though they claim them to be very low.

The site seems to be experiencing difficulties right now, hopefuly it'll 
be up soon again.


- Tul

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



Re: [PHP] Turning a string into a condition

2012-02-16 Thread Marc Guay
> It shouldn't be that hard to parse this type of expressions.

I appreciate your concern, and will do my best to validate the input,
but there are two things:

1)  The application will only be used by selected users.
and
2)  The range of possibilities are broader than I indicated.  They
would like to be able to enter conditions of all sorts.  i.e.

($x / $y) > 0.5
(($a+$b+$c) / $d) < .75

etc.

If you have any suggestions on how to increase the security while
maintaning the flexibility, I'd be happy to hear it.

Marc

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



Re: [PHP] Turning a string into a condition

2012-02-16 Thread Matijn Woudt
On Thu, Feb 16, 2012 at 9:49 PM, Marc Guay  wrote:
>> I just added the return statement and the semicolon, because the error was 
>> complaining about it not being a proper PHP statement basically.
>
> That's beautiful, thanks.  I just stumbled across a forum post that
> said it wasn't possible and was about to give up for the day.
>
> Marc

While it works, I'm a bit worried about how you're going to use this.
If the data is from user input, then this is really dangerous (that's
why there is a big fat warning on the eval man page).
You can easily execute nasty commands with eval.
If it is user input, then it would be much safer to do the parsing
yourself. It shouldn't be that hard to parse this type of expressions.

- Matijn

- Matijn

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



Re: [PHP] Turning a string into a condition

2012-02-16 Thread Marc Guay
> I just added the return statement and the semicolon, because the error was 
> complaining about it not being a proper PHP statement basically.

That's beautiful, thanks.  I just stumbled across a forum post that
said it wasn't possible and was about to give up for the day.

Marc

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



Re: [PHP] Turning a string into a condition

2012-02-16 Thread Ashley Sheridan
On Thu, 2012-02-16 at 15:38 -0500, Marc Guay wrote:

> > It sounds like you have a string "$x < $y" in the database that you then
> > replace into a string "4 < 5" which you want to test a conditional on. If
> > this is the case, why are you storing conditionals in the database?
> 
> The user will be able to construct their own query strings, it's
> complicated but necessary.  The issue I'm dealing with, though, is
> this:
> 
> $condition = "4 < 5";
> if ($condition){
> //do stuff
> }
> 


You were on the right lines with the eval:

$condition = "return 4 < 5;";

if (eval($condition))
{
//do stuff
}

I just added the return statement and the semicolon, because the error
was complaining about it not being a proper PHP statement basically.

-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Turning a string into a condition

2012-02-16 Thread Marc Guay
> It sounds like you have a string "$x < $y" in the database that you then
> replace into a string "4 < 5" which you want to test a conditional on. If
> this is the case, why are you storing conditionals in the database?

The user will be able to construct their own query strings, it's
complicated but necessary.  The issue I'm dealing with, though, is
this:

$condition = "4 < 5";
if ($condition){
//do stuff
}

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



Re: [PHP] Turning a string into a condition

2012-02-16 Thread Joshua Kehn
Can you explain a more clearly what it is you're trying to accomplish?

It sounds like you have a string "$x < $y" in the database that you then 
replace into a string "4 < 5" which you want to test a conditional on. If this 
is the case, why are you storing conditionals in the database?

Regards,

–Josh

Joshua Kehn | @joshkehn 
http://joshuakehn.com

On Feb 16, 2012, at 3:31 PM, Marc Guay wrote:

> Hi folks,
> 
> I've constructed simple conditions based on DB data and would like to
> actually evaluate them with PHP.  For example, the coded string "$x <
> $y" has been str_replaced into "4 < 5", but now I would actually like
> to use that string in an if() statement.  I tried eval() but got an
> unhelpful error, any thoughts would be welcome.
> 
> Marc
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 



[PHP] Turning a string into a condition

2012-02-16 Thread Marc Guay
Hi folks,

I've constructed simple conditions based on DB data and would like to
actually evaluate them with PHP.  For example, the coded string "$x <
$y" has been str_replaced into "4 < 5", but now I would actually like
to use that string in an if() statement.  I tried eval() but got an
unhelpful error, any thoughts would be welcome.

Marc

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



Re: [PHP] Connect to Google

2012-02-16 Thread Marc Guay
Sort of off topic but here's a list of existing services (some of
which are free) in case you don't want to reinvent the wheel.

http://www.justfitstudio.com/articles/plagiarism-detection.html

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



Re: [PHP] Connect to Google

2012-02-16 Thread Marc Guay
This is the first time I've been surprised that a Drupal module
existed for something...

http://drupal.org/project/authenticate

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



Re: [PHP] Connect to Google

2012-02-16 Thread Matijn Woudt
2012/2/16 John Taylor-Johnston :
> Can I use PHP to interface with Google? Any possible examples of this?

There's Google Custom Search API:
http://code.google.com/intl/nl-NL/apis/customsearch/v1/overview.html

It interfaces in JSON, and PHP has json functions included since PHP 5.2. [1].
It's free up to 100 queries a day, after that you have to pay $5 per
1000 queries.

- Matijn

[1] www.php.net/json

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



Re: [PHP] Connect to Google

2012-02-16 Thread Ashley Sheridan
On Thu, 2012-02-16 at 14:50 -0500, John Taylor-Johnston wrote:

> I'm a top quoter.
> I would parse the text first. Phrase by phrase, or phrase segments.
> Then spit out a report.
> 
> Marc Guay wrote:
> > If that's not good enough, can you explain how you would like it to
> > function?  Would the whole paper be scanned phrase-by-phrase for
> > matches and then spit out a report?
> 


You might be a top quoter but, please, to get the best from this list
and not annoy people post at the bottom. The list gets archived online
at many places, and it's annoying to read things in this order:

reply 4
>>reply 2
question
>>>reply 1
>reply 3

Almost every email client I know of allows bottom posting. This is just
one of the rules of this list, please don't be offended, but do try to
keep to the rules, it keeps everyone happy, and happy people are helpful
people!

-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Connect to Google

2012-02-16 Thread Ashley Sheridan
On Thu, 2012-02-16 at 14:47 -0500, John Taylor-Johnston wrote:

> Can I use PHP to interface with Google? Any possible examples of this?
> 
> Let's start with the first step. :)
> 
> I'm sure proprietary sites like http://www.compilatio.net/ for example 
> connects to search engines. They cannot be crawling the net too. That would 
> be crazy.
> 
> (I'm a top quoter. It's more intuitive.)
> 
> Thanks Ash.
> 
> John
> 
> 
> 
> Ashley Sheridan wrote:
> > On Wed, 2012-02-15 at 21:56 -0500, John Taylor-Johnston wrote:
> >> How can I use PHP to interface with Google and see if this text exists
> >> on the internet?
> >>
> >
> > Wow, that's a pretty big project you're chewing there. A quick search 
> > shows that there are some project out there to detect plagiarism, but 
> > I think for university calibre there's a hefty sum of money required.
> >


It might seem more intuitive to you, but it really, really screws up the
archives.

Like I said before, cURL is the way to "interface" with Google.
Basically, cURL can be used to request resources, in this case a web
page, from the web. You can call a URL and parse the page of results to
determine whatever you need to. As you've not really hashed out any firm
ides of what exactly you want, it's a little difficult to say exactly
what you need to do.

-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Connect to Google

2012-02-16 Thread John Taylor-Johnston

I'm a top quoter.
I would parse the text first. Phrase by phrase, or phrase segments.
Then spit out a report.

Marc Guay wrote:

If that's not good enough, can you explain how you would like it to
function?  Would the whole paper be scanned phrase-by-phrase for
matches and then spit out a report?


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



Re: [PHP] Connect to Google

2012-02-16 Thread John Taylor-Johnston

Can I use PHP to interface with Google? Any possible examples of this?

Let's start with the first step. :)

I'm sure proprietary sites like http://www.compilatio.net/ for example connects 
to search engines. They cannot be crawling the net too. That would be crazy.

(I'm a top quoter. It's more intuitive.)

Thanks Ash.

John



Ashley Sheridan wrote:

On Wed, 2012-02-15 at 21:56 -0500, John Taylor-Johnston wrote:

How can I use PHP to interface with Google and see if this text exists
on the internet?



Wow, that's a pretty big project you're chewing there. A quick search 
shows that there are some project out there to detect plagiarism, but 
I think for university calibre there's a hefty sum of money required.




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



Re: [PHP] Connect to Google

2012-02-16 Thread Marc Guay
> If you use the advanced search
> tools you can choose "verbatim" and see if the exact phrase matches.

Just correcting myself here, the way to do this is by simply wrapping
the words in quotes "like this, hey now".  The verbatim tool is
something else.

Marc

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



Re: [PHP] Connect to Google

2012-02-16 Thread Ashley Sheridan
On Wed, 2012-02-15 at 21:56 -0500, John Taylor-Johnston wrote:

> I'm a teacher. I want to use PHP to interface with Google and see if a 
> student has plagiarized.
> 
> I don't see many open-source projects on the subject, so I want to 
> create my own script.
> 
> How can I use PHP to interface with Google and see if this text exists 
> on the internet?
> 
> If this is possible, I need some ideas on how to parse the text and 
> input it into Google.
> 
> Then I might like to get a percentage idea of how this text compares to 
> a site that Google has indexed.
> 
> 
> $SampleText = "Lorem ipsum dolor sit amet, test link adipiscing elit. 
> Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc 
> iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet 
> at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa quis 
> luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget 
> metus. Maecenas ornare tortor. Donec sed tellus eget sapien fringilla 
> nonummy. Mauris a ante. Suspendisse quam sem, consequat at, commodo 
> vitae, feugiat in, nunc. Morbi imperdiet augue quis tellus."
> 
> John
> 
> 


Wow, that's a pretty big project you're chewing there. A quick search
shows that there are some project out there to detect plagiarism, but I
think for university calibre there's a hefty sum of money required.

To get a rough idea, you could break a text into sentences, and then
query each one of those to see if it occurs just like that. You can use
cURL to grab search results pages for this sort of thing, no need for a
special interface. There are a few things to bear in mind though:


  * Googles terms and conditions may prohibit using their search
engine like this, or may impose a limit on how much you can do
this
  * Some sentences will be intentionally copied, as quotes. Maybe
some sort of check against the source to see if it's in a quote
context.
  * What if only part of a sentence is copied?


Maybe after you've searched for exact matches from the sentences in the
source, you could remove them from the source, then re-check every
sentence against Googles fuzzy search. It may produce many false
positives though.

There are plenty of other factors too, such as students copying from
books which don't exist in a search engines archives, some subjects may
unintentionally result in the same way of wording, particularly
technical subjects which tend to be removed from more creative and
flowery descriptive tendencies.

-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Connect to Google

2012-02-16 Thread Marc Guay
> I'm a teacher. I want to use PHP to interface with Google and see if a
> student has plagiarized.

Hi.  Why not just enter the suspected text into a search engine and
see if any close matches come up?  If you use the advanced search
tools you can choose "verbatim" and see if the exact phrase matches.
If that's not good enough, can you explain how you would like it to
function?  Would the whole paper be scanned phrase-by-phrase for
matches and then spit out a report?

Marc

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



[PHP] Connect to Google

2012-02-16 Thread John Taylor-Johnston
I'm a teacher. I want to use PHP to interface with Google and see if a 
student has plagiarized.


I don't see many open-source projects on the subject, so I want to 
create my own script.


How can I use PHP to interface with Google and see if this text exists 
on the internet?


If this is possible, I need some ideas on how to parse the text and 
input it into Google.


Then I might like to get a percentage idea of how this text compares to 
a site that Google has indexed.



$SampleText = "Lorem ipsum dolor sit amet, test link adipiscing elit. 
Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc 
iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet 
at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa quis 
luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget 
metus. Maecenas ornare tortor. Donec sed tellus eget sapien fringilla 
nonummy. Mauris a ante. Suspendisse quam sem, consequat at, commodo 
vitae, feugiat in, nunc. Morbi imperdiet augue quis tellus."


John


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



Re: [PHP] Form Post to different domain

2012-02-16 Thread Matijn Woudt
On Thu, Feb 16, 2012 at 5:02 PM, Daniel Brown  wrote:
> On Thu, Feb 16, 2012 at 10:57, Matijn Woudt  wrote:
>>
>> What if the system PHP is running on not the same one as the one that
>> is going to read the plain-text/CSV/.. files? I don't think it is good
>> practice to use it when writing to files. I often write files on a
>> Linux server that people are going to read on a Windows PC.
>
>    Then what is the difference between PHP_EOL and forcing \n?  It's
> still going to use POSIX-style EOLs, but now you've taken away the
> benefit of the compatibility.

I'm not saying you should force \n then, but you might want to decide
what to force depending on who will be using it, so in case a windows
user is going to read it, then you set \r\n, otherwise you select
\n.You could even try to detect that based on a browser identification
string.

>
>> Apart from that, most software written in the last 5-10 years will
>> happily read files with either \n or \r\n line endings. I'm not really
>> sure about Win XP for example, but if it would have a problem with the
>> Linux \n endings, it might even be better to *always*  use \r\n line
>> endings (except where standards require it), as I haven't seen a
>> single Linux application since I started using it (about 9 years ago)
>> that was not able to read a file with \r\n based line endings.
>
>    You may want to check again.  Ever see ^M at the end of your
> lines?  Or, in vim, notice how it says it's a DOS file?

I have seen them, but only in files which had mixed line endings,
which should of course never be used. Vim does indeed notice it's a
'dos' file, but it's merely detecting that the file has \r\n line
endings and that it should add those too. I don't consider that bad.

>
>> Even better, go Unicode. Unicode specifies that there are 8 ways to
>> make a new line, and they should all be accepted. However, the pretty
>> uncommon NEL, LS and PS are not supported in many applications.
>> (though CR, LF and CRLF are).
>
>    Nothing you've suggested is necessarily bad, but more to the
> point, it doesn't come close to invalidating the benefit of PHP_EOL.

I'm not saying using PHP_EOL is bad, but I disagree with using it
always as a habit. If line endings matter, then you need to make
decisions based on that, and don't depend on it being automatically OK
if PHP_EOL is used.

- Matijn

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



Re: [PHP] Form Post to different domain

2012-02-16 Thread Daniel Brown
On Thu, Feb 16, 2012 at 10:57, Matijn Woudt  wrote:
>
> What if the system PHP is running on not the same one as the one that
> is going to read the plain-text/CSV/.. files? I don't think it is good
> practice to use it when writing to files. I often write files on a
> Linux server that people are going to read on a Windows PC.

Then what is the difference between PHP_EOL and forcing \n?  It's
still going to use POSIX-style EOLs, but now you've taken away the
benefit of the compatibility.

> Apart from that, most software written in the last 5-10 years will
> happily read files with either \n or \r\n line endings. I'm not really
> sure about Win XP for example, but if it would have a problem with the
> Linux \n endings, it might even be better to *always*  use \r\n line
> endings (except where standards require it), as I haven't seen a
> single Linux application since I started using it (about 9 years ago)
> that was not able to read a file with \r\n based line endings.

You may want to check again.  Ever see ^M at the end of your
lines?  Or, in vim, notice how it says it's a DOS file?

> Even better, go Unicode. Unicode specifies that there are 8 ways to
> make a new line, and they should all be accepted. However, the pretty
> uncommon NEL, LS and PS are not supported in many applications.
> (though CR, LF and CRLF are).

Nothing you've suggested is necessarily bad, but more to the
point, it doesn't come close to invalidating the benefit of PHP_EOL.

-- 

Network Infrastructure Manager
http://www.php.net/

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



Re: [PHP] Form Post to different domain

2012-02-16 Thread Matijn Woudt
On Thu, Feb 16, 2012 at 4:09 PM, Daniel Brown  wrote:
> On Thu, Feb 16, 2012 at 09:53, Tedd Sperling  wrote:
>
>    This means you can rest assured that the newlines will be
> appropriate for the system on which PHP is running.  While it makes
> little difference on the web, it makes a world of difference at the
> CLI and when writing to plain-text files (including CSV).  I've been
> using it out of the force of habit for about seven years or so, and
> exclusively (with the exception of email headers and other warranted
> cases) for the last four.
>

What if the system PHP is running on not the same one as the one that
is going to read the plain-text/CSV/.. files? I don't think it is good
practice to use it when writing to files. I often write files on a
Linux server that people are going to read on a Windows PC.

Apart from that, most software written in the last 5-10 years will
happily read files with either \n or \r\n line endings. I'm not really
sure about Win XP for example, but if it would have a problem with the
Linux \n endings, it might even be better to *always*  use \r\n line
endings (except where standards require it), as I haven't seen a
single Linux application since I started using it (about 9 years ago)
that was not able to read a file with \r\n based line endings.

Even better, go Unicode. Unicode specifies that there are 8 ways to
make a new line, and they should all be accepted. However, the pretty
uncommon NEL, LS and PS are not supported in many applications.
(though CR, LF and CRLF are).

- Matijn

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



Re: [PHP] Form Post to different domain

2012-02-16 Thread Daniel Brown
On Thu, Feb 16, 2012 at 09:53, Tedd Sperling  wrote:
>
> Why the '.PHP_EOL' ?
>
> I've never seen that before and looking through the PHP documentation doesn't 
> give me much.

Cross-compatibility.  For systems which use \n, PHP_EOL will be
\n.  For systems which use \r\n, PHP_EOL will be \r\n.  And, for
oddball or legacy systems which still use \r you get the point.

This means you can rest assured that the newlines will be
appropriate for the system on which PHP is running.  While it makes
little difference on the web, it makes a world of difference at the
CLI and when writing to plain-text files (including CSV).  I've been
using it out of the force of habit for about seven years or so, and
exclusively (with the exception of email headers and other warranted
cases) for the last four.

There are a lot of other very useful and yet very underused
constants.  You can find the info on them here:

http://php.net/reserved.constants

-- 

Network Infrastructure Manager
http://www.php.net/

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



Re: [PHP] Form Post to different domain

2012-02-16 Thread Tedd Sperling
On Feb 14, 2012, at 1:39 PM, Daniel Brown wrote:

> On Tue, Feb 14, 2012 at 13:36, Rick Dwyer  wrote:
>> 
>> I only have access to domain B... the one receiving the Form POST.
> 
>Then all you should need to do is:
> 
>a.) Verify that Domain A is indeed pointing to Domain B, to
> the script you expect, as a POST request.
>b.) In the POST-receiving script on Domain B, try this simple snippet:
> 
>  echo ''.PHP_EOL;
> var_dump($_POST);
> die('');
> ?>
> 
>That should give you all data from the post request.
> 
> -- 
> 
> Network Infrastructure Manager
> http://www.php.net/

Why the '.PHP_EOL' ?

I've never seen that before and looking through the PHP documentation doesn't 
give me much.

Cheers,

tedd


_
t...@sperling.com
http://sperling.com

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