public function delete($id = FALSE) { $recycle = $this->recycles->find($id); $destroy = unserialize($recycle->data); switch ($recycle->type) { case 'file': $get = folder::get(WEBROOT . $this->config->item('public_folder')); $keys = array_keys($get['filename'], $destroy->file); if (count($keys) > 0) { foreach ($keys as $key) { $the_file = $get['fullpath'][$key]; if (file_exists($the_file)) { unlink($the_file); $destroyed = $destroy->name; } } } else { $destroyed = $destroy->name; } break; default: $destroyed = $destroy->name; break; } if ($destroyed) { if ($this->recycles->delete($recycle->id)) { $this->session->set_flashdata('success', 'You have successfully deleted "' . $recycle->name . '" permanently.'); redirect('admin/recycle'); } } }