33
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2024-12-25 19:41:05 +00:00

use the tmp path configured in the joomla config

This commit is contained in:
Daniel Dimitrov 2012-06-09 14:51:17 +02:00
parent f4011c1675
commit c9608e6fea
3 changed files with 39 additions and 20 deletions

View File

@ -17,11 +17,11 @@ jimport('joomla.filesystem.archive');
class jedcheckerControllerPolice extends JController { class jedcheckerControllerPolice extends JController {
public function check() { public function check() {
require_once JPATH_COMPONENT_ADMINISTRATOR . '/libraries/rules/htmlindexes.php'; require_once JPATH_COMPONENT_ADMINISTRATOR . '/libraries/rules/htmlindexes.php';
$path = JPATH_COMPONENT_ADMINISTRATOR . '/tmp/unzipped/'; $path = JFactory::getConfig()->get('tmp_path') . '/jed_checker/unzipped';
$police = new jedcheckerRulesHtmlindexes; $police = new jedcheckerRulesHtmlindexes;
$folders = JFolder::folders($path); $folders = JFolder::folders($path);
$police->check($path.$folders[0]); $police->check($path.'/'.$folders[0]);
} }
} }

View File

@ -16,9 +16,9 @@ class jedcheckerControllerUploads extends JController
{ {
public function __construct() public function __construct()
{ {
$this->path = JPATH_COMPONENT_ADMINISTRATOR . '/tmp/'; $this->path = JFactory::getConfig()->get('tmp_path') . '/jed_checker';
$this->pathArchive = $this->path . 'arhives/'; $this->pathArchive = $this->path . '/arhives';
$this->pathUnzipped = $this->path . 'unzipped/'; $this->pathUnzipped = $this->path . '/unzipped';
parent::__construct(); parent::__construct();
} }
@ -28,18 +28,25 @@ class jedcheckerControllerUploads extends JController
*/ */
public function upload() public function upload()
{ {
$appl = JFactory::getApplication();
$file = JRequest::getVar('extension', '', 'files', 'array'); $file = JRequest::getVar('extension', '', 'files', 'array');
if ($file['tmp_name']) { if ($file['tmp_name']) {
$path = $this->pathArchive; $path = $this->pathArchive;
$filepath = $path . strtolower($file['name']); // if the archive folder doesn't exist - create it!
// let us remove all previous uploads if(!JFolder::exists($path)) {
$archiveFiles = JFolder::files($path); JFolder::create($path);
} else {
// let us remove all previous uploads
$archiveFiles = JFolder::files($path);
foreach ($archiveFiles as $archive) { foreach ($archiveFiles as $archive) {
if (!JFile::delete($this->pathArchive . $archive)) { if (!JFile::delete($this->pathArchive . '/'.$archive)) {
echo 'could not delete' . $archive; echo 'could not delete' . $archive;
}
} }
} }
$filepath = $path .'/'. strtolower($file['name']);
$object_file = new JObject($file); $object_file = new JObject($file);
$object_file->filepath = $filepath; $object_file->filepath = $filepath;
@ -51,7 +58,7 @@ class jedcheckerControllerUploads extends JController
JError::raiseWarning(100, JText::_('COM_JEDCHECKER_ERROR_UNABLE_TO_UPLOAD_FILE')); JError::raiseWarning(100, JText::_('COM_JEDCHECKER_ERROR_UNABLE_TO_UPLOAD_FILE'));
return false; return false;
} }
$appl->redirect('index.php?option=com_jedchecker&view=uploads', JText::_('COM_JEDCHECKER_UPLOAD_WAS_SUCCESSFUL'));
return true; return true;
} }
@ -64,22 +71,31 @@ class jedcheckerControllerUploads extends JController
*/ */
public function unzip() public function unzip()
{ {
$appl = JFactory::getApplication();
// let us remove all previous unzipped files // if folder doesn't exist - create it!
$folders = JFolder::folders($this->pathUnzipped); if(!JFolder::exists($this->pathUnzipped)) {
foreach ($folders as $folder) { JFolder::create($this->pathUnzipped);
JFolder::delete($this->pathUnzipped . $folder); } else {
// let us remove all previous unzipped files
$folders = JFolder::folders($this->pathUnzipped);
foreach ($folders as $folder) {
JFolder::delete($this->pathUnzipped .'/'. $folder);
}
} }
$file = JFolder::files($this->pathArchive); $file = JFolder::files($this->pathArchive);
$result = JArchive::extract($this->pathArchive . $file[0], $this->pathUnzipped . $file[0]); $result = JArchive::extract($this->pathArchive .'/'. $file[0], $this->pathUnzipped .'/'. $file[0]);
if ($result) { if ($result) {
// scan unzipped folders if we find zip file -> unzip them as well // scan unzipped folders if we find zip file -> unzip them as well
$this->unzipAll($this->pathUnzipped . $file[0]); $this->unzipAll($this->pathUnzipped .'/'. $file[0]);
$message = 'COM_JEDCHECKER_UNZIP_SUCCESS';
} else {
$message = 'COM_JEDCHECKER_UNZIP_FAILED';
} }
$appl->redirect('index.php?option=com_jedchecker&view=uploads', JText::_($message));
return $result; return $result;
} }

View File

@ -1 +1,4 @@
; Language files have to start with semicolon (;) otherwise we have problems with transifex ; Language files have to start with semicolon (;) otherwise we have problems with transifex
COM_JEDCHECKER_UPLOAD_WAS_SUCCESSFUL="Upload was successful"
COM_JEDCHECKER_UNZIP_SUCCESS="Unzip was successful! Now go ahead and click that check button!"
COM_JEDCHECKER_UNZIP_FAILED="Unzip failed";