You are here

function hacked_reports_export_select in Hacked! 6

1 string reference to 'hacked_reports_export_select'
hacked_menu in ./hacked.module
Implementation of hook_menu().

File

./hacked.export.inc, line 4

Code

function hacked_reports_export_select() {
  global $user;

  // Lookup the clean hashes in the cache table and offer to export them:
  $rows = array();
  $header = array();
  $cache_results = db_query("SELECT cid, data, created, headers, expire, serialized FROM {" . HACKED_CACHE_TABLE . "} WHERE cid LIKE '%s%%'", 'hacked:clean:hashes:');
  while ($cache = db_fetch_object($cache_results)) {
    if (isset($cache->data)) {

      // If the data is permanent or we're not enforcing a minimum cache lifetime
      // always return the cached data.
      if ($cache->expire == CACHE_PERMANENT || !variable_get('cache_lifetime', 0)) {
        $cache->data = db_decode_blob($cache->data);
        if ($cache->serialized) {
          $cache->data = unserialize($cache->data);
        }
      }
      else {
        if ($user->cache > $cache->created) {

          // This cache data is too old and thus not valid for us, ignore it.
          continue;
        }
        else {
          $cache->data = db_decode_blob($cache->data);
          if ($cache->serialized) {
            $cache->data = unserialize($cache->data);
          }
        }
      }

      // Process the row:
      $key_split = explode(':', $cache->cid);
      if (count($key_split) == 6) {
        $row = array();
        $row[] = t('!type - !name - !version', array(
          '!type' => $key_split[3],
          '!name' => $key_split[4],
          '!version' => $key_split[5],
        ));
        $row[] = l(t('Export'), 'admin/reports/hacked-export/' . $cache->cid);
        $rows[] = $row;
      }
    }
  }
  return theme('table', $header, $rows);
}