View source
<?php
function hacked_reports_export_select() {
global $user;
$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 ($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) {
continue;
}
else {
$cache->data = db_decode_blob($cache->data);
if ($cache->serialized) {
$cache->data = unserialize($cache->data);
}
}
}
$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);
}
function hacked_reports_exports_export_form($form_state, $cid) {
$form = array();
$cache = cache_get($cid, HACKED_CACHE_TABLE);
if (!$cache->data) {
return drupal_not_found();
}
$export = var_export($cache->data, TRUE);
$export = '$hashes = ' . $export;
$export .= ';';
$form['export'] = array(
'#type' => 'textarea',
'#default_value' => $export,
'#rows' => count(explode("\n", $export)),
);
return $form;
}