Ejemplo n.º 1
0
 private function setGalleryPath($galleryPath)
 {
     // TODO handle if absolute path is used as input
     $this->relativeGalleryPath = JFolder::makeSafe($galleryPath);
     // TODO safe enough?
     $this->galleryPath = JPATH_BASE . DS . $this->relativeGalleryPath;
 }
Ejemplo n.º 2
0
 public function get()
 {
     $app = JFactory::getApplication();
     jimport('joomla.filesystem.folder');
     JPluginHelper::importPlugin('api');
     $result = $app->triggerEvent('register_api_plugin');
     $plugins = array();
     foreach ($result as $plugin) {
         if (!isset($plugin->title) || !isset($plugin->plugin)) {
             continue;
         }
         $path = JFolder::makeSafe(JPATH_ROOT . "/plugins/api/{$plugin->plugin}/html");
         if (!JFolder::exists($path)) {
             continue;
         }
         $files = JFolder::files($path, '.', true, true);
         // Remove absolute path
         foreach ($files as &$file) {
             $file = str_replace(JPATH_ROOT . '/', '', $file);
         }
         $plugins[$plugin->plugin] = array('title' => $plugin->title, 'type' => $plugin->plugin, 'version' => $plugin->version, 'files' => $files);
     }
     ksort($plugins);
     $this->plugin->setResponse($plugins);
 }
Ejemplo n.º 3
0
 function save($data)
 {
     $row =& JTable::getInstance('categories', 'Table');
     $id = $data['id'];
     if (!$row->bind($data)) {
         JError::raiseError(500, $row->getError());
         return false;
     }
     if (!$row->check()) {
         JError::raiseError(500, $row->getError());
     }
     if (!$row->store()) {
         JError::raiseError(500, $row->getError());
         return false;
     }
     if (!$id) {
         $row->load($row->{$id});
         jimport('joomla.filesystem.file');
         $baseFolder = JPATH_SITE . DS . 'codefile';
         $baseFolder = JFolder::makeSafe($path);
         if (!JFolder::exists($baseFolder)) {
             JFolder::create($baseFolder);
             echo "<br>" . $baseFolder;
         }
         $codeFolder = JPATH_SITE . DS . 'codefile' . DS . 'category_' . $row->id;
         echo "<br>" . $codeFolder;
         JFolder::create($codeFolder);
     } else {
         echo "The old row" . $id;
     }
     return true;
 }
Ejemplo n.º 4
0
 function __construct($name, $type)
 {
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     $this->_name = JFolder::makeSafe($name);
     $this->_type = JFolder::makeSafe($type);
     $model =& JModel::getInstance('Configuration', 'JDefenderModel');
     $this->_params = new JParameter($model->getIni());
     $this->_rules =& JD_Rule_Manager::getRules($name);
 }
Ejemplo n.º 5
0
 public static function splitPath($path, $makeRelative = true)
 {
     if ($makeRelative) {
         $path = GalleryHelper::makeRelative($path);
     }
     $parts = explode('/', $path);
     $object = new ArrayObject();
     $object->filename = JFile::makeSafe(array_pop($parts));
     // last element is filename
     $object->folderPath = JFolder::makeSafe(implode(DS, $parts));
     // use rest as path
     return $object;
 }
Ejemplo n.º 6
0
 /**
  * Load the handlers :)
  * @static
  * @return void
  */
 function loadHandlers($type)
 {
     static $loaded = array();
     if (!empty($loaded[$type])) {
         return;
     }
     $type = JFolder::makeSafe($type);
     $basePath = JPATH_COMPONENT_ADMINISTRATOR . DS . 'lib' . DS . 'handlers' . DS . $type;
     $files = JFolder::files($basePath, 'jd_.+handler\\.php', false, false);
     foreach ($files as $file) {
         $path = $basePath . DS . $file;
         if (JFile::exists($path)) {
             require_once $path;
         }
     }
     $loaded[$type] = true;
 }
Ejemplo n.º 7
0
 function display($tpl = null)
 {
     // params
     $params = JFactory::getApplication()->getParams();
     $galleryPath = $params->get('gallery_path');
     // TODO not safe
     // validate
     $folderPath = JFolder::makeSafe(JRequest::getString('path'));
     $filename = JFile::makeSafe(JRequest::getString('filename'));
     // ---
     $folder = new Folder($galleryPath, $folderPath);
     $photo = new Photo($folder, $filename);
     // add css
     $document =& JFactory::getDocument();
     $document->addStyleSheet('media/com_gallery/css/gallery.style.css');
     // assign Variables
     $this->assignRef('photo', $photo);
     parent::display($tpl);
 }
Ejemplo n.º 8
0
 public function getFiles($fullPath, $path)
 {
     $path = JFolder::makeSafe($path);
     $data = array();
     $extensions = $this->_config->get('file_types');
     if (!$extensions) {
         $extensions = 'jpeg,gif,png,jpg';
     }
     $arrayExtension = explode(',', $extensions);
     $results = JFolder::files($fullPath, '.', false, false);
     foreach ($results as $result) {
         //get file's extension
         $extension = JFile::getExt($result);
         if (in_array($extension, $arrayExtension) && JFile::exists($fullPath . '/' . $result)) {
             array_push($data, array('filename' => basename($result), 'type' => 'file', 'url' => preg_replace('!/+!', '/', JSNES_IMAGES_URL . $path . '/' . basename($result))));
         }
     }
     return $data;
 }
Ejemplo n.º 9
0
 /**
  * @static
  * @param unknown_type $type
  * @return JD_Action instance :0
  */
 function &getInstance($type = null)
 {
     static $instances = array();
     if (empty($type)) {
         return $instances;
     }
     $type = JFolder::makeSafe($type);
     if (empty($instances[$type])) {
         JD_Action::_loadActions();
         $className = 'JD_' . $type . '_Action';
         if (class_exists($className)) {
             $instances[$type] = new $className();
         } else {
             JError::raiseWarning(0, JText::_('Cannot instanciate action class') . ': ' . 'jd_' . $type . '_action');
             return null;
         }
     }
     return $instances[$type];
 }
Ejemplo n.º 10
0
 public function execute()
 {
     $this->out('Hello. What do you want to build today:' . "\n" . '1 - Component; 2 - Plugin; 3 - Module');
     $choice = $this->in();
     switch ($choice) {
         case 1:
         case 2:
             $this->out('Sorry but we can offer you only Modules :)');
             break;
         case 3:
         default:
             $this->type = 'module';
     }
     $this->out('Please enter an extension name in lower case e.g. "testmodule"');
     $extName = JFolder::makeSafe($this->in());
     $this->out('Do you want to install the extension on completion?');
     $this->out("1 - Yes\n2 - No\n");
     $install = $this->in();
     $extInstall = $install == 1 ? true : false;
     $manifestPath = 'scaffold/module/';
     $this->builder = new JBuilder($extName, 'module', $extInstall);
     $this->builder->build();
 }
Ejemplo n.º 11
0
 public function saveDocumentVersions($dataInput, $table, $fieldsData, $isNew, $newMainCatId, $tableBeforeSave = null)
 {
     $versions = $dataInput['versions'];
     $docId = $table->id;
     $app = JFactory::getApplication();
     $params = JUDownloadHelper::getParams($newMainCatId);
     $db = JFactory::getDbo();
     $file_directory = JPATH_ROOT . "/" . JUDownloadFrontHelper::getDirectory("file_directory", "media/com_judownload/files/");
     $file_directory_tmp = $file_directory . "tmp/";
     if (!is_writable($file_directory_tmp)) {
         $file_directory_tmp = sys_get_temp_dir() . "/plupload/";
     }
     if (JUDLPROVERSION && !$isNew && $params->get('store_old_file_versions', 1)) {
         $versionField = new JUDownloadFieldCore_version();
         if (version_compare($tableBeforeSave->version, $fieldsData[$versionField->id]) != 0) {
             $query = "SELECT * FROM #__judownload_files WHERE doc_id = " . $docId;
             $db->setQuery($query);
             $fileObjectList = $db->loadObjectList();
             foreach ($fileObjectList as $fileObj) {
                 $query = $db->getQuery(true);
                 $query->select('*')->from('#__judownload_versions')->where('file_id = ' . $fileObj->id)->where('date < ' . $db->quote($table->updated))->where('file_path != ""')->order('date DESC, version DESC');
                 $db->setQuery($query, 0, 1);
                 $nearestVersion = $db->loadObject();
                 $storeFile = false;
                 if (!$nearestVersion) {
                     $storeFile = true;
                 } else {
                     $currentVersionFile = $file_directory . $docId . '/' . $fileObj->file_name;
                     $nearestVersionFile = $file_directory . $docId . '/' . $nearestVersion->file_path;
                     if (hash_file('md5', $currentVersionFile) != hash_file('md5', $nearestVersionFile)) {
                         $storeFile = true;
                     }
                 }
                 if ($storeFile) {
                     $versionFolder = JFolder::makeSafe($table->version);
                     if (!$versionFolder) {
                         $versionFolder = 'versions';
                     }
                     if (!JFolder::exists($file_directory . $docId . "/" . $versionFolder . "/")) {
                         $file_index = $file_directory . $docId . "/" . $versionFolder . "/index.html";
                         $buffer = "<!DOCTYPE html><title></title>";
                         JFile::write($file_index, $buffer);
                     }
                     $src = $file_directory . $docId . "/" . $fileObj->file_name;
                     $fileName = $fileObj->file_name;
                     $dest = $file_directory . $docId . "/" . $versionFolder . "/" . $fileName;
                     while (JFile::exists($dest)) {
                         $fileName = md5($fileObj->file_name . JUDownloadHelper::generateRandomString(10)) . "." . JFile::getExt($fileObj->file_name);
                         $dest = $file_directory . $docId . "/" . $versionFolder . "/" . $fileName;
                     }
                     JFile::copy($src, $dest);
                     $versionTable = JTable::getInstance("Version", "JUDownloadTable");
                     $version_downloads_check_arr = array('doc_id' => $docId, 'file_id' => $fileObj->id, 'version' => $table->version);
                     if ($versionTable->load($version_downloads_check_arr)) {
                         $versionTable->date = intval($table->updated) ? $table->updated : $table->created;
                         $versionTable->size = $fileObj->size;
                         $versionTable->md5_checksum = $fileObj->md5_checksum;
                         $versionTable->crc32_checksum = $fileObj->crc32_checksum;
                         $versionTable->file_path = $versionFolder . "/" . $fileName;
                         $versionTable->store();
                     } else {
                         $versionTable->bind($version_downloads_check_arr);
                         $versionTable->id = 0;
                         $versionTable->date = intval($table->updated) ? $table->updated : $table->created;
                         $versionTable->size = $fileObj->size;
                         $versionTable->md5_checksum = $fileObj->md5_checksum;
                         $versionTable->crc32_checksum = $fileObj->crc32_checksum;
                         $versionTable->file_path = $versionFolder . "/" . $fileName;
                         $versionTable->store();
                     }
                 }
             }
         }
     }
     if (JUDLPROVERSION && $app->isAdmin()) {
         $versionTable = JTable::getInstance("Version", "JUDownloadTable");
         foreach ($versions as $versionKey => $version) {
             if ($versionTable->load($versionKey)) {
                 if ($version['remove']) {
                     $srcFile = $file_directory . $versionTable->doc_id . '/' . $versionTable->file_path;
                     JFile::delete($srcFile);
                     $versionTable->delete();
                     if ($version['replace']) {
                         $filePath = $file_directory_tmp . $version['replace'];
                         if (JFile::exists($filePath)) {
                             JFile::delete($filePath);
                         }
                     }
                 } elseif ($version['replace']) {
                     $oldFile = $file_directory . $versionTable->doc_id . '/' . $versionTable->file_path;
                     JFile::delete($oldFile);
                     $versionFolder = JFolder::makeSafe($versionTable->version);
                     if (!$versionFolder) {
                         $versionFolder = 'versions';
                     }
                     if (!JFolder::exists($file_directory . $versionTable->doc_id . "/" . $versionFolder . "/")) {
                         $file_index = $file_directory . $versionTable->doc_id . "/" . $versionFolder . "/index.html";
                         $buffer = "<!DOCTYPE html><title></title>";
                         JFile::write($file_index, $buffer);
                     }
                     $tmpFilePath = $file_directory_tmp . $version['replace'];
                     $versionTable->size = filesize($tmpFilePath);
                     if ($params->get('auto_generate_md5_checksum', 2) == 2 && $versionTable->size <= $params->get("max_filesize_auto_generate_checksum", 100) * 1024 * 1024 || $params->get('auto_generate_md5_checksum', 2) == 1) {
                         $versionTable->md5_checksum = hash_file('md5', $tmpFilePath);
                     }
                     if ($params->get('auto_generate_crc32_checksum', 2) == 2 && $versionTable->size <= $params->get("max_filesize_auto_generate_checksum", 100) * 1024 * 1024 || $params->get('auto_generate_crc32_checksum', 2) == 1) {
                         $versionTable->crc32_checksum = hash_file('crc32b', $tmpFilePath);
                     }
                     do {
                         $version['replace'] = md5($version['replace'] . JUDownloadHelper::generateRandomString(10)) . "." . JFile::getExt($version['replace']);
                         $newFilePath = $versionFolder . "/" . $version['replace'];
                         $dest = $file_directory . $versionTable->doc_id . "/" . $newFilePath;
                     } while (JFile::exists($dest));
                     $versionTable->file_path = $newFilePath;
                     $versionTable->store();
                     JFile::move($tmpFilePath, $dest);
                 }
             }
         }
     }
 }
Ejemplo n.º 12
0
 /**
  * Helper wrapper method for makeSafe
  *
  * @param   string  $path  The full path to sanitise.
  *
  * @return  string  The sanitised string
  *
  * @see     JFolder::makeSafe()
  * @since   3.4
  */
 public function makeSafe($path)
 {
     return JFolder::makeSafe($path);
 }
Ejemplo n.º 13
0
 function fileupdload($id)
 {
     if (!$_FILES['cfile']['size'] || $_FILES['cfile']['size'] > 6000000) {
         return false;
     } else {
         $permitted = array('application/zip', 'application/x-rar-compressed');
         $typeOK = false;
         foreach ($permitted as $type) {
             if ($type == $_FILES['cfile']['type']) {
                 $typeOK = true;
                 break;
             }
         }
         if ($typeOK) {
             $cate = 'category_' . JRequest::getVar('category');
             jimport('joomla.filesystem.folder');
             $folder = JPATH_SITE . DS . 'codefile';
             $folder = JFolder::makeSafe($folder);
             if (!JFolder::exists($folder)) {
                 JFolder::create($folder);
             }
             $folder = JPATH_SITE . DS . 'codefile' . DS . $cate;
             $folder = JFolder::makeSafe($folder);
             if (!JFolder::exists($folder)) {
                 JFolder::create($folder);
             }
             $name = $_FILES['cfile']['name'];
             $filename = 'devzone_' . $id . '_' . $name;
             $newname = JPATH_SITE . DS . 'codefile' . DS . $cate . DS . $filename;
             if (!move_uploaded_file($_FILES['cfile']['tmp_name'], $newname)) {
                 return false;
             } else {
                 if ($this->filenameupdate($id, $filename)) {
                     return false;
                 } else {
                     return true;
                 }
             }
         } else {
             return false;
         }
     }
 }
Ejemplo n.º 14
0
	/**
	 * Tests the JFolder::makeSafe method.
	 *
	 * @return  void
	 *
	 * @since   12.1
	 *
	 * @covers  JFolder::makeSafe
	 */
	public function testMakeSafe()
	{
		$actual = JFolder::makeSafe('test1/testdirectory');
		$this->assertEquals('test1/testdirectory', $actual);
	}
Ejemplo n.º 15
0
 protected function createZipArchive($archiveName = '', $filesPath = '', $files = array())
 {
     $archiveName = JPATH_TMP . $this->extPrefix . $this->extName . '.zip';
     JFolder::makeSafe($archiveName);
     if (JFile::exists($archiveName)) {
         return false;
     }
     $zipAdapter =& JArchive::getAdapter('zip');
     $result = $zipAdapter->create($archiveName, $this->filesArray);
     return $result;
 }
Ejemplo n.º 16
0
 /**
  * Create a new folder
  */
 public function newFolder()
 {
     if (!$this->checkACL('core.create')) {
         throw new \RuntimeException(\JText::_('JERROR_ALERTNOAUTHOR'), 403);
     }
     $this->csrfProtection();
     $categoryId = $this->input->getInt('id', 0);
     $folder = $this->input->getString('folder', '');
     $file = $this->input->getString('file', '');
     /** @var \Akeeba\ReleaseSystem\Admin\Model\Upload $model */
     $model = $this->getModel();
     $model->setState('category', (int) $categoryId);
     $model->setState('folder', $folder);
     $model->setState('file', $file);
     $parent = $model->getCategoryFolder();
     $potentialPrefix = substr($parent, 0, 5);
     $potentialPrefix = strtolower($potentialPrefix);
     $useS3 = $potentialPrefix == 's3://';
     if ($useS3) {
         $trimmedParent = $parent;
         if (substr($parent, 0, 5) == 's3://') {
             $trimmedParent = substr($parent, 5);
         }
         $newFolder = $trimmedParent . '/' . $file;
         $newFolder = trim($newFolder, '/') . '/';
         $s3 = AmazonS3::getInstance();
         $status = $s3->putObject('$folder$', $newFolder, true);
     } else {
         \JLoader::import('joomla.filesystem.folder');
         $newFolder = $parent . '/' . \JFolder::makeSafe($file);
         $status = \JFolder::create($newFolder);
     }
     $url = 'index.php?option=com_ars&view=upload&task=category&id=' . (int) $categoryId . '&folder=' . urlencode($this->input->getString('folder')) . '&' . \JFactory::getSession()->getFormToken(true) . '=1';
     if ($status) {
         $this->setRedirect($url, \JText::_('MSG_FOLDER_CREATED'));
         return;
     }
     $this->setRedirect($url, JText::_('MSG_FOLDER_NOT_CREATED'), 'error');
 }
Ejemplo n.º 17
0
 /**
  * Method to run after an install/update/uninstall method.
  *
  * @param string $type
  * @param string $parent
  *
  * @return void
  */
 public function postflight($type, $parent)
 {
     if (!defined('SOCIALCOMMUNITY_PATH_COMPONENT_ADMINISTRATOR')) {
         define('SOCIALCOMMUNITY_PATH_COMPONENT_ADMINISTRATOR', JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_socialcommunity');
     }
     // Register Install Helper
     JLoader::register('SocialCommunityInstallHelper', SOCIALCOMMUNITY_PATH_COMPONENT_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'install.php');
     jimport('Prism.init');
     jimport('Socialcommunity.init');
     $params = JComponentHelper::getParams('com_socialcommunity');
     /** @var  $params Joomla\Registry\Registry */
     $mediaFolder = JFolder::makeSafe($params->get('local_media_folder', 'media/socialcommunity'));
     $mediaFolderPath = JPath::clean(JPATH_SITE . DIRECTORY_SEPARATOR . $mediaFolder);
     $temporaryMediaFolder = $mediaFolder . '/temporary';
     $temporaryMediaFolderPath = JPath::clean(JPATH_SITE . DIRECTORY_SEPARATOR . $temporaryMediaFolder);
     // Create images folder
     if (!JFolder::exists($mediaFolderPath)) {
         SocialCommunityInstallHelper::createFolder($mediaFolderPath);
     }
     // Create temporary images folder
     if (!JFolder::exists($temporaryMediaFolderPath)) {
         SocialCommunityInstallHelper::createFolder($temporaryMediaFolderPath);
     }
     // Start table with the information
     SocialCommunityInstallHelper::startTable();
     // Requirements
     SocialCommunityInstallHelper::addRowHeading(JText::_('COM_SOCIALCOMMUNITY_MINIMUM_REQUIREMENTS'));
     // Display result about verification for existing folder
     $title = JText::_('COM_SOCIALCOMMUNITY_IMAGE_FOLDER');
     $info = $mediaFolder;
     if (!JFolder::exists($mediaFolderPath)) {
         $result = array('type' => 'important', 'text' => JText::_('JNO'));
     } else {
         $result = array('type' => 'success', 'text' => JText::_('JYES'));
     }
     SocialCommunityInstallHelper::addRow($title, $result, $info);
     // Display result about verification for writable folder
     $title = JText::_('COM_SOCIALCOMMUNITY_WRITABLE_FOLDER');
     $info = $mediaFolder;
     if (!is_writable($mediaFolderPath)) {
         $result = array('type' => 'important', 'text' => JText::_('JNO'));
     } else {
         $result = array('type' => 'success', 'text' => JText::_('JYES'));
     }
     SocialCommunityInstallHelper::addRow($title, $result, $info);
     // Display result about verification for existing folder
     $title = JText::_('COM_SOCIALCOMMUNITY_TEMPORARY_IMAGE_FOLDER');
     $info = $temporaryMediaFolder;
     if (!JFolder::exists($temporaryMediaFolderPath)) {
         $result = array('type' => 'important', 'text' => JText::_('JNO'));
     } else {
         $result = array('type' => 'success', 'text' => JText::_('JYES'));
     }
     SocialCommunityInstallHelper::addRow($title, $result, $info);
     // Display result about verification for writable folder
     $title = JText::_('COM_SOCIALCOMMUNITY_TEMPORARY_WRITABLE_FOLDER');
     $info = $temporaryMediaFolder;
     if (!is_writable($temporaryMediaFolderPath)) {
         $result = array('type' => 'important', 'text' => JText::_('JNO'));
     } else {
         $result = array('type' => 'success', 'text' => JText::_('JYES'));
     }
     SocialCommunityInstallHelper::addRow($title, $result, $info);
     // Display result about verification for GD library
     $title = JText::_('COM_SOCIALCOMMUNITY_GD_LIBRARY');
     $info = '';
     if (!extension_loaded('gd') and function_exists('gd_info')) {
         $result = array('type' => 'important', 'text' => JText::_('COM_SOCIALCOMMUNITY_WARNING'));
     } else {
         $result = array('type' => 'success', 'text' => JText::_('JON'));
     }
     SocialCommunityInstallHelper::addRow($title, $result, $info);
     // Display result about verification for cURL library
     $title = JText::_('COM_SOCIALCOMMUNITY_CURL_LIBRARY');
     $info = '';
     if (!extension_loaded('curl')) {
         $info = JText::_('COM_SOCIALCOMMUNITY_CURL_INFO');
         $result = array('type' => 'important', 'text' => JText::_('COM_SOCIALCOMMUNITY_WARNING'));
     } else {
         $result = array('type' => 'success', 'text' => JText::_('JON'));
     }
     SocialCommunityInstallHelper::addRow($title, $result, $info);
     // Display result about verification Magic Quotes
     $title = JText::_('COM_SOCIALCOMMUNITY_MAGIC_QUOTES');
     $info = '';
     if (get_magic_quotes_gpc()) {
         $info = JText::_('COM_SOCIALCOMMUNITY_MAGIC_QUOTES_INFO');
         $result = array('type' => 'important', 'text' => JText::_('JON'));
     } else {
         $result = array('type' => 'success', 'text' => JText::_('JOFF'));
     }
     SocialCommunityInstallHelper::addRow($title, $result, $info);
     // Display result about verification FileInfo
     $title = JText::_('COM_SOCIALCOMMUNITY_FILEINFO');
     $info = '';
     if (!function_exists('finfo_open')) {
         $info = JText::_('COM_SOCIALCOMMUNITY_FILEINFO_INFO');
         $result = array('type' => 'important', 'text' => JText::_('JOFF'));
     } else {
         $result = array('type' => 'success', 'text' => JText::_('JON'));
     }
     SocialCommunityInstallHelper::addRow($title, $result, $info);
     // Display result about verification PHP Version.
     $title = JText::_('COM_SOCIALCOMMUNITY_PHP_VERSION');
     $info = '';
     if (version_compare(PHP_VERSION, '5.4.0', '<')) {
         $result = array('type' => 'important', 'text' => JText::_('COM_SOCIALCOMMUNITY_WARNING'));
     } else {
         $result = array('type' => 'success', 'text' => JText::_('JYES'));
     }
     SocialCommunityInstallHelper::addRow($title, $result, $info);
     // Display result about MySQL Version.
     $title = JText::_('COM_SOCIALCOMMUNITY_MYSQL_VERSION');
     $info = '';
     $dbVersion = JFactory::getDbo()->getVersion();
     if (version_compare($dbVersion, '5.5.3', '<')) {
         $result = array('type' => 'important', 'text' => JText::_('COM_SOCIALCOMMUNITY_WARNING'));
     } else {
         $result = array('type' => 'success', 'text' => JText::_('JYES'));
     }
     SocialCommunityInstallHelper::addRow($title, $result, $info);
     // Display result about verification of installed Prism Library
     $title = JText::_('COM_SOCIALCOMMUNITY_PRISM_LIBRARY');
     $info = '';
     if (!class_exists('Prism\\Version')) {
         $info = JText::_('COM_SOCIALCOMMUNITY_PRISM_LIBRARY_DOWNLOAD');
         $result = array('type' => 'important', 'text' => JText::_('JNO'));
     } else {
         $result = array('type' => 'success', 'text' => JText::_('JYES'));
     }
     SocialCommunityInstallHelper::addRow($title, $result, $info);
     // Installed extensions
     SocialCommunityInstallHelper::addRowHeading(JText::_('COM_SOCIALCOMMUNITY_INSTALLED_EXTENSIONS'));
     // SocialCommunity Library
     $result = array('type' => 'success', 'text' => JText::_('COM_SOCIALCOMMUNITY_INSTALLED'));
     SocialCommunityInstallHelper::addRow(JText::_('COM_SOCIALCOMMUNITY_SOCIALCOMMUNITY_LIBRARY'), $result, JText::_('COM_SOCIALCOMMUNITY_LIBRARY'));
     // User - Social Community New User
     $result = array('type' => 'success', 'text' => JText::_('COM_SOCIALCOMMUNITY_INSTALLED'));
     SocialCommunityInstallHelper::addRow(JText::_('COM_SOCIALCOMMUNITY_USER_SOCIALCOMMUNITY_USER'), $result, JText::_('COM_SOCIALCOMMUNITY_PLUGIN'));
     // End table with the information
     SocialCommunityInstallHelper::endTable();
     echo JText::sprintf('COM_SOCIALCOMMUNITY_MESSAGE_REVIEW_SAVE_SETTINGS', JRoute::_('index.php?option=com_socialcommunity'));
     if (!class_exists('Prism\\Version')) {
         echo JText::_('COM_SOCIALCOMMUNITY_MESSAGE_INSTALL_PRISM_LIBRARY');
     } else {
         if (class_exists('Socialcommunity\\Version')) {
             $prismVersion = new Prism\Version();
             $componentVersion = new Socialcommunity\Version();
             if (version_compare($prismVersion->getShortVersion(), $componentVersion->requiredPrismVersion, '<')) {
                 echo JText::_('COM_SOCIALCOMMUNITY_MESSAGE_INSTALL_PRISM_LIBRARY');
             }
         }
     }
     // Create profiles if orphans exist.
     SocialCommunityHelper::createProfiles();
 }
Ejemplo n.º 18
0
 function _processSmartBlog($migrateComment, $migrateImage, $imagePath)
 {
     $db = EasyBlogHelper::db();
     $jSession = JFactory::getSession();
     $ejax = new EJax();
     //check if com_blog installed.
     if (!JFile::exists(JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_blog' . DIRECTORY_SEPARATOR . 'blog.php')) {
         $ejax->append('progress-status2', JText::_('COM_EASYBLOG_MIGRATOR_SMARTBLOG_ERROR'));
         $ejax->script("\$( '#migrator-submit2' ).html('" . JText::_('COM_EASYBLOG_MIGRATOR_ABORTED') . "');");
         $ejax->script("\$( '#migrator-submit2' ).attr('disabled' , '');");
         $ejax->script("\$( '#icon-wait2' ).css( 'display' , 'none' );");
         $ejax->send();
         exit;
     }
     $migrateStat = $jSession->get('EBLOG_MIGRATOR_JOOMLA_STAT', '', 'EASYBLOG');
     if (empty($migrateStat)) {
         $migrateStat = new stdClass();
         $migrateStat->blog = 0;
         $migrateStat->category = 0;
         $migrateStat->comments = 0;
         $migrateStat->images = 0;
         $migrateStat->user = array();
     }
     $query = 'SELECT * FROM `#__blog_postings` AS a';
     $query .= ' WHERE NOT EXISTS (';
     $query .= ' SELECT content_id FROM `#__easyblog_migrate_content` AS b WHERE b.`content_id` = a.`id` and `component` = ' . $db->Quote('com_blog');
     $query .= ' )';
     $query .= ' ORDER BY a.`id` LIMIT 1';
     $db->setQuery($query);
     $row = $db->loadObject();
     if (is_null($row)) {
         //at here, we check whether there are any records processed. if yes,
         //show the statistic.
         $ejax->append('progress-status2', JText::_('COM_EASYBLOG_MIGRATOR_FINISHED'));
         $ejax->script("divSrolltoBottomSmartBlog();");
         //update statistic
         $stat = '========================================== <br />';
         $stat .= JText::_('COM_EASYBLOG_MIGRATOR_TOTAL_BLOGS') . ': ' . $migrateStat->blog . '<br />';
         $stat .= 'Total comments migrated : ' . $migrateStat->comments . '<br />';
         $stat .= 'Total images migrated : ' . $migrateStat->images . '<br />';
         $statUser = $migrateStat->user;
         if (!empty($statUser)) {
             $stat .= '<br />';
             $stat .= 'Total user\'s contribution: ' . count($statUser) . '<br />';
             foreach ($statUser as $eachUser) {
                 $stat .= JText::_('COM_EASYBLOG_MIGRATOR_TOTAL_BLOG_USER') . ' \'' . $eachUser->name . '\': ' . $eachUser->blogcount . '<br />';
             }
         }
         $stat .= '<br />==========================================';
         $ejax->assign('stat-status2', $stat);
         $ejax->script("\$( '#migrator-submit2' ).html('" . JText::_('COM_EASYBLOG_MIGRATOR_MIGRATION_COMPLETED') . "');");
         $ejax->script("\$( '#migrator-submit2' ).attr('disabled' , '');");
         $ejax->script("\$( '#icon-wait2' ).css( 'display' , 'none' );");
     } else {
         // here we should process the migration
         // step 1 : create user if not exists in eblog_users - create user through profile jtable load method.
         // step 2 : migrate image files.
         //      step 2.1: create folder if not exist.
         // step 3: migrate comments if needed.
         $date = EB::date();
         $blogObj = new stdClass();
         //default
         $blogObj->category_id = 1;
         //assume 1 is the uncategorized id.
         //load user profile
         $profile = EB::user($row->user_id);
         $blog = EB::table('Blog');
         //assigning blog data
         $blogObj->created_by = $profile->id;
         $blogObj->created = !empty($row->post_date) ? $row->post_date : $date->toMySQL();
         $blogObj->modified = !empty($row->post_update) ? $row->post_update : $date->toMySQL();
         $blogObj->title = $row->post_title;
         $blogObj->permalink = EasyBlogHelper::getPermalink($row->post_title);
         $blogObj->intro = '';
         $blogObj->content = $row->post_desc;
         $blogObj->published = $row->published;
         $blogObj->publish_up = !empty($row->post_date) ? $row->post_date : $date->toMySQL();
         $blogObj->publish_down = '0000-00-00 00:00:00';
         $blogObj->hits = $row->post_hits;
         $blogObj->frontpage = 1;
         $blog->bind($blogObj);
         //step 2
         $imageMigrated = false;
         if ($migrateImage) {
             $newImagePath = JPATH_ROOT . DIRECTORY_SEPARATOR . 'images';
             if (!empty($imagePath)) {
                 $tmpimagePath = str_ireplace('/', DIRECTORY_SEPARATOR, $imagePath);
                 $newImagePath .= DIRECTORY_SEPARATOR . $tmpimagePath;
                 $newImagePath = JFolder::makeSafe($newImagePath);
             }
             if (!JFolder::exists($newImagePath)) {
                 JFolder::create($newImagePath);
             }
             $src = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_blog' . DIRECTORY_SEPARATOR . 'Images' . DIRECTORY_SEPARATOR . 'blogimages' . DIRECTORY_SEPARATOR . 'th' . $row->post_image;
             $dest = $newImagePath . DIRECTORY_SEPARATOR . $row->post_image;
             if (JFile::exists($src)) {
                 $imageMigrated = JFile::copy($src, $dest);
             }
         }
         if ($imageMigrated) {
             $destSafeURL = str_ireplace(DIRECTORY_SEPARATOR, '/', $imagePath);
             $destSafeURL = 'images/' . $destSafeURL . '/' . $row->post_image;
             $imageContent = '<p><img style="padding:0px 10px 10px 0px;" align="left" src="' . $destSafeURL . '" border="0" /> </p>';
             $blog->content = $imageContent . $blog->content;
             $migrateStat->images++;
         }
         $blog->store();
         // step 3
         if ($migrateComment) {
             //required frontend model file.
             require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'models' . DIRECTORY_SEPARATOR . 'comment.php';
             $model = new EasyBlogModelComment();
             $queryComment = 'SELECT * FROM `#__blog_comment` WHERE `post_id` = ' . $db->Quote($row->id);
             $queryComment .= ' ORDER BY `id`';
             $db->setQuery($queryComment);
             $resultComment = $db->loadObjectList();
             if (count($resultComment) > 0) {
                 foreach ($resultComment as $itemComment) {
                     //load user profile
                     $commentor = EB::user($itemComment->user_id);
                     $user = JFactory::getUser($itemComment->user_id);
                     $now = EB::date();
                     $commt = EB::table('Comment');
                     $commt->post_id = $blog->id;
                     $commt->comment = $itemComment->comment_desc;
                     $commt->title = $itemComment->comment_title;
                     $commt->name = $user->name;
                     $commt->email = $user->email;
                     $commt->url = $commentor->url;
                     $commt->created_by = $itemComment->user_id;
                     $commt->created = $itemComment->comment_date;
                     $commt->published = $itemComment->published;
                     //adding new comment
                     $latestCmmt = $model->getLatestComment($blog->id, '0');
                     $lft = 1;
                     $rgt = 2;
                     if (!empty($latestCmmt)) {
                         $lft = $latestCmmt->rgt + 1;
                         $rgt = $latestCmmt->rgt + 2;
                         $model->updateCommentSibling($blog->id, $latestCmmt->rgt);
                     }
                     $commt->lft = $lft;
                     $commt->rgt = $rgt;
                     $commt->store();
                     //update state
                     $migrateStat->comments++;
                 }
                 //end foreach
             }
             //end if count(comment)
         }
         //update session value
         $migrateStat->blog++;
         $statUser = $migrateStat->user;
         $statUserObj = null;
         if (!isset($statUser[$profile->id])) {
             $statUserObj = new stdClass();
             $statUserObj->name = $profile->nickname;
             $statUserObj->blogcount = 0;
         } else {
             $statUserObj = $statUser[$profile->id];
         }
         $statUserObj->blogcount++;
         $statUser[$profile->id] = $statUserObj;
         $migrateStat->user = $statUser;
         $jSession->set('EBLOG_MIGRATOR_JOOMLA_STAT', $migrateStat, 'EASYBLOG');
         //log the entry into migrate table.
         $migrator = EB::table('Migrate');
         $migrator->content_id = $row->id;
         $migrator->post_id = $blog->id;
         $migrator->session_id = $jSession->getToken();
         $migrator->component = 'com_blog';
         $migrator->store();
         $ejax->append('progress-status2', JText::_('COM_EASYBLOG_MIGRATOR_MIGRATED_SMARTBLOG') . ': ' . $row->id . JText::_('COM_EASYBLOG_MIGRATOR_EASYBLOG') . ' :' . $blog->id . '<br />');
         $ejax->script("ejax.load('migrators','_processSmartBlog','{$migrateComment}', '{$migrateImage}', '{$imagePath}');");
     }
     $ejax->send();
 }
Ejemplo n.º 19
0
 /**
  * Loads validators
  * @param $name validator name
  * @return string classname of loaded validator
  */
 function loadValidator($names, $type = '')
 {
     foreach ($names as $name) {
         $classname = JFile::makeSafe('JD_' . ucfirst($name) . '_Validator');
         $type = JFolder::makeSafe($type);
         if ($type) {
             $path = JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_jdefender' . DS . 'lib' . DS . 'validators' . DS . $type . DS;
         } else {
             $path = JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_jdefender' . DS . 'lib' . DS . 'validators' . DS;
         }
         $path .= strtolower($classname) . '.php';
         if (JFile::exists($path)) {
             include_once $path;
             if (class_exists($classname)) {
                 $validator = new $classname();
                 $this->register($validator);
             } else {
                 $logger =& JD_Logger::getInstance(__CLASS__);
                 $logger->log('Failed loading validator, classname: ' . $classname, 'warning');
             }
         }
     }
     return true;
 }
Ejemplo n.º 20
0
 public function validate($form, $data, $group = null)
 {
     // clean up the folder name if it is no picasa album
     if (empty($data['id'])) {
         // make the foldername for local folders safe
         if ($data['foldertype'] == 0) {
             $data['folder'] = JFolder::makeSafe($data['folder']);
         }
     }
     $validData = parent::validate($form, $data, $group);
     if (is_bool($validData) && $validDate == false) {
         return false;
     }
     if (!isset($data['usergroups']) || count($data['usergroups']) == 0) {
         $validData['usergroupids'] = '';
     } else {
         $validData['usergroupids'] = implode(',', $data['usergroups']);
     }
     return $validData;
 }
Ejemplo n.º 21
0
 public function migrateImage($item)
 {
     $newImagePath = JPATH_ROOT . DIRECTORY_SEPARATOR . 'images';
     if (!empty($imagePath)) {
         $tmpimagePath = str_ireplace('/', DIRECTORY_SEPARATOR, $imagePath);
         $newImagePath .= DIRECTORY_SEPARATOR . $tmpimagePath;
         $newImagePath = JFolder::makeSafe($newImagePath);
     }
     if (!JFolder::exists($newImagePath)) {
         JFolder::create($newImagePath);
     }
     $src = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_blog' . DIRECTORY_SEPARATOR . 'Images' . DIRECTORY_SEPARATOR . 'blogimages' . DIRECTORY_SEPARATOR . 'th' . $item->post_image;
     $dest = $newImagePath . DIRECTORY_SEPARATOR . $item->post_image;
     if (JFile::exists($src)) {
         $imageMigrated = JFile::copy($src, $dest);
     }
     return $imageMigrated;
 }
Ejemplo n.º 22
0
 /**
  * Method to run after an install/update/uninstall method.
  *
  * @param string $type
  * @param string $parent
  *
  * @return void
  */
 public function postflight($type, $parent)
 {
     if (!defined("GAMIFICATION_PATH_COMPONENT_ADMINISTRATOR")) {
         define("GAMIFICATION_PATH_COMPONENT_ADMINISTRATOR", JPATH_ADMINISTRATOR . "/components/com_gamification");
     }
     // Register Component helpers
     JLoader::register("GamificationInstallHelper", GAMIFICATION_PATH_COMPONENT_ADMINISTRATOR . "/helpers/install.php");
     jimport('Prism.init');
     jimport('Gamification.init');
     $params = JComponentHelper::getParams("com_gamification");
     $imagesFolder = JFolder::makeSafe($params->get("images_directory", "images/gamification"));
     $imagesPath = JPath::clean(JPATH_SITE . DIRECTORY_SEPARATOR . $imagesFolder);
     // Create images folder
     if (!JFolder::exists($imagesPath)) {
         GamificationInstallHelper::createFolder($imagesPath);
     }
     // Start table with the information
     GamificationInstallHelper::startTable();
     // Requirements
     GamificationInstallHelper::addRowHeading(JText::_("COM_GAMIFICATION_MINIMUM_REQUIREMENTS"));
     // Display result about verification for existing folder
     $title = JText::_("COM_GAMIFICATION_IMAGE_FOLDER");
     $info = $imagesFolder;
     if (!is_dir($imagesPath)) {
         $result = array("type" => "important", "text" => JText::_("JNO"));
     } else {
         $result = array("type" => "success", "text" => JText::_("JYES"));
     }
     GamificationInstallHelper::addRow($title, $result, $info);
     // Display result about verification for writable folder
     $title = JText::_("COM_GAMIFICATION_WRITABLE_FOLDER");
     $info = $imagesFolder;
     if (!is_writable($imagesPath)) {
         $result = array("type" => "important", "text" => JText::_("JNO"));
     } else {
         $result = array("type" => "success", "text" => JText::_("JYES"));
     }
     GamificationInstallHelper::addRow($title, $result, $info);
     // Display result about verification for GD library
     $title = JText::_("COM_GAMIFICATION_GD_LIBRARY");
     $info = "";
     if (!extension_loaded('gd') and function_exists('gd_info')) {
         $result = array("type" => "important", "text" => JText::_("COM_GAMIFICATION_WARNING"));
     } else {
         $result = array("type" => "success", "text" => JText::_("JON"));
     }
     GamificationInstallHelper::addRow($title, $result, $info);
     // Display result about verification for cURL library
     $title = JText::_("COM_GAMIFICATION_CURL_LIBRARY");
     $info = "";
     if (!extension_loaded('curl')) {
         $info = JText::_("COM_GAMIFICATION_CURL_INFO");
         $result = array("type" => "important", "text" => JText::_("JOFF"));
     } else {
         $result = array("type" => "success", "text" => JText::_("JON"));
     }
     GamificationInstallHelper::addRow($title, $result, $info);
     // Display result about verification Magic Quotes
     $title = JText::_("COM_GAMIFICATION_MAGIC_QUOTES");
     $info = "";
     if (get_magic_quotes_gpc()) {
         $info = JText::_("COM_GAMIFICATION_MAGIC_QUOTES_INFO");
         $result = array("type" => "important", "text" => JText::_("JON"));
     } else {
         $result = array("type" => "success", "text" => JText::_("JOFF"));
     }
     GamificationInstallHelper::addRow($title, $result, $info);
     // Display result about verification FileInfo
     $title = JText::_("COM_GAMIFICATION_FILEINFO");
     $info = "";
     if (!function_exists('finfo_open')) {
         $info = JText::_("COM_GAMIFICATION_FILEINFO_INFO");
         $result = array("type" => "important", "text" => JText::_("JOFF"));
     } else {
         $result = array("type" => "success", "text" => JText::_("JON"));
     }
     GamificationInstallHelper::addRow($title, $result, $info);
     // Display result about PHP version
     $title = JText::_("COM_GAMIFICATION_PHP_VERSION");
     $info = "";
     if (version_compare(PHP_VERSION, '5.3.0') < 0) {
         $result = array("type" => "important", "text" => JText::_("COM_GAMIFICATION_WARNING"));
     } else {
         $result = array("type" => "success", "text" => JText::_("JYES"));
     }
     GamificationInstallHelper::addRow($title, $result, $info);
     // Display result about verification of installed Prism Library
     jimport("itprism.version");
     $title = JText::_("COM_GAMIFICATION_PRISM_LIBRARY");
     $info = "";
     if (!class_exists("Prism\\Version")) {
         $info = JText::_("COM_GAMIFICATION_PRISM_LIBRARY_DOWNLOAD");
         $result = array("type" => "important", "text" => JText::_("JNO"));
     } else {
         $result = array("type" => "success", "text" => JText::_("JYES"));
     }
     GamificationInstallHelper::addRow($title, $result, $info);
     // Installed extensions
     GamificationInstallHelper::addRowHeading(JText::_("COM_GAMIFICATION_INSTALLED_EXTENSIONS"));
     // Gamification Library
     $result = array("type" => "success", "text" => JText::_("COM_GAMIFICATION_INSTALLED"));
     GamificationInstallHelper::addRow(JText::_("COM_GAMIFICATION_GAMIFICATION_LIBRARY"), $result, JText::_("COM_GAMIFICATION_LIBRARY"));
     // Gamification System Gamification
     $result = array("type" => "success", "text" => JText::_("COM_GAMIFICATION_INSTALLED"));
     GamificationInstallHelper::addRow(JText::_("COM_GAMIFICATION_PLUGIN_SYSTEM_GAMIFICATION"), $result, JText::_("COM_GAMIFICATION_PLUGIN"));
     // End table
     GamificationInstallHelper::endTable();
     echo JText::sprintf("COM_GAMIFICATION_MESSAGE_REVIEW_SAVE_SETTINGS", JRoute::_("index.php?option=com_gamification"));
     if (!class_exists("Prism\\Version")) {
         echo JText::_("COM_GAMIFICATION_MESSAGE_INSTALL_PRISM_LIBRARY");
     } else {
         if (class_exists("Gamification\\Version")) {
             $prismVersion = new Prism\Version();
             $componentVersion = new Gamification\Version();
             if (version_compare($prismVersion->getShortVersion(), $componentVersion->requiredPrismVersion, "<")) {
                 echo JText::_("COM_GAMIFICATION_MESSAGE_INSTALL_PRISM_LIBRARY");
             }
         }
     }
 }
Ejemplo n.º 23
0
 /**
  * Resolve extension by one of it's files
  * @param $path
  * @returns object 
  * 
  * $result->type = 'component';
  * $result->isAdmin = $isAdmin;
  * $result->group = null;
  * $result->extension			
  */
 function resolveExtension($path)
 {
     $originalPath = JPath::clean($path);
     $path = str_replace('\\', '/', $path);
     $path = str_replace(JPATH_ROOT, '', $path);
     $path = trim($path, '/ ');
     $isAdmin = strpos($path, 'administrator/') !== false;
     $parts = explode('/', $path);
     for ($i = 0, $c = count($parts); $i < $c; $i++) {
         switch ($parts[$i]) {
             case 'components':
                 if (empty($parts[$i + 1]) || strpos($parts[$i + 1], 'com_') !== 0) {
                     break;
                 }
                 $result = new stdClass();
                 $result->type = 'component';
                 $result->isAdmin = $isAdmin;
                 $result->group = null;
                 $result->extension = empty($parts[$i + 1]) ? '' : $parts[$i + 1];
                 return $result;
             case 'plugins':
                 if (empty($parts[$i + 1]) || empty($parts[$i + 2])) {
                     break;
                 }
                 // check if we have plugin php or xml file ;)
                 $file = basename($parts[$i + 2]);
                 $configFile = JPATH_ROOT . DS . 'plugins' . DS . $parts[$i + 1] . DS . JFile::stripExt($file) . '.xml';
                 $pluginFile = JPATH_ROOT . DS . 'plugins' . DS . $parts[$i + 1] . DS . JFile::stripExt($file) . '.php';
                 if (!is_file($configFile) || !is_file($pluginFile)) {
                     break;
                 }
                 $result = new stdClass();
                 $result->type = 'plugin';
                 $result->isAdmin = $isAdmin;
                 $result->group = empty($parts[$i + 1]) ? '' : $parts[$i + 1];
                 $result->extension = empty($parts[$i + 2]) ? '' : JFile::stripExt($parts[$i + 2]);
                 return $result;
             case 'modules':
                 if (empty($parts[$i + 1])) {
                     break;
                 }
                 // check if we have module php or xml file ;)
                 $file = JFolder::makeSafe($parts[$i + 1]);
                 $configFile = JPATH_ROOT . DS . 'modules' . DS . $file . DS . JFile::stripExt($file) . '.xml';
                 $moduleFile = JPATH_ROOT . DS . 'modules' . DS . $file . DS . JFile::stripExt($file) . '.php';
                 if (!is_file($configFile) || !is_file($moduleFile)) {
                     break;
                 }
                 $result = new stdClass();
                 $result->type = 'module';
                 $result->isAdmin = $isAdmin;
                 $result->group = null;
                 $result->extension = empty($parts[$i + 1]) ? '' : $parts[$i + 1];
                 return $result;
             case 'templates':
                 if (empty($parts[$i + 1])) {
                     break;
                 }
                 if (!is_dir(JPATH_ROOT . DS . 'templates' . DS . JFolder::makeSafe($parts[$i + 1]))) {
                     break;
                 }
                 $result = new stdClass();
                 $result->type = 'template';
                 $result->isAdmin = $isAdmin;
                 $result->group = null;
                 $result->extension = empty($parts[$i + 1]) ? '' : $parts[$i + 1];
                 return $result;
         }
     }
     return false;
 }
Ejemplo n.º 24
0
 /**
  * Method to save tables
  *
  * Cannot use JFile::write() because we want to append data
  *
  * @access    public
  *
  * @param   boolean $update
  *
  * @return  mixed
  *
  * @throws  BwException on errors
  */
 public function saveTables($update = false)
 {
     try {
         // Import JFolder and JFileObject class
         jimport('joomla.filesystem.folder');
         jimport('joomla.filesystem.file');
         // create (empty) backup file
         $date = JFactory::getDate()->format("Y-m-d_H_i");
         $path = IS_WIN ? JFactory::getConfig()->get('tmp_path') : JFolder::makeSafe(JFactory::getConfig()->get('tmp_path'));
         $file_name = $path . '/' . JFile::makeSafe('BwPostman_Tables_Server_' . $date . '.xml');
         if (!JFolder::exists($path)) {
             if ($update) {
                 echo '<p class="bw_tablecheck_error">' . JText::sprintf('COM_BWPOSTMAN_MAINTENANCE_SAVE_TABLES_ERROR_FOLDER_NOT_FOUND', $path) . '</p>';
                 return false;
             }
             throw new BwException(JText::sprintf('COM_BWPOSTMAN_MAINTENANCE_SAVE_TABLES_ERROR_FOLDER_NOT_FOUND', $path));
         }
         $handle = fopen($file_name, 'wb');
         if ($handle === false) {
             if ($update) {
                 echo '<p class="bw_tablecheck_error">' . JText::sprintf('COM_BWPOSTMAN_MAINTENANCE_SAVE_TABLES_ERROR_FOLDER_NOT_WRITABLE', $path) . '</p>';
                 return false;
             }
             throw new BwException(JText::sprintf('COM_BWPOSTMAN_MAINTENANCE_SAVE_TABLES_ERROR_FOLDER_NOT_WRITABLE', $path));
         }
         // get all names of installed BwPostman tables
         $tableNames = $this->getTableNamesFromDB();
         if ($tableNames === null) {
             if ($update) {
                 echo '<p class="bw_tablecheck_error">' . JText::sprintf('COM_BWPOSTMAN_MAINTENANCE_SAVE_TABLES_ERROR_GET_TABLE_NAMES', $path) . '</p>';
                 return false;
             }
             throw new BwException(JText::_('COM_BWPOSTMAN_MAINTENANCE_SAVE_TABLES_ERROR_GET_TABLE_NAMES'));
         }
         // write file header
         $file_data = array();
         $file_data[] = $this->buildXmlHeader();
         if (fwrite($handle, implode("\n", $file_data)) === false) {
             if ($update) {
                 echo '<p class="bw_tablecheck_error">' . JText::sprintf('COM_BWPOSTMAN_MAINTENANCE_SAVE_TABLES_ERROR_WRITING_HEADER', $path) . '</p>';
                 return false;
             }
             throw new BwException(JText::_('COM_BWPOSTMAN_MAINTENANCE_SAVE_TABLES_ERROR_WRITING_HEADER'));
         }
         foreach ($tableNames as $table) {
             // do not save the table "bwpostman_templates_tpl"
             if (strpos($table, 'templates_tpl') === false) {
                 $file_data = array();
                 $tableName = $this->getGenericTableName($table);
                 $file_data[] = "\t\t<tables>";
                 // set XML tables section
                 $file_data[] = $this->buildXmlStructure($tableName);
                 // get table description
                 if (fwrite($handle, implode("\n", $file_data)) === false) {
                     if ($update) {
                         echo '<p class="bw_tablecheck_error">' . JText::sprintf('COM_BWPOSTMAN_MAINTENANCE_SAVE_TABLES_ERROR_WRITE_FILE_NAME', $file_name) . '</p>';
                         return false;
                     }
                     throw new BwException(JText::sprintf('COM_BWPOSTMAN_MAINTENANCE_SAVE_TABLES_ERROR_WRITE_FILE_NAME', $file_name));
                 } else {
                     if ($update) {
                         echo '<p class="bw_tablecheck_ok">' . JText::sprintf('COM_BWPOSTMAN_MAINTENANCE_SAVE_TABLES_WRITE_TABLE_SUCCESS', $tableName) . '</p>';
                     }
                 }
                 $file_data = array();
                 $res = $this->buildXmlData($tableName, $handle);
                 // write table data
                 if (!$res) {
                     if ($update) {
                         echo '<p class="bw_tablecheck_error">' . JText::sprintf('COM_BWPOSTMAN_MAINTENANCE_SAVE_TABLES_ERROR_WRITE_FILE_NAME', $file_name) . '</p>';
                         return false;
                     }
                     break;
                 }
                 $file_data = array();
                 $file_data[] = $this->buildXmlAssets($tableName);
                 // write data assets
                 $file_data[] = "\t\t</tables>\n";
                 // set XML tables section
                 if (fwrite($handle, implode("\n", $file_data)) === false) {
                     if ($update) {
                         echo '<p class="bw_tablecheck_error">' . JText::sprintf('COM_BWPOSTMAN_MAINTENANCE_SAVE_ASSETS_WRITE_FILE_ERROR', $file_name) . '</p>';
                         return false;
                     }
                     throw new BwException(JText::sprintf('COM_BWPOSTMAN_MAINTENANCE_SAVE_ASSETS_WRITE_FILE_ERROR', $file_name));
                 }
                 $file_data = array();
             }
         }
         $file_data[] = $this->buildXmlFooter();
         // get XML footer
         $file_data = implode("\n", $file_data);
         if (fwrite($handle, $file_data) !== false) {
             if ($update) {
                 echo '<p class="bw_tablecheck_ok">' . JText::sprintf('COM_BWPOSTMAN_MAINTENANCE_SAVE_TABLES_WRITE_FILE_SUCCESS', $file_name) . '</p>';
             }
         } else {
             if ($update) {
                 echo '<p class="bw_tablecheck_error">' . JText::sprintf('COM_BWPOSTMAN_MAINTENANCE_SAVE_TABLES_ERROR_WRITE_FILE_NAME', $file_name) . '</p>';
                 return false;
             }
             throw new BwException(JText::sprintf('COM_BWPOSTMAN_MAINTENANCE_SAVE_TABLES_ERROR_WRITE_FILE_NAME', $file_name));
         }
     } catch (BwException $e) {
         echo $e->getMessage();
         JFile::delete($file_name);
         return false;
     }
     if ($update) {
         return true;
     } else {
         return $file_name;
     }
 }
Ejemplo n.º 25
0
 /**
  * Method to run after an install/update/uninstall method.
  *
  * @param string $type
  * @param string $parent
  *
  * @return void
  */
 public function postflight($type, $parent)
 {
     if (!defined("COM_CROWDFUNDING_PATH_COMPONENT_ADMINISTRATOR")) {
         define("COM_CROWDFUNDING_PATH_COMPONENT_ADMINISTRATOR", JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . "components" . DIRECTORY_SEPARATOR . "com_crowdfunding");
     }
     // Register Component helpers
     JLoader::register("CrowdfundingInstallHelper", COM_CROWDFUNDING_PATH_COMPONENT_ADMINISTRATOR . DIRECTORY_SEPARATOR . "helpers" . DIRECTORY_SEPARATOR . "install.php");
     jimport('joomla.filesystem.path');
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     jimport('Prism.init');
     jimport('Crowdfunding.init');
     $params = JComponentHelper::getParams("com_crowdfunding");
     /** @var $params Joomla\Registry\Registry */
     // Prepare images folders.
     $imagesFolder = JFolder::makeSafe($params->get("images_directory", "images/crowdfunding"));
     $temporaryImagesFolder = $imagesFolder . "/temporary";
     // Create images folder.
     $imagesPath = JPath::clean(JPATH_SITE . DIRECTORY_SEPARATOR . $imagesFolder);
     if (!is_dir($imagesPath)) {
         CrowdfundingInstallHelper::createFolder($imagesPath);
     }
     // Create temporary images folder
     $temporaryImagesPath = JPath::clean(JPATH_SITE . DIRECTORY_SEPARATOR . $temporaryImagesFolder);
     if (!is_dir($temporaryImagesPath)) {
         CrowdfundingInstallHelper::createFolder($temporaryImagesPath);
     }
     // Start table with the information
     CrowdfundingInstallHelper::startTable();
     // Requirements
     CrowdfundingInstallHelper::addRowHeading(JText::_("COM_CROWDFUNDING_MINIMUM_REQUIREMENTS"));
     // Display result about verification for existing folder
     $title = JText::_("COM_CROWDFUNDING_IMAGE_FOLDER");
     $info = $imagesFolder;
     if (!is_dir($imagesPath)) {
         $result = array("type" => "important", "text" => JText::_("JNO"));
     } else {
         $result = array("type" => "success", "text" => JText::_("JYES"));
     }
     CrowdfundingInstallHelper::addRow($title, $result, $info);
     // Display result about verification for writable folder
     $title = JText::_("COM_CROWDFUNDING_IMAGE_WRITABLE_FOLDER");
     $info = $imagesFolder;
     if (!is_writable($imagesPath)) {
         $result = array("type" => "important", "text" => JText::_("JNO"));
     } else {
         $result = array("type" => "success", "text" => JText::_("JYES"));
     }
     CrowdfundingInstallHelper::addRow($title, $result, $info);
     // Display result about verification for existing folder
     $title = JText::_("COM_CROWDFUNDING_TEMPORARY_IMAGE_FOLDER");
     $info = $temporaryImagesFolder;
     if (!is_dir($temporaryImagesPath)) {
         $result = array("type" => "important", "text" => JText::_("JNO"));
     } else {
         $result = array("type" => "success", "text" => JText::_("JYES"));
     }
     CrowdfundingInstallHelper::addRow($title, $result, $info);
     // Display result about verification for writable folder
     $title = JText::_("COM_CROWDFUNDING_TEMPORARY_IMAGE_WRITABLE_FOLDER");
     $info = $temporaryImagesFolder;
     if (!is_writable($temporaryImagesPath)) {
         $result = array("type" => "important", "text" => JText::_("JNO"));
     } else {
         $result = array("type" => "success", "text" => JText::_("JYES"));
     }
     CrowdfundingInstallHelper::addRow($title, $result, $info);
     // Display result about verification for GD library
     $title = JText::_("COM_CROWDFUNDING_GD_LIBRARY");
     $info = "";
     if (!extension_loaded('gd') and function_exists('gd_info')) {
         $result = array("type" => "important", "text" => JText::_("COM_CROWDFUNDING_WARNING"));
     } else {
         $result = array("type" => "success", "text" => JText::_("JON"));
     }
     CrowdfundingInstallHelper::addRow($title, $result, $info);
     // Display result about verification for cURL library
     $title = JText::_("COM_CROWDFUNDING_CURL_LIBRARY");
     $info = "";
     if (!extension_loaded('curl')) {
         $info = JText::_("COM_CROWDFUNDING_CURL_INFO");
         $result = array("type" => "important", "text" => JText::_("JOFF"));
     } else {
         $result = array("type" => "success", "text" => JText::_("JON"));
     }
     CrowdfundingInstallHelper::addRow($title, $result, $info);
     // Display result about verification Magic Quotes
     $title = JText::_("COM_CROWDFUNDING_MAGIC_QUOTES");
     $info = "";
     if (get_magic_quotes_gpc()) {
         $info = JText::_("COM_CROWDFUNDING_MAGIC_QUOTES_INFO");
         $result = array("type" => "important", "text" => JText::_("JON"));
     } else {
         $result = array("type" => "success", "text" => JText::_("JOFF"));
     }
     CrowdfundingInstallHelper::addRow($title, $result, $info);
     // Display result about verification FileInfo
     $title = JText::_("COM_CROWDFUNDING_FILEINFO");
     $info = "";
     if (!function_exists('finfo_open')) {
         $info = JText::_("COM_CROWDFUNDING_FILEINFO_INFO");
         $result = array("type" => "important", "text" => JText::_("JOFF"));
     } else {
         $result = array("type" => "success", "text" => JText::_("JON"));
     }
     CrowdfundingInstallHelper::addRow($title, $result, $info);
     // Display result about verification of PHP Version.
     $title = JText::_("COM_CROWDFUNDING_PHP_VERSION");
     $info = "";
     if (version_compare(PHP_VERSION, '5.3.0') < 0) {
         $result = array("type" => "important", "text" => JText::_("COM_CROWDFUNDING_WARNING"));
     } else {
         $result = array("type" => "success", "text" => JText::_("JYES"));
     }
     CrowdfundingInstallHelper::addRow($title, $result, $info);
     // Display result about verification of installed Prism Library
     $title = JText::_("COM_CROWDFUNDING_PRISM_LIBRARY");
     $info = "";
     if (!class_exists("Prism\\Version")) {
         $info = JText::_("COM_CROWDFUNDING_PRISM_LIBRARY_DOWNLOAD");
         $result = array("type" => "important", "text" => JText::_("JNO"));
     } else {
         $result = array("type" => "success", "text" => JText::_("JYES"));
     }
     CrowdfundingInstallHelper::addRow($title, $result, $info);
     // Installed extensions
     CrowdfundingInstallHelper::addRowHeading(JText::_("COM_CROWDFUNDING_INSTALLED_EXTENSIONS"));
     // Crowdfunding Library
     $result = array("type" => "success", "text" => JText::_("COM_CROWDFUNDING_INSTALLED"));
     CrowdfundingInstallHelper::addRow(JText::_("COM_CROWDFUNDING_CROWDFUNDING_LIBRARY"), $result, JText::_("COM_CROWDFUNDING_LIBRARY"));
     // Plugins
     // Content - Crowdfunding - Navigation
     $result = array("type" => "success", "text" => JText::_("COM_CROWDFUNDING_INSTALLED"));
     CrowdfundingInstallHelper::addRow(JText::_("COM_CROWDFUNDING_CONTENT_CROWDFUNDING_NAVIGATION"), $result, JText::_("COM_CROWDFUNDING_PLUGIN"));
     // Content - Crowdfunding - Share
     $result = array("type" => "success", "text" => JText::_("COM_CROWDFUNDING_INSTALLED"));
     CrowdfundingInstallHelper::addRow(JText::_("COM_CROWDFUNDING_CONTENT_CROWDFUNDING_SHARE"), $result, JText::_("COM_CROWDFUNDING_PLUGIN"));
     // Content - Crowdfunding - Admin Mail
     $result = array("type" => "success", "text" => JText::_("COM_CROWDFUNDING_INSTALLED"));
     CrowdfundingInstallHelper::addRow(JText::_("COM_CROWDFUNDING_CONTENT_CROWDFUNDING_ADMIN_MAIL"), $result, JText::_("COM_CROWDFUNDING_PLUGIN"));
     // Content - Crowdfunding - User Mail
     $result = array("type" => "success", "text" => JText::_("COM_CROWDFUNDING_INSTALLED"));
     CrowdfundingInstallHelper::addRow(JText::_("COM_CROWDFUNDING_CONTENT_CROWDFUNDING_USER_MAIL"), $result, JText::_("COM_CROWDFUNDING_PLUGIN"));
     // Content - Crowdfunding - Validator
     $result = array("type" => "success", "text" => JText::_("COM_CROWDFUNDING_INSTALLED"));
     CrowdfundingInstallHelper::addRow(JText::_("COM_CROWDFUNDING_CONTENT_CROWDFUNDING_VALIDATOR"), $result, JText::_("COM_CROWDFUNDING_PLUGIN"));
     // System - Crowdfunding - Modules
     $result = array("type" => "success", "text" => JText::_("COM_CROWDFUNDING_INSTALLED"));
     CrowdfundingInstallHelper::addRow(JText::_("COM_CROWDFUNDING_SYSTEM_CROWDFUNDINGMODULES"), $result, JText::_("COM_CROWDFUNDING_PLUGIN"));
     // Crowdfunding Payment - PayPal
     $result = array("type" => "success", "text" => JText::_("COM_CROWDFUNDING_INSTALLED"));
     CrowdfundingInstallHelper::addRow(JText::_("COM_CROWDFUNDING_CROWDFUNDINGPAYMENT_PAYPAL"), $result, JText::_("COM_CROWDFUNDING_PLUGIN"));
     // Modules
     // Crowdfunding Info
     $result = array("type" => "success", "text" => JText::_("COM_CROWDFUNDING_INSTALLED"));
     CrowdfundingInstallHelper::addRow(JText::_("COM_CROWDFUNDING_CROWDFUNDING_MODULE_INFO"), $result, JText::_("COM_CROWDFUNDING_MODULE"));
     // Crowdfunding Details
     $result = array("type" => "success", "text" => JText::_("COM_CROWDFUNDING_INSTALLED"));
     CrowdfundingInstallHelper::addRow(JText::_("COM_CROWDFUNDING_CROWDFUNDING_MODULE_DETAILS"), $result, JText::_("COM_CROWDFUNDING_MODULE"));
     // Crowdfunding Rewards
     $result = array("type" => "success", "text" => JText::_("COM_CROWDFUNDING_INSTALLED"));
     CrowdfundingInstallHelper::addRow(JText::_("COM_CROWDFUNDING_CROWDFUNDING_MODULE_REWARDS"), $result, JText::_("COM_CROWDFUNDING_MODULE"));
     // End table
     CrowdfundingInstallHelper::endTable();
     echo JText::sprintf("COM_CROWDFUNDING_MESSAGE_REVIEW_SAVE_SETTINGS", JRoute::_("index.php?option=com_crowdfunding"));
     if (!class_exists("Prism\\Version")) {
         echo JText::_("COM_CROWDFUNDING_MESSAGE_INSTALL_PRISM_LIBRARY");
     } else {
         if (class_exists("Crowdfunding\\Version")) {
             $prismVersion = new Prism\Version();
             $crowdfundingVersion = new Crowdfunding\Version();
             if (version_compare($prismVersion->getShortVersion(), $crowdfundingVersion->requiredPrismVersion)) {
                 echo JText::_("COM_CROWDFUNDING_MESSAGE_INSTALL_PRISM_LIBRARY");
             }
         }
     }
     // Remove the files that the system does not use anymore.
     $this->removeUnusedFiles();
 }
Ejemplo n.º 26
0
 /**
  * @dataProvider makeSafeData
  */
 public function testMakeSafeFromDataSet($path, $expect)
 {
     $actual = JFolder::makeSafe($path);
     $this->assertEquals($expect, $actual);
 }
Ejemplo n.º 27
0
 /**
  * Method to get the XML form file for this component. Used to get translated field names for history preview.
  *
  * @param   JTableContenttype  $typesTable  Table object with content history options.
  *
  * @return  mixed  JModel object if successful, false if no model found.
  *
  * @since   3.2
  */
 public static function getFormFile(JTableContenttype $typesTable)
 {
     $result = false;
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     // First, see if we have a file name in the $typesTable
     $options = json_decode($typesTable->content_history_options);
     if (is_object($options) && isset($options->formFile) && JFile::exists(JPATH_ROOT . '/' . $options->formFile)) {
         $result = JPATH_ROOT . '/' . $options->formFile;
     } else {
         $aliasArray = explode('.', $typesTable->type_alias);
         if (count($aliasArray) == 2) {
             $component = $aliasArray[1] == 'category' ? 'com_categories' : $aliasArray[0];
             $path = JFolder::makeSafe(JPATH_ADMINISTRATOR . '/components/' . $component . '/models/forms/');
             $file = JFile::makeSafe($aliasArray[1] . '.xml');
             $result = JFile::exists($path . $file) ? $path . $file : false;
         }
     }
     return $result;
 }
Ejemplo n.º 28
0
 /**
  * 
  * Uploads a file if the upload is used
  * copy the file to the tmp directory if a local file is used
  * unpack a packed file is used
  */
 function upload()
 {
     $mainframe = JFactory::getApplication();
     jimport('joomla.filesystem.file');
     //Retrieve file details from uploaded file, sent from upload form:
     $uploaded_file = JRequest::getVar('uploaded_file', null, 'files', 'array');
     //do we use an existing file on server or an uploades file?
     if (empty($uploaded_file['name'])) {
         $existing_file = JRequest::getVar('existing_file', null, 'post', 'string');
         $existing_file_name = JFile::makeSafe(Jfile::getname(Jfile::stripExt($existing_file)));
         $existing_file_extension = JFile::makeSafe(JFile::getExt($existing_file));
         $existing_file_folder_name = JFolder::makeSafe(strstr($existing_file, $existing_file_name, true));
         // $mainframe->getCfg('tmp_path') . DS . JFile::makeSafe(JFile::getName($existing_file));
         $tempfile = tempnam($mainframe->getCfg('tmp_path'), $existing_file_name);
         $fDestName = $tempfile . "." . $existing_file_extension;
         //we don't need the file itseld, we just need the name
         unlink($tempfile);
         JFile::copy(JPATH_ROOT . $existing_file_folder_name . $existing_file_name . "." . $existing_file_extension, $fDestName);
     } else {
         $fDestName = $mainframe->getCfg('tmp_path') . DS . JFile::makeSafe($uploaded_file['name']);
         $fNameTmp = $uploaded_file['tmp_name'];
         if (!JFile::upload($fNameTmp, $fDestName)) {
             //Display the back button:
             JToolBarHelper::back();
             $this->setError('The file could not be uploaded.');
         }
     }
     if (count($this->getErrors() == 0)) {
         $returnURL = JURI::base() . 'index.php?option=com_k2import&task=selectcategory&file=' . JFile::getName($fDestName);
         if (strtolower(JFile::getExt($fDestName)) != 'csv') {
             //we will try to use the file as archive
             jimport('joomla.filesystem.archive');
             $import_tmp_dir = $mainframe->getCfg('tmp_path') . DS . 'k2_import';
             if (JArchive::extract($fDestName, $import_tmp_dir)) {
                 $csv_files = JFolder::files($import_tmp_dir, '.csv');
                 foreach ($csv_files as $csv_file) {
                     if (!JFile::move($csv_file, JFile::makeSafe($csv_file), $import_tmp_dir)) {
                         $this->setError('The file ' . $csv_file . ' could not be renamed.');
                         return false;
                     }
                 }
                 $this->setRedirect($returnURL . '&modus=archive', 'The file was successful uploaded and extracted');
             } else {
                 JToolBarHelper::back();
                 $this->setError('The file could not be extracted.');
             }
         } else {
             $this->setRedirect($returnURL, 'The file was successful uploaded');
         }
     }
 }
Ejemplo n.º 29
0
 function buildRegex($folders = null)
 {
     // Make sure expression limits viewed folders... in case of
     // error, default to expression that will reject all directories
     $regex = '_-_-__-_-_';
     $array = array();
     // Checks
     if (is_array($folders) && !empty($folders)) {
         $folders = implode(',', $folders);
     } elseif (!is_string($folders) || empty($folders)) {
         return $regex;
     }
     // Try and correct errors if any
     $folders = str_replace(array(';', '|'), ',', $folders);
     $folders = @explode(',', $folders);
     foreach ($folders as $f) {
         $f = JFolder::makeSafe($f);
         if (!empty($f)) {
             $array[] = $f;
         }
     }
     // Build regex for use with JFolders::folders
     if (!empty($array)) {
         $regex = '(' . implode('|', $array) . ')';
     }
     return $regex;
 }
Ejemplo n.º 30
0
 /**
  * adds new folder to the database
  * @return array with error Strings
  */
 public static function addNewFolders()
 {
     $errors = array();
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $folders = array();
     if (file_exists(COM_EVENTGALLERY_IMAGE_FOLDER_PATH)) {
         $verzeichnis = dir(COM_EVENTGALLERY_IMAGE_FOLDER_PATH);
     } else {
         return $errors;
     }
     # Hole die verfügbaren Verzeichnisse
     while ($elm = $verzeichnis->read()) {
         //sucht alle Verzeichnisse mit Bilder
         if (is_dir(COM_EVENTGALLERY_IMAGE_FOLDER_PATH . $elm) && $elm != '.' && $elm != '..' && !preg_match("/.cache/", $elm)) {
             if (is_dir(COM_EVENTGALLERY_IMAGE_FOLDER_PATH . $elm . DIRECTORY_SEPARATOR)) {
                 array_push($folders, $elm);
             }
         }
     }
     $query = $db->getQuery(true);
     $query->select('folder')->from($db->quoteName('#__eventgallery_folder'));
     $db->setQuery($query);
     $currentfolders = $db->loadAssocList(null, 'folder');
     # Füge Verzeichnisse in die DB ein
     foreach (array_diff($folders, $currentfolders) as $folder) {
         #Versuchen wir, ein paar Infos zu erraten
         if (strcmp($folder, JFolder::makeSafe($folder)) != 0) {
             $errors[] = JText::sprintf('COM_EVENTGALLERY_SYNC_DATABASE_SYNC_ERROR_FOLDERNAME', $folder, JFolder::makeSafe($folder));
             continue;
         }
         $date = "";
         $temp = array();
         $created = date('Y-m-d H:i:s', filemtime(COM_EVENTGALLERY_IMAGE_FOLDER_PATH . $folder));
         if (preg_match("/[0-9]{4}-[0-9]{2}-[0-9]{2}/", $folder, $temp)) {
             $date = $temp[0];
             $description = str_replace($temp[0], '', $folder);
         } else {
             $description = $folder;
         }
         $db = JFactory::getDbo();
         $db->setQuery('SELECT MAX(ordering) FROM #__eventgallery_folder');
         $max = $db->loadResult();
         $description = trim(str_replace("_", " ", $description));
         $query = $db->getQuery(true);
         $query->insert($db->quoteName('#__eventgallery_folder'))->columns('folder,published,date,description,' . 'userid,created,modified,ordering')->values(implode(',', array($db->quote($folder), '0', $db->quote($date), $db->quote($description), $db->quote($user->id), $db->quote($created), 'now()', $max + 1)));
         $db->setQuery($query);
         $db->execute();
     }
     return $errors;
 }