You are here

function resizeimage_wrapper_dbcache in Brilliant Gallery 5.4

Same name and namespace in other branches
  1. 5.3 image.php \resizeimage_wrapper_dbcache()
  2. 6.4 functions.inc \resizeimage_wrapper_dbcache()
  3. 6 image.php \resizeimage_wrapper_dbcache()
  4. 6.2 image.php \resizeimage_wrapper_dbcache()
  5. 6.3 image.php \resizeimage_wrapper_dbcache()
  6. 7.2 OLD_brilliant_gallery_functions.inc \resizeimage_wrapper_dbcache()
  7. 7 brilliant_gallery_functions.inc \resizeimage_wrapper_dbcache()
1 call to resizeimage_wrapper_dbcache()
image.php in ./image.php

File

./image.php, line 85

Code

function resizeimage_wrapper_dbcache($reset = FALSE) {
  global $bgcachexpire;
  global $user;

  #$userId = $user->uid;
  $bgcacheid = 'bg_' . md5($_GET['imgp'] . $_GET['imgw'] . $_GET['imgh']);

  #echo $bgcacheid;
  static $my_data;

  #echo '0.... ';
  if (!isset($my_data) || $reset) {
    if (!$reset && ($cache = cache_get($bgcacheid)) && !empty($cache->data)) {

      #$my_data = $cache->data; echo '-1.... ' . $my_data;
      $my_data = unserialize($cache->data);
    }
    else {

      // Do your expensive calculations here, and populate $my_data
      // with the correct stuff..
      $my_data = resizeimage($_GET['imgp'], $_GET['imgw'], $_GET['imgh']);

      #echo ' -2.... ' . $bgcachexpire . ' // ' . $my_data;

      # For some reason I could not use: mysql_escape_string($my_data)
      cache_set($bgcacheid, 'cache', $my_data, time() + $bgcachexpire);

      # FOR DRUPAL6 MUST USE:

      #cache_set($bgcacheid,  $my_data, 'cache',time() + $bgcachexpire); # For some reason I could not use: mysql_escape_string($my_data)
      $my_data = unserialize($my_data);
    }
  }
  return $my_data;
}