ImageBlock not working - http://www.studio4tattoos.co.uk/gallery2/
GazNicki
Joined: 2009-09-15
Posts: 36 |
Posted: Tue, 2010-02-16 12:49 |
<!-- Issue Details --> I have been trying without success to solve this problem, but really cannot. The imageblock will not display on my page. I have tried both imageblock and mediaBlock to perform this, but without success. I have a index.php file and using the @readfile I cannot display the images. By utilising an iframe on my webpage, I can get the results I require, but the iframe is an inferior solution, and to be honest - an ugly one with minimal support for various browsers. I have also utilised the CURL solution found on the net, and this seems to work when I use someone else's website (they gave a link to use) but using my link it will not work. Can anyone please help me. Is there a way to enable the @readfile() command (I have full control over my php.ini file). Any help would be appreciated. Regards, |
|
Posts: 8339
You need to enable the fopen_wrappers in php.ini
Post a link to your phpinfo
instructions for creating a phpinfo here.
I also have a jquery version of mediaBlock and the ever popular minislideshow.
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 36
Apologies for the missing phpinfo link. http://www.studio4tattoos.co.uk/phpinfo.php
Will look into the php.ini file now.
Posts: 8339
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 36
Yeah, I have control of the php.ini but limited knowledge on how to adjust it lol.
fopen_wrappers is not listed in the php.ini file I have, but I have added the following:
This hasn't resolved the issue, and I am struggling to find how to enable it in the php.ini file using Google. Any advice??
Edit:
phpinfo.php indicates the following:
allow_url_fopen:
Local Value = On
Master Value = On
Posts: 8339
http://us3.php.net/manual/en/function.readfile.php
what code are you using in your imageblock/mediaBlock call?
where are you trying to display these blocks?
as answered in my forums, mediaBlock is outputting content:
http://www.studio4tattoos.co.uk/gallery2/mediaBlock.php?mode=dynamic&g2_view=dynamicalbum.RandomAlbum&showTitle=1&useThumb=1&column=3
looks like you've added <head> and <body> tags to mediaBlock??? Not advised when you include its output in other pages.
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 36
Please advise which forums your preferance for us to use is.
I have setup an index.php and an index.htm.
The htm file is ustilising iframes with formatting through a CSS file to allow some level of cross-browser compatability. Unfortunately, this is not the ideal answer to the problem.
The php file is using the @readfile commands. When I have loaded up the sourcecode through the web-browser however for the php file, the @readme lines are not shown in the code.
The code for the HTML file is as follows:
The code for the PHP file is as follows:
Posts: 8339
So you're trying to embed gallery in yoursite? try my easy form.
otherwise I see several issues
only one o in tatoos? and should be tags.VirtualAlbum
no need for px - g2_view=imageblock.External should be mode=dynamic
other then the misspelled tatoo these are outputting content.
So curl should work for you if readfile is not.
you can also use:
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 36
I am now using the following in the PHP file:
<? php
echo files_get_contents('http://www.studio4tattoos.co.uk/gallery2/mediaBlock.php?mode=dynamic&g2_view=dynamicalbum.RandomAlbum&useThumb=1&column=1&useMicro=150');
?>
<?php
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, 'http://www.studio4tattoos.co.uk/gallery2/mediaBlock.php?mode=dynamic&g2_view=tags.VirtualAlbum&g2_tagName=tattoo&useThumb=1&column=1&useMicro=150');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
echo $file_contents;
?>
Unfortunately neither of these two produce any form of output. Where am I going wrong??
Posts: 8339
if the file you are placing this code in does not have the .php extension then the php will not get executed.
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 36
It does have a php extention, it is the index.php file.
I have used your easy form, and it is a fantastic piece of kit, but not the result I am after. I just require to link the images to the index page. Getting the PHP file to work properly is turning out to be quite important. While the HTM file is using the iframes with great success, the PHP file will offer greater versatility to my website.
Is there anything else that you can see that I am doing wrong with either of these pieces of code? Is there anything else I should enable in php.ini??
I'm sorry this is turning into a headache.
Posts: 8339
the url you used in your curl did not work, but this did http://www.flashyourweb.com/gallery2/curlTest.php
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 8339
try this:
and remove the:
<html>
<head><link rel="stylesheet" href="style.css" type="text/css" /></head>
<body>
from mediaBlock.php
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 8339
And if you enable the image frame module you'll get the dropshadow
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 36
Removed all additions to mediBlock.php and adjusted the index.php file to utilise the code you have above.
This is the end result: http://www.studio4tattoos.co.uk/index.php
I have tested the functionality of php by using a simple hello world code:
<?php
echo "hello world!";
?>
This displays hello world! in my site, so the php must be functioning properly. I just have no idea why none of this is working right. I feel like crying lol
Posts: 8339
you never did post a link to your phpinfo
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 36
Third post mate
http://www.studio4tattoos.co.uk/phpinfo.php
Posts: 8339
Sorry.
The only issues I see in your php: output_buffering should be zero and upload_max_filesize you'll want larger then 2M
and why am I seeing /** Use this to display your content */
That comment should be ignored. can you attach your index.php to this forum?
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 36
Thanks. I have updated the php.ini file and this should now be reflected in the phpinfo.php file.
Below is a copy of the index.php file that is currently on my server. Both versions are identical, I haven't made any changes either server-side or locally.
Posts: 36
I decided to make a fresh php file and start again to test the integrety of the website and try and narrow this problem down. There really is only 3 possible problems:
1) Corrupt mediaBlock.php file - Not the case as it is working when linked directly to. Never-the-less I have re-downloaded this file and replaced it on the server.
2) Corrupt coding in my index.php file - This would be my error so a fresh index2.php file was created to test the server.
3) Incorrect server settings - I have created my index2.php file to display errors.
The file can be found here:
http://www.studio4tattoos.co.uk/index2.php
What I have found is that @readfile displays nothing. No error and no output. I have linked it to a variable using the following code to see if it helps:
<?php
$a = @readfile('http://www.studio4tattoos.co.uk/gallery2/mediaBlock.php?mode=dynamic&amp;g2_view=dynamicalbum.RandomAlbum&amp;showTitle=1');
echo ($a);
?>
This didn't work either.
Since readfile didn't work, I decided to try file_get_contents like so:
<?php
$a = file_get_contents('http://www.studio4tattoos.co.uk/gallery2/mediaBlock.php?mode=dynamic&g2_view=dynamicalbum.RandomAlbum&showTitle=1');
echo ($a);
$b = file_get_contents('http://www.studio4tattoos.co.uk/index.htm');
echo ($b);
?>
Guess what ... we get errors!!
Warning: file_get_contents(http://www.studio4tattoos.co.uk/gallery2/mediaBlock.php?mode=dynamic&g2_view=dynamicalbum.RandomAlbum&showTitle=1) [function.file-get-contents]: failed to open stream: Connection refused in /home/sites/studio4tattoos.co.uk/public_html/index2.php on line 12
Warning: file_get_contents(http://www.studio4tattoos.co.uk/index.htm) [function.file-get-contents]: failed to open stream: Connection refused in /home/sites/studio4tattoos.co.uk/public_html/index2.php on line 14
If we slip in another cheeky bit of code, we can prove that the file_get_contents actually works for an EXTERNAL website, but not for an internal one. This code proves it:
$c = file_get_contents('http://www.google.co.uk');
echo ($c);
I have attatched a copy of the index2.php file that I have been using to test this. It is now live too via http://www.studio4tattoos.co.uk/index2.php
I hope this can bring us one step closer
Posts: 8339
so here is your index.php copied to my curlTest http://www.flashyourweb.com/gallery2/curlTest.php
the top 2 images use my curl function and the bottom 2 use readfile
So your server refuses connections from itself, but accepts foreign connections?
gonna have to google that one or maybe I'll Bing it ;)
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 36
Yeah that seems to be the issue that I have at the moment.
I do have the ability to switch to PHP4 4.4.9, but have been advised that the issue is more a settings issue. I have been trying to google but not a thing yet.
Sorry this is turning into a headache. I really appreciate your help.
Posts: 8339
http://www.cyberciti.biz/faq/connection-refused-connect-to-listener-on-000080/
loopback connection?
sorry not an apache expert.
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 36
Unfortunately me neither lol. Thats quite confusing lol
Posts: 4342
Hmm. Johnny-come-lately to this one too. First thing to check (if I understand what I read right) is whether the server can open any connections to itself: can you use wget from a shell, or lynx, to your own website? Try via http://localhost/... too.
Posts: 36
beyond my knowledge at the moment that. But I will certainly try to fathom it out.
Posts: 4342
OK - but in the spirit of divide-and-conquer, you need to narrow down whether it's a server issue (wget doesn't work either) or a php issue (wget and lynx are fine loading local pages, but nothing in php works).
Posts: 36
Any advice on where I should start with the wget? Will I need SSH Access??
Posts: 8339
To me it looks to be an apache issue. php cannot refuse connections.
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 4342
Yes, you'll need SSH access to use a shell session (SSH is short for Secure SHell... I wouldn't recommend telnet) unless your server is physically local and you have a screen and keyboard attached, which I guess it isn't.
wget is a standard system tool for fetching files via http from a command prompt. Lynx is a text-only browser. It's quite likely that wget is available to you already if you open a shell. try "wget --help" for syntax, but basically you can type "wget <url>" to fetch something.
It could be apache refusing a local connection; it could be an IP filter refusing outbound connections to local host; it could be something else in the TCP/IP stack fouling up. So there are lots of things to try: telnet to daytime, if it's available, try ssh to localhost from inside the shell, to open another shell inside the first, try to narrow down which combination of system parts shows any problems. Very hard to guess without some tests. Or it could be a php bug, or ... who knows?
Posts: 8339
I also invited nivekiam - that's at least 4 brain cells knocking together ;)
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 36
I think my head is going to explode lol
I have submitted a ticket to the Hosting Company to grant SSH access on the account. Is there anything else I can be doing in the mean time?? Changing to 4.4.9 just crashed the Gallery2, so I guess thats not an option at present.
Edit:
Thanks suprsidr. I make my contributions equal to about 0.25% of a cell though haha
Posts: 4342
Just a thought: you may find it's a "security policy" of the hosting company to block local->local web requests. I can't honestly think why they should find it necessary, but I've heard of stupider things.
Posts: 36
What a joke. The Support Team has gotten back to me with a request for ID and a completed document to be faxed to the company before the SSH Access will be granted.
Just asked if Local->Local web requests are permitted. Reply from the Service Desk:
Hi Gareth Parkinson
Thanks for contacting us. Loop-back connections are not permitted on our servers and are blocked at the firewall. This is in place to protect the server from its self and is not possible to get around. They should be able to reprogram the script to run the code without calling a loopback.
Posts: 4342
Not unusual. I have been asked to fax my passport before getting SSH access in the past. And that was on a server with a tight-as-a-badger's-whatsit chroot jail for users.
Posts: 4342
You heard it here first.
Posts: 36
Looks like you was bang on the money with the Security there alec. Any idea what the lottery numbers are tonight? lol
So, can I utilise my other server to link to an external mediaBlock.php file that links to the Gallery2 on my studio4tattoos.co.uk server?
Posts: 4342
Sure. Write a script on your other server that takes the params you need to supply and bounces them back in a query to the original server, then reflects the output back. A bit hack-y, but no reason why it shouldn't work.
Maybe you can look at using G2 embedded to display the images you want? Then there's no need for an "internal" web query, you can get G2 to return the html (that you would have got from the query) in a variable, instead. Supersidr is much more knowlegeable than I on that kind of stuff. I'm sure he can advise you.
Posts: 8339
Actually my jquery version may work better. Unless self-ajax calls are blocked as well.
Seems I also made a mediaBlock-includes.php for someone in a similar sit.
it was used lik:
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 36
Thanks. Unfortunately I don't know where to start with that one. In principle tha basics should work. Send the results from server A -> B, then let server A get the results back from server B.
But how to code lol.
Posts: 4342
One suspects they are, as ajax is carried via http on port 80 also.
Posts: 36
Where can I download the mediaBlockIncludes.php file?? This seems like a pretty good option.
Posts: 8339
http://www.flashyourweb.com/filemgmt/index.php
its a few versions behind the current mediaBlock.... I had removed support for this script. But it should function fine for your needs.
BTW you need to enable dynamic albums to use any of the mode:dynamic features
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 36
Thanks,
Do I install this into my root or into my gallery2 folder??
Posts: 8339
does not matter as long as you use the /full/system/path/to/gallery2/embed.php for line 27 and its advisable to use full urls for the g2Uri and embedUri on line 28 (makes it portable)
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 36
Using the code:
Gave this error:
Posts: 8339
not a url a path ie. /home/sites/studio4tattoos.co.uk/public_html/gallery2/embed.php
the require to mediaBlockIncludes would also be a path
require_once ('/home/sites/studio4tattoos.co.uk/public_html/mediaBlockIncludes.php');
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 36
Ok, Changed to /home/sites/studio4tattoos.co.uk/public_html/ as the root folder.
This now rails and displays nothing again. Infact, any further php is no ignored too. No errors, just not display.
Posts: 8339
mediaBlockIncludes.php:
page you are trying to display content in:
you don't seem to have any tags defined or the tags module is not installed so you cannot use the tags view
to use mode:dynamic g2_view:random you need to enable the dynamics albums module
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 36
Amazing. Thank you!
This works, so now I can tweak it to give the exact results I require. You my friend are nothing short of a genuis.
Big thanks to Alec too!
Posts: 16504
Great work guys! Glad I could help
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here