How to display the image which is in the cache file?

Author Message

zfirst zlast

Wednesday 26 November 2008 12:48:04 am

Hi All,

I have installed an extension "Human Captcha" on my site, and add the codes following into the template:

<img src={ezhumancaptcha_image()|ezroot()} alt="eZHumanCAPTCHA" />

But it not works now. I checked the source code, found the url of image is: /var/ezflow_site/cache/ezhumancaptcha/0b371fcfc9ab0ea5ca9a5aa3b2bb17eaf30d293f.jpg. Then i check the folder, found the image is there, but if i view via the url: http://mysite.com/var/ezflow_site/cache/ezhumancaptcha/0b371fcfc9ab0ea5ca9a5aa3b2bb17eaf30d293f.jpg, it failed.

Is there anybody know how to view an image in the cache file? As i guessed the problem may be because of the view privilege of the cache file.

Duffy Walsh

Wednesday 27 January 2010 8:59:14 am

I am having the same problem, did you find it was an issue with file or directory permissions on the server?

Duffy Walsh

Viktor Belak

Saturday 05 February 2011 11:00:52 am

I have the same problem... in cache, picture is created, but in form there is nothing... how is it possible...??

it looks like it is not accesible...really

Viktor Belak

Tuesday 08 February 2011 1:51:50 pm

Does anyone knows how to force token image generates image into cache directory of ezhumancaptcha with good permission??? 660 or something... I've tried every possible way and look in whole code, but I have no idea anymore... please...

viktor

Viktor Belak

Wednesday 09 February 2011 10:21:24 am

I've finally solved the problem...

In class file ezhumancaptchatools.php I've added line with a chmod function and change directory to store token images to storage, also further in the script, it looks like this>

public static function generateImagePath( $encryptedToken )
{
$ini = eZINI::instance('ezhumancaptcha.ini');
$tokenDirectory = eZSys::storageDirectory() . '/'. $ini->variable( 'GeneralSettings', 'TokenCacheDir' ) .'/';
$tokenFormat = $ini->variable( 'CommonCAPTCHASettings', 'TokenFormat' );

if( !eZDir::isWriteable( $tokenDirectory ) )
{
eZDebug::writeNotice( 'Cache subdirectory does not exist, attempting to create', 'eZHumanCAPTCHATools::generateImagePath' );
eZDir::mkdir( $tokenDirectory );
}
$tokenPath = $tokenDirectory.sha1( $encryptedToken ).'.'.$tokenFormat;
chmod( $tokenPath, octdec( eZINI::instance('ezhumancaptcha.ini')->variable( 'CommonCAPTCHASettings','StorageFilePermissions' ) ) );
return $tokenPath;
}

And in ezhmumancaptha.ini.appen.php I have added under the section CommonCAPTCHASettings this>

[CommonCAPTCHASettings]

TokenStorageFilePermission=0660

And it works actually,

VikTor

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.