mirror of
https://github.com/joomla-extensions/jedchecker.git
synced 2024-12-24 19:30:24 +00:00
adding basic upload and unzip functionality
This commit is contained in:
parent
05194c9e33
commit
7619fd09a9
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Daniel Dimitrov - compojoom.com
|
||||
* @date: 02.06.12
|
||||
*
|
||||
* @copyright Copyright (C) 2008 - 2012 compojoom.com . All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined( '_JEXEC' ) or die ( 'Restricted access' );
|
||||
|
||||
class jedcheckerController extends JController
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Daniel Dimitrov - compojoom.com
|
||||
* @date: 02.06.12
|
||||
*
|
||||
* @copyright Copyright (C) 2008 - 2012 compojoom.com . All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
jimport('joomla.filesystem');
|
||||
jimport('joomla.filesystem.archive');
|
||||
|
||||
class jedcheckerControllerUploads extends JController
|
||||
{
|
||||
public function __construct() {
|
||||
$this->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;
|
||||
}
|
||||
}
|
@ -1,8 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
* User: Dq
|
||||
* Date: 21/05/12
|
||||
* Time: 10:26
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
* @author Daniel Dimitrov - compojoom.com
|
||||
* @date: 02.06.12
|
||||
*
|
||||
* @copyright Copyright (C) 2008 - 2012 compojoom.com . All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
jimport('joomla.application.component.controller');
|
||||
|
||||
$controller = JController::getInstance('jedchecker');
|
||||
$controller->execute(JRequest::getCmd('task'));
|
||||
$controller->redirect();
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Daniel Dimitrov - compojoom.com
|
||||
* @date: 02.06.12
|
||||
*
|
||||
* @copyright Copyright (C) 2008 - 2012 compojoom.com . All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
JHTML::_('behavior.mootools', true);
|
||||
JHtml::_('behavior.formvalidation');
|
||||
JHtml::_('behavior.keepalive');
|
||||
|
||||
?>
|
||||
<form action="<?php echo JRoute::_('index.php?option=com_jedchecker&view=uploads'); ?>"
|
||||
method="post" class="form form-validate" name="adminForm" id="adminForm" enctype="multipart/form-data">
|
||||
|
||||
<input type="file" name="extension" class="required" />
|
||||
<button onclick="Joomla.submitbutton('uploads.upload')">
|
||||
submit
|
||||
</button>
|
||||
<input type="hidden" name="task" value="" />
|
||||
<?php echo JHTML::_('form.token'); ?>
|
||||
</form>
|
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Daniel Dimitrov - compojoom.com
|
||||
* @date: 02.06.12
|
||||
*
|
||||
* @copyright Copyright (C) 2008 - 2012 compojoom.com . All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
jimport('joomla.application.component.view');
|
||||
|
||||
class jedcheckerViewUploads extends JView {
|
||||
|
||||
public function display($tpl = null) {
|
||||
$this->setToolbar();
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
public function setToolbar() {
|
||||
JToolBarHelper::custom('uploads.unzip', 'unzip', 'unzip', 'unzip', false);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user