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.

eZ debug

Timing: Jan 30 2025 16:37:08
Script start
Timing: Jan 30 2025 16:37:08
Module start 'layout'
Timing: Jan 30 2025 16:37:08
Module start 'content'
Timing: Jan 30 2025 16:37:08
Module end 'content'
Timing: Jan 30 2025 16:37:08
Script end

Main resources:

Total runtime0.0203 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0040 588.3750151.2422
Module start 'layout' 0.00400.0032 739.6172220.7344
Module start 'content' 0.00720.0117 960.35161,002.0078
Module end 'content' 0.01900.0013 1,962.359437.9922
Script end 0.0203  2,000.3516 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002311.4648140.0002
Check MTime0.00104.7526140.0001
Mysql Total
Database connection0.00052.622610.0005
Mysqli_queries0.00199.327730.0006
Looping result0.00000.049410.0000
Template Total0.00104.810.0010
Template load0.00073.574710.0007
Template processing0.00021.197910.0002
Override
Cache load0.00052.520310.0005
General
dbfile0.00178.287480.0002
String conversion0.00000.025940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs