diff --git a/source/administrator/components/com_jedchecker/controller.php b/source/administrator/components/com_jedchecker/controller.php new file mode 100644 index 0000000..99512b4 --- /dev/null +++ b/source/administrator/components/com_jedchecker/controller.php @@ -0,0 +1,15 @@ +path = JPATH_COMPONENT_ADMINISTRATOR . '/tmp/'; + parent::__construct(); + } + + /** + * basic upload + * @return bool + */ + public function upload() { + $file = JRequest::getVar('extension', '', 'files', 'array'); + if($file['tmp_name']) { + $path = JPATH_COMPONENT_ADMINISTRATOR . '/tmp/'; + $filepath = $path . strtolower($file['name']); +// let us remove all previous uplaods + $folders = JFolder::folders($path); + foreach($folders as $folder) { + JFolder::delete($folder); + } + + $object_file = new JObject($file); + $object_file->filepath = $filepath; + $file = (array) $object_file; + +// let us try to upload + if (!JFile::upload($file['tmp_name'], $file['filepath'])) + { + // Error in upload + JError::raiseWarning(100, JText::_('COM_JEDCHECKER_ERROR_UNABLE_TO_UPLOAD_FILE')); + return false; + } + + return true; + } + + return false; + } + + /** + * unzip the file + * @return bool + */ + public function unzip() { + + $file = JFolder::files($this->path); + + $result = JArchive::extract($this->path.$file[0], $this->path); + + return $result; + } +} diff --git a/source/administrator/components/com_jedchecker/jedchecker.php b/source/administrator/components/com_jedchecker/jedchecker.php index aac684c..c8d8181 100644 --- a/source/administrator/components/com_jedchecker/jedchecker.php +++ b/source/administrator/components/com_jedchecker/jedchecker.php @@ -1,8 +1,15 @@ execute(JRequest::getCmd('task')); +$controller->redirect(); \ No newline at end of file diff --git a/source/administrator/components/com_jedchecker/views/uploads/tmpl/default.php b/source/administrator/components/com_jedchecker/views/uploads/tmpl/default.php new file mode 100644 index 0000000..3097c01 --- /dev/null +++ b/source/administrator/components/com_jedchecker/views/uploads/tmpl/default.php @@ -0,0 +1,26 @@ + +
\ No newline at end of file diff --git a/source/administrator/components/com_jedchecker/views/uploads/view.html.php b/source/administrator/components/com_jedchecker/views/uploads/view.html.php new file mode 100644 index 0000000..316bfc9 --- /dev/null +++ b/source/administrator/components/com_jedchecker/views/uploads/view.html.php @@ -0,0 +1,24 @@ +setToolbar(); + parent::display($tpl); + } + + public function setToolbar() { + JToolBarHelper::custom('uploads.unzip', 'unzip', 'unzip', 'unzip', false); + } +} \ No newline at end of file