PDA

View Full Version : Can't get snippets to work at all


cd500 user
1st of July 2005 (Fri), 10:09
I've been trying for the last two days to get snippets to work on my site. I just want to put a random 10 images on the index page, underneath the list of groups. I've found the right location in groupindex.php and a test include (pulling variables from another file even) works ok so I know includes are functional on my site.

I changed a bit of the snippetdemo php code to compare back to back with Pekka's site and you can see that his site will include ok (albeit with an error, "Undefined variable: orlist..." but it still includes). The error I am getting is directly below that in red. Here is the entire page, it is much easier to look at the error than to retype everything here: http://www.driftwoodroad.com/ee/snippetdemo2.php

The include_path is so long because I thought at first the path was not correct, so I included everything I thought EE would need but it has not worked.

Please does anyone have any ideas, this is beginning to drive me crazy.

Thank you,
Patrick

Pekka
1st of July 2005 (Fri), 11:23
Most likely the problem is "allow_url_fopen" directive. Try the attached snippets.php, it has other bug fixes, too.

cd500 user
1st of July 2005 (Fri), 11:59
Pekka thank you for the quick response. Now there is good news and bad news - the good news is the snippets code works if I copy/paste the URL directly into the browser. The bad news is it still won't "include" in the page. I do have "allow_url_fopen" set to ON in my php.ini. The new snippets.php is on the server but I still get the same 404 message in the link above.

This I really don't understand since on my server some includes work (like the one on the groupindex page, see http://www.driftwoodroad.com/ee/ a very simple include "test.php") but the snippets always give a 404 when I try to include. Any more ideas? I told you it was driving me crazy :)

Thank you very much,
Patrick

wkitty42
1st of July 2005 (Fri), 16:14
have you searched for snippets in this forum? if not, you should and keep an eye out for those threads about snippets that i participated in... i went thru quite a bit of working and testing... some of my problems are/were caused by my own restrictions on visitors to my site (ie: no UserAgent == blocked access)... i also had to allow my system to access itself via my htaccess... i think that was all done via http access to the includes and such... i reworked stuff and was able to get things included internally on the server without using http access and that helped a lot... do that search and see if my posts help...

i've not grabbed the snippets.zip that pekka just posted to you to compare it with what i have currently online... everything i have is/was posted right here in this forum ;)

Pekka
1st of July 2005 (Fri), 16:36
I put on a page http://photography-on-the.net/ee/snippetdemo.php which has

<?php
include("http://www.driftwoodroad.com/ee/snippets.php?get=latest_galleries");
?>

<p><hr>

<?php
include("http://driftwoodroad.com/ee/snippets.php?get=latest_photos&viewas=text");
?>

and as you see it works ok. So the issue is only in remote include feature in your server/PHP. As it gives error 404,

see http://www.php.net/manual/en/function.include.php and there

Windows versions of PHP prior to PHP 4.3.0 do not support accessing remote files via this function, even if allow_url_fopen is enabled.

Could above warning apply to your server?

Problem could also be this:
Do you have mod_security module loaded in your Apache? Mod security can deny access to URL using rules and return e.g. 404 on "hit", these rules can be seen in httpd.conf of Apache.

PS. If you do not call snippets from external server, try using

http://localhost/ee/snippets.php?get=latest_galleries

or

http://127.0.0.1/ee/snippets.php?get=latest_galleries

cd500 user
2nd of July 2005 (Sat), 00:01
I am running PHP 4.3.6. Changing it to localhost fixed it. I did try that with the older snippets file yesterday, but got errors and so changed it to external. Thanks again for the great support!

Regards,
Patrick