function restore_forms() { $mainframe =& JFactory::getApplication(); $database =& JFactory::getDBO(); jimport('joomla.utilities.error'); jimport('joomla.filesystem.file'); $files = $_FILES; if (is_array($files) && !empty($files)) { //the file has been uploaded $file = $files['file']; $filename = $file['name']; $exten = explode(".", $filename); if ($exten[count($exten) - 1] == 'cf4bak') { $path = JPATH_BASE . DS . 'cache'; $uploadedfile = JFile::upload($file['tmp_name'], $path . DS . $filename); if (!$uploadedfile) { JError::raiseWarning(100, "UPLAOD FAILED" . ": " . $file['error']); $mainframe->redirect("index.php?option=com_chronoforms"); } else { ChronoFormsAdmin::restore_forms_from_file($path . DS . $filename); $mainframe->redirect("index.php?option=com_chronoforms", "Forms restored successfully."); } } else { //wrong file extension JError::raiseWarning(100, "The file uploaded was not a Chronoforms V4 forms backup file."); $mainframe->redirect("index.php?option=com_chronoforms"); } } else { //no file, render the upload page HTML_Admin_ChronoForms::restore_forms(); } }