@@ -165,7 +165,15 @@ public function display_graph_by_resource()
165
165
$ resource_list = $ new_list ;
166
166
$ i = 1 ;
167
167
// Cache definition
168
- $ cachePath = api_get_path (SYS_ARCHIVE_PATH );
168
+ $ cachePath = api_get_path (SYS_ARCHIVE_PATH ) . 'chart/ ' ;
169
+ if (!file_exists ($ cachePath )) {
170
+ mkdir ($ cachePath , 0755 , true );
171
+ }
172
+
173
+ if (!is_writable ($ cachePath )) {
174
+ chmod ($ cachePath , 0755 );
175
+ }
176
+
169
177
foreach ($ resource_list as $ key => $ resource ) {
170
178
// Reverse array, otherwise we get highest values first
171
179
$ resource = array_reverse ($ resource , true );
@@ -196,9 +204,8 @@ public function display_graph_by_resource()
196
204
$ myCache = new pCache (['CacheFolder ' => substr ($ cachePath , 0 , strlen ($ cachePath ) - 1 )]);
197
205
$ chartHash = $ myCache ->getHash ($ dataSet );
198
206
if ($ myCache ->isInCache ($ chartHash )) {
199
- $ imgPath = api_get_path ( SYS_ARCHIVE_PATH ) .$ chartHash ;
207
+ $ imgPath = $ cachePath .$ chartHash ;
200
208
$ myCache ->saveFromCache ($ chartHash , $ imgPath );
201
- $ imgPath = api_get_path (WEB_ARCHIVE_PATH ).$ chartHash ;
202
209
} else {
203
210
/* Create the pChart object */
204
211
$ widthSize = 480 ;
@@ -294,11 +301,10 @@ public function display_graph_by_resource()
294
301
/* Render the picture (choose the best way) */
295
302
296
303
$ myCache ->writeToCache ($ chartHash , $ myPicture );
297
- $ imgPath = api_get_path ( SYS_ARCHIVE_PATH ) .$ chartHash ;
304
+ $ imgPath = $ cachePath .$ chartHash ;
298
305
$ myCache ->saveFromCache ($ chartHash , $ imgPath );
299
- $ imgPath = api_get_path (WEB_ARCHIVE_PATH ).$ chartHash ;
300
306
}
301
- echo '<img src=" ' . $ imgPath. '" > ' ;
307
+ echo '<img src="data:image/png;base64, ' . base64_encode ( file_get_contents ( $ imgPath)) . '" > ' ;
302
308
if (0 == $ i % 2 && 0 != $ i ) {
303
309
echo '<br /><br /> ' ;
304
310
} else {
0 commit comments