CodeIgniter Forums

Full Version: php includes
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Unknown[/eluser]
Ok so im trying to install reCaptcha onto one of my sites...

for those who dont know, reCaptcha is a simple anti bot / anti spam application...

To install it it needs to use:

require_once();

so i uploaded the file it needs to require into the SYSTEM folder of codeigniter...

when i run:

require_once(base_url().'system/recaptchalib.php');

i get the following errors:

Code:
A PHP Error was encountered

Severity: Warning

Message: require_once() [function.require-once]: URL file-access is disabled in the server configuration

Filename: user_control/register.php

Line Number: 21

---------------------------

A PHP Error was encountered

Severity: Warning

Message: require_once(http://donov.co.uk/game/system/recaptchalib.php) [function.require-once]: failed to open stream: no suitable wrapper could be found

Filename: user_control/register.php

Line Number: 21

---------------------------

Fatal error: require_once() [function.require]: Failed opening required 'http://donov.co.uk/game/system/recaptchalib.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/donov/public_html/game/application/views/user_control/register.php on line 21


now i vaguley understand that its because codeignightor doesnt let you use require_once(); and that there should be a way to remove this restriction in the config.php...

i cant find the option to remove the restriction...

maybe theres a better way...

can anyone help?

(this is the first time i used CVM im probably doing it wrong)

El Forum

[eluser]Dyllon[/eluser]
CI does not restrict access to any php functions.

You should add libraries to your application directory, not your system directory.

I haven't used reCaptcha personally nor do I know what the file structure looks like but in most cases it's a matter of dropping the desired library into the libraries folder, adding the include path, and possibly writing a small wrapper.

El Forum

[eluser]must[/eluser]
hi,
Personally i wasn't aware of this restriction because i never had to use require_once() or include() in Codeigniter. You can implement Recaptcha as a helper or a plugin check plugins / helpers
or you can simply use one of the libraries offered by the community
http://codeigniter.com/wiki/ReCAPTCHA/
http://codeigniter.com/wiki/reCAPTCHA_2/

edit: oh and yes you should use the application folder to add any thing to your web-application

El Forum

[eluser]Unknown[/eluser]
I setup the ReCAPTCHA_2 helper and it displays fine...

The validation fails every time tho... i have a feeling that its because the field you type the answer into isnt the field that the validation checks... however i dont see another field to check.

If i post back the field its trying to validate i get nothing.

El Forum

[eluser]must[/eluser]
Make sure that you're checking the recaptcha_challenge_field field (and check the html source to be sure that that's the field you need to be checking on).
if you can't get it to work try http://codeigniter.com/wiki/ReCAPTCHA/ it's more organized and compatible plus it has a good documentation and examples that you can follow.