Esempio n. 1
0
 function connector()
 {
     $mainframe = JFactory::getApplication();
     $params = JComponentHelper::getParams('com_digicom');
     $root = $params->get('ftp_source_path', 'digicom');
     $folder = JRequest::getVar('folder', $root, 'default', 'path');
     if (JString::trim($folder) == "") {
         $folder = $root;
     } else {
         // Ensure that we are always below the root directory
         if (strpos($folder, $root) !== 0) {
             $folder = $root;
         }
     }
     // Disable debug
     JRequest::setVar('debug', false);
     $url = JURI::root(true) . '/' . $folder;
     $path = JPATH_SITE . '/' . JPath::clean($folder);
     JPath::check($path);
     include_once JPATH_COMPONENT_ADMINISTRATOR . '/libs/elfinder/elFinderConnector.class.php';
     include_once JPATH_COMPONENT_ADMINISTRATOR . '/libs/elfinder/elFinder.class.php';
     include_once JPATH_COMPONENT_ADMINISTRATOR . '/libs/elfinder/elFinderVolumeDriver.class.php';
     include_once JPATH_COMPONENT_ADMINISTRATOR . '/libs/elfinder/elFinderVolumeLocalFileSystem.class.php';
     function access($attr, $path, $data, $volume)
     {
         $mainframe = JFactory::getApplication();
         // Hide PHP files.
         $ext = strtolower(JFile::getExt(basename($path)));
         if ($ext == 'php') {
             return true;
         }
         // Hide files and folders starting with .
         if (strpos(basename($path), '.') === 0 && $attr == 'hidden') {
             return true;
         }
         // Read only access for front-end. Full access for administration section.
         switch ($attr) {
             case 'read':
                 return true;
                 break;
             case 'write':
                 return $mainframe->isSite() ? false : true;
                 break;
             case 'locked':
                 return $mainframe->isSite() ? true : false;
                 break;
             case 'hidden':
                 return false;
                 break;
         }
     }
     if ($mainframe->isAdmin()) {
         $permissions = array('read' => true, 'write' => true);
     } else {
         $permissions = array('read' => true, 'write' => false);
     }
     $options = array('debug' => false, 'roots' => array(array('driver' => 'LocalFileSystem', 'path' => $path, 'URL' => $url, 'accessControl' => 'access', 'defaults' => $permissions)));
     $connector = new elFinderConnector(new elFinder($options));
     $connector->run();
 }
Esempio n. 2
0
 /**
  * Get the params for the configuration variables
  */
 function &getParams()
 {
     static $instance;
     if ($instance == null) {
         $component = JEV_COM_COMPONENT;
         $table = JTable::getInstance('extension');
         //if (!$table->loadByOption( $component ))
         if (!$table->load(array("element" => "com_jevents", "type" => "component"))) {
             JError::raiseWarning(500, 'Not a valid component');
             return false;
         }
         // work out file path
         if ($path = JRequest::getString('path')) {
             $path = JPath::clean(JPATH_SITE . '/' . $path);
             JPath::check($path);
         } else {
             $option = preg_replace('#\\W#', '', isset($table->element) ? $table->element : $table->option);
             $path = JPATH_ADMINISTRATOR . '/' . 'components' . '/' . $option . '/' . 'config.xml';
         }
         // Use our own class to add more functionality!
         include_once JEV_ADMINLIBS . "jevparams.php";
         if (file_exists($path)) {
             $instance = new JevParameter($table->params, $path);
         } else {
             $instance = new JevParameter($table->params);
         }
     }
     return $instance;
 }
Esempio n. 3
0
 public function connector()
 {
     $mainframe = JFactory::getApplication();
     $user = JFactory::getUser();
     $path = SigProHelper::getPath('site');
     $url = SigProHelper::getHTTPPath($path);
     JPath::check($path);
     include_once JPATH_COMPONENT_ADMINISTRATOR . '/js/elfinder/php/elFinderConnector.class.php';
     include_once JPATH_COMPONENT_ADMINISTRATOR . '/js/elfinder/php/elFinder.class.php';
     include_once JPATH_COMPONENT_ADMINISTRATOR . '/js/elfinder/php/elFinderVolumeDriver.class.php';
     include_once JPATH_COMPONENT_ADMINISTRATOR . '/js/elfinder/php/elFinderVolumeLocalFileSystem.class.php';
     function access($attr, $path, $data, $volume)
     {
         $mainframe = JFactory::getApplication();
         $user = JFactory::getUser();
         // Hide files and folders starting with .
         if (strpos(basename($path), '.') === 0 && $attr == 'hidden') {
             return true;
         }
         // Read only access for front-end. Full access for administration section.
         switch ($attr) {
             case 'read':
                 return true;
                 break;
             case 'write':
                 if ($mainframe->isSite()) {
                     return false;
                 } else {
                     return version_compare(JVERSION, '1.6.0', 'ge') ? $user->authorise('core.create', 'com_sigpro') && $user->authorise('core.edit', 'com_sigpro') && $user->authorise('core.delete', 'com_sigpro') : true;
                 }
                 break;
             case 'locked':
                 if ($mainframe->isSite()) {
                     return true;
                 } else {
                     return version_compare(JVERSION, '1.6.0', 'ge') ? !($user->authorise('core.create', 'com_sigpro') && $user->authorise('core.edit', 'com_sigpro') && $user->authorise('core.delete', 'com_sigpro')) : false;
                 }
                 break;
             case 'hidden':
                 return false;
                 break;
         }
     }
     if ($mainframe->isAdmin()) {
         if (version_compare(JVERSION, '1.6.0', 'ge')) {
             $write = $user->authorise('core.create', 'com_sigpro') && $user->authorise('core.edit', 'com_sigpro') && $user->authorise('core.delete', 'com_sigpro');
         } else {
             $write = true;
         }
         $permissions = array('read' => true, 'write' => $write);
     } else {
         $permissions = array('read' => true, 'write' => false);
     }
     $options = array('roots' => array(array('driver' => 'LocalFileSystem', 'path' => $path, 'URL' => $url, 'accessControl' => 'access', 'defaults' => $permissions)));
     $connector = new elFinderConnector(new elFinder($options));
     $connector->run();
 }
Esempio n. 4
0
 /**
  * Display an image.
  *
  * @param   string  $src  The source of the image
  *
  * @return  string  A <img> element if the specified file exists, otherwise, a null string
  *
  * @since   2.5
  */
 public static function image($src)
 {
     $src = preg_replace('#[^A-Z0-9\\-_\\./]#i', '', $src);
     $file = JPATH_SITE . '/' . $src;
     jimport('joomla.filesystem.path');
     JPath::check($file);
     if (!file_exists($file)) {
         return '';
     }
     return '<img src="' . JUri::root() . $src . '" alt="" />';
 }
Esempio n. 5
0
 /**
  * Method to auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @return	void
  * @since	1.6
  */
 protected function populateState()
 {
     // Set the component (option) we are dealing with.
     $component = JRequest::getCmd('component');
     $this->setState('component.option', $component);
     // Set an alternative path for the configuration file.
     if ($path = JRequest::getString('path')) {
         $path = JPath::clean(JPATH_SITE . '/' . $path);
         JPath::check($path);
         $this->setState('component.path', $path);
     }
 }
Esempio n. 6
0
 /**
  * Method to auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @return  void
  * @since   1.6
  */
 protected function populateState()
 {
     $input = JFactory::getApplication()->input;
     // Set the component (option) we are dealing with.
     $component = $input->get('component');
     $this->setState('component.option', $component);
     // Set an alternative path for the configuration file.
     if ($path = $input->getString('path')) {
         $path = JPath::clean(JPATH_SITE . '/' . $path);
         JPath::check($path);
         $this->setState('component.path', $path);
     }
 }
Esempio n. 7
0
 function connector()
 {
     $mainframe =& JFactory::getApplication();
     $params =& JComponentHelper::getParams('com_media');
     $root = $params->get('file_path', 'media');
     $folder = JRequest::getVar('folder', $root, 'default', 'path');
     $type = JRequest::getCmd('type', 'video');
     if (JString::trim($folder) == "") {
         $folder = $root;
     }
     $url = JURI::root(true) . '/' . $folder;
     $path = JPATH_SITE . DS . JPath::clean($folder);
     JPath::check($path);
     include_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'lib' . DS . 'elfinder' . DS . 'elFinderConnector.class.php';
     include_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'lib' . DS . 'elfinder' . DS . 'elFinder.class.php';
     include_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'lib' . DS . 'elfinder' . DS . 'elFinderVolumeDriver.class.php';
     include_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'lib' . DS . 'elfinder' . DS . 'elFinderVolumeLocalFileSystem.class.php';
     function access($attr, $path, $data, $volume)
     {
         $mainframe =& JFactory::getApplication();
         // Hide files and folders starting with .
         if (strpos(basename($path), '.') === 0 && $attr == 'hidden') {
             return true;
         }
         // Read only access for front-end. Full access for administration section.
         switch ($attr) {
             case 'read':
                 return true;
                 break;
             case 'write':
                 return $mainframe->isSite() ? false : true;
                 break;
             case 'locked':
                 return $mainframe->isSite() ? true : false;
                 break;
             case 'hidden':
                 return false;
                 break;
         }
     }
     if ($mainframe->isAdmin()) {
         $permissions = array('read' => true, 'write' => true);
     } else {
         $permissions = array('read' => true, 'write' => false);
     }
     $options = array('roots' => array(array('driver' => 'LocalFileSystem', 'path' => $path, 'URL' => $url, 'accessControl' => 'access', 'defaults' => $permissions)));
     $connector = new elFinderConnector(new elFinder($options));
     $connector->run();
 }
Esempio n. 8
0
 public static function getPath($type = 'site')
 {
     jimport('joomla.filesystem.file');
     $application = JFactory::getApplication();
     if ($type == 'k2') {
         $path = JPATH_SITE . '/media/k2/galleries';
     } else {
         if ($type == 'site') {
             $user = JFactory::getUser();
             if (version_compare(JVERSION, '2.5', 'ge')) {
                 $isAdmin = $user->authorise('core.admin', 'com_sigpro');
             } else {
                 $isAdmin = $user->gid == 25;
             }
             if ($application->isAdmin() || $isAdmin) {
                 if (version_compare(JVERSION, '1.6.0', 'ge')) {
                     $defaultImagePath = 'images';
                 } else {
                     $defaultImagePath = 'images/stories';
                 }
                 $params = JComponentHelper::getParams('com_sigpro');
                 $path = JPATH_SITE . '/' . $params->get('galleries_rootfolder', $defaultImagePath);
             } else {
                 $folder = self::getUserFolder();
                 $path = JPATH_SITE . '/media/jw_sigpro/users/' . $folder;
                 if (!JFolder::exists($path)) {
                     JFolder::create($path);
                 }
             }
         } else {
             if ($type == 'users') {
                 $path = JPATH_SITE . '/media/jw_sigpro/users';
             }
         }
     }
     $path = JPath::clean($path);
     JPath::check($path);
     if (JString::substr($path, -1, 1) == DIRECTORY_SEPARATOR) {
         $path = JString::rtrim($path, DIRECTORY_SEPARATOR);
     }
     return $path;
 }
Esempio n. 9
0
 /**
  * Method to load a user activity plugin translation helper
  *
  * @param     string    $name      The name of the plugin
  * @param     string    $type      The plugin type (Optional)
  * @param     array     $config    Config options (Optional)
  *
  * @return    mixed     $plugin    The plugin helper instance on success, Null if not found
  */
 public static function getPluginHelper($name, $type = 'useractivity', $config = array())
 {
     static $plugins = array();
     // Check the cache
     $cache = $type . '.' . $name;
     if (isset($plugins[$cache])) {
         return $plugins[$cache];
     }
     // Include the helper file
     $helper_file = JPath::check(JPATH_PLUGINS . '/' . $type . '/' . $name . '/helpers/' . $name . '.php');
     if (!file_exists($helper_file)) {
         $plugins[$cache] = null;
         return null;
     }
     require_once $helper_file;
     // Create class instance
     $class_name = 'plg' . $type . $name . 'Helper';
     $plugins[$cache] = new $class_name($config);
     return $plugins[$cache];
 }
Esempio n. 10
0
 function getFiles($path)
 {
     static $list;
     // Only process the list once per request
     if (is_array($list)) {
         return $list;
     }
     $path = JPath::clean($path, '/');
     $folder = JPath::check(JPATH_ROOT . '/' . $path);
     if (!is_readable($folder)) {
         return false;
     }
     $files = array();
     $folders = array();
     $docs = array();
     $extensions = array('jpg', 'png', 'gif', 'jpeg');
     // Get upload files if any
     include 'getuploads.php';
     // Iterate over the files if they exist
     foreach (JFolder::files($folder) as $file) {
         $extension = strtolower(pathinfo($folder . '/' . $file, PATHINFO_EXTENSION));
         if (!in_array($extension, $extensions)) {
             continue;
         }
         $tmp = new stdClass();
         $tmp->name = $file;
         $tmp->path = $path . '/' . $file;
         $tmp->url = JURI::root() . $path . '/' . $file;
         $tmp->size = filesize(JPATH_ROOT . '/' . $tmp->path);
         $tmp->date = date("Y-m-d H:i:s", getlastmod(JPATH_ROOT . '/' . $tmp->path));
         $tmp->isimage = true;
         $info = getimagesize(JPATH_ROOT . '/' . $tmp->path);
         $tmp->width = $info[0];
         $tmp->height = $info[1];
         $tmp->type = $info[2];
         $tmp->mime = $info['mime'];
         $tmp->thumbnailUrl = $this->getThumbnailUrl($tmp, 60, 60);
         $files[] = $tmp;
     }
     return $files;
 }
Esempio n. 11
0
 /**
  * Parses the configuration options of a specific component area
  *
  * @param   string  $component  Which component's cionfiguration to parse
  * @param   string  $area       Which area to parse (frontend, backend, cli)
  *
  * @return  array  A hash array with the configuration data
  */
 protected function parseComponentArea($component, $area)
 {
     // Initialise the return array
     $ret = array();
     // Check that the path exists
     JLoader::import('joomla.filesystem.folder');
     $path = JPATH_ADMINISTRATOR . '/components/' . $component;
     $path = JPath::check($path);
     if (!JFolder::exists($path)) {
         return $ret;
     }
     // Read the filename if it exists
     $filename = $path . '/fof.xml';
     if (!JFile::exists($filename)) {
         return $ret;
     }
     $data = JFile::read($filename);
     // Load the XML data in a SimpleXMLElement object
     $xml = simplexml_load_string($data);
     if (!$xml instanceof SimpleXMLElement) {
         return $ret;
     }
     // Get this area's data
     $areaData = $xml->xpath('//' . $area);
     if (empty($areaData)) {
         return $ret;
     }
     $xml = array_shift($areaData);
     // Parse individual configuration domains
     $domains = $this->getDomains();
     foreach ($domains as $dom) {
         $class = 'FOFConfigDomain' . ucfirst($dom);
         if (class_exists($class, true)) {
             $o = new $class();
             $o->parseDomain($xml, $ret);
         }
     }
     // Finally, return the result
     return $ret;
 }
Esempio n. 12
0
 /**
  * Get the params for the configuration variables
  */
 function &getParams()
 {
     static $instance;
     if ($instance == null) {
         $component = JRequest::getCmd('component');
         $table =& JTable::getInstance('component');
         $table->loadByOption($component);
         // work out file path
         if ($path = JRequest::getString('path')) {
             $path = JPath::clean(JPATH_SITE . DS . $path);
             JPath::check($path);
         } else {
             $option = preg_replace('#\\W#', '', $table->option);
             $path = JPATH_ADMINISTRATOR . DS . 'components' . DS . $option . DS . 'config.xml';
         }
         if (file_exists($path)) {
             $instance = new JParameter($table->params, $path);
         } else {
             $instance = new JParameter($table->params);
         }
     }
     return $instance;
 }
Esempio n. 13
0
 public function connector()
 {
     $application = JFactory::getApplication();
     $user = JFactory::getUser();
     if ($user->guest) {
         K2Response::throwError(JText::_('K2_YOU_ARE_NOT_AUTHORIZED_TO_PERFORM_THIS_OPERATION'), 403);
     }
     $params = JComponentHelper::getParams('com_media');
     $root = $params->get('file_path', 'media');
     $folder = $this->input->get('folder', $root, 'path');
     $type = $this->input->get('type', 'video', 'cmd');
     if (JString::trim($folder) == "") {
         $folder = $root;
     } else {
         // Ensure that we are always below the root directory
         if (strpos($folder, $root) !== 0) {
             $folder = $root;
         }
     }
     // Disable debug
     $this->input->set('debug', false);
     $url = JURI::root(true) . '/' . $folder;
     $path = JPATH_SITE . '/' . JPath::clean($folder);
     JPath::check($path);
     include_once JPATH_SITE . '/media/k2app/vendor/elfinder/php/elFinderConnector.class.php';
     include_once JPATH_SITE . '/media/k2app/vendor/elfinder/php/elFinder.class.php';
     include_once JPATH_SITE . '/media/k2app/vendor/elfinder/php/elFinderVolumeDriver.class.php';
     include_once JPATH_SITE . '/media/k2app/vendor/elfinder/php/elFinderVolumeLocalFileSystem.class.php';
     function access($attr, $path, $data, $volume)
     {
         $application = JFactory::getApplication();
         $ext = strtolower(JFile::getExt(basename($path)));
         if ($ext == 'php') {
             return true;
         }
         // Hide files and folders starting with .
         if (strpos(basename($path), '.') === 0 && $attr == 'hidden') {
             return true;
         }
         // Read only access for front-end. Full access for administration section.
         switch ($attr) {
             case 'read':
                 return true;
                 break;
             case 'write':
                 return $application->isSite() ? false : true;
                 break;
             case 'locked':
                 return $application->isSite() ? true : false;
                 break;
             case 'hidden':
                 return false;
                 break;
         }
     }
     if ($application->isAdmin()) {
         $permissions = array('read' => true, 'write' => true);
     } else {
         $permissions = array('read' => true, 'write' => false);
     }
     $options = array('roots' => array(array('driver' => 'LocalFileSystem', 'path' => $path, 'URL' => $url, 'accessControl' => 'access', 'defaults' => $permissions)));
     $connector = new elFinderConnector(new elFinder($options));
     $connector->run();
     return $this;
 }
Esempio n. 14
0
 /**
  * Checks for snooping outside of the file system root.
  *
  * @param   string  $path  A file system path to check.
  *
  * @return  string  A cleaned version of the path or exit on error.
  *
  * @throws  \Exception
  */
 public function pathCheck($path)
 {
     return \JPath::check($path);
 }
Esempio n. 15
0
 /**
  * Helper wrapper method for check
  *
  * @param   string  $path  A file system path to check.
  *
  * @return  string  A cleaned version of the path or exit on error.
  *
  * @see     JPath::check()
  * @since   3.4
  * @throws  Exception
  */
 public function check($path)
 {
     return JPath::check($path);
 }
Esempio n. 16
0
 function _savelanguage()
 {
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     $code = JRequest::getString('code');
     JRequest::setVar('code', $code);
     $content = JRequest::getVar('content', '', '', 'string', JREQUEST_ALLOWRAW);
     if (empty($code)) {
         return;
     }
     $content_override = JRequest::getVar('content_override', '', '', 'string', JREQUEST_ALLOWRAW);
     $folder = JLanguage::getLanguagePath(JPATH_ROOT) . DS . 'overrides';
     jimport('joomla.filesystem.folder');
     if (!JFolder::exists($folder)) {
         JFolder::create($folder);
     }
     if (JFolder::exists($folder)) {
         $path = $folder . DS . $code . '.override.ini';
         if (!JPath::check($path)) {
             hikashop_display(JText::sprintf('FAIL_SAVE', 'invalid filename'), 'error');
             return false;
         }
         $result = JFile::write($path, $content_override);
         if (!$result) {
             hikashop_display(JText::sprintf('FAIL_SAVE', $path), 'error');
         }
     }
     if (empty($content)) {
         return;
     }
     $path = JLanguage::getLanguagePath(JPATH_ROOT) . DS . $code . DS . $code . '.com_hikashop.ini';
     if (!JPath::check($path)) {
         hikashop_display(JText::sprintf('FAIL_SAVE', 'invalid filename'), 'error');
         return false;
     }
     $result = JFile::write($path, $content);
     if ($result) {
         hikashop_display(JText::_('HIKASHOP_SUCC_SAVED'), 'success');
         $updateHelper = hikashop_get('helper.update');
         $updateHelper->installMenu($code);
         $js = "window.top.document.getElementById('image{$code}').src = '" . HIKASHOP_IMAGES . "icons/icon-16-edit.png'";
         $doc = JFactory::getDocument();
         $doc->addScriptDeclaration($js);
     } else {
         hikashop_display(JText::sprintf('FAIL_SAVE', $path), 'error');
     }
     return $result;
 }
Esempio n. 17
0
 function displayassociate()
 {
     $path = JRequest::getVar('csv_path');
     $num = JRequest::getVar('current_filter');
     $cid = JRequest::getVar('cid', '');
     if (!JPath::check($path)) {
         echo JText::_('FILE_NOT_FOUND');
         return false;
     }
     if (!empty($cid)) {
         $massactionClass = hikashop_get('class.massaction');
         $params = $massactionClass->get($cid);
     }
     if (!empty($params->massaction_filters)) {
         if (!is_array($params->massaction_filters)) {
             $filters = unserialize($params->massaction_filters);
         } else {
             $filters = $params->massaction_filters;
         }
     } else {
         $filters = array();
     }
     $element = array();
     $element['path'] = $path;
     if (isset($filters[0]->data['change'])) {
         $changes = $filters[0]->data['change'];
         $element['change'] = $changes;
     }
     $massactionClass = hikashop_get('class.massaction');
     $data = $massactionClass->getFromFile($element, true);
     switch ($data->error) {
         case 'not_found':
             echo JText::_('FILE_NOT_FOUND');
             break;
         case 'fail_open':
             echo JText::_('HIKA_CANNOT_OPEN');
             break;
         case 'empty':
             echo JText::_('HIKA_EMPTY_FILE');
             break;
         case 'wrong_columns':
             if (isset($data->wrongColumns)) {
                 echo '<fieldset><legend>' . JText::_('SELECT_CORRESPONDING_COLUMNS') . '</legend>';
                 foreach ($data->wrongColumns as $wrongColumn) {
                     $changeColumn = $wrongColumn . ': ';
                     $changeColumn .= '<select class="chzn-done" id="productfilter' . $num . 'csvImport_pathType" name="filter[product][' . $num . '][csvImport][change][' . $wrongColumn . ']">';
                     $changeColumn .= '<option value="delete">' . JText::_('REMOVE') . '</option>';
                     foreach ($data->validColumns as $validColumn) {
                         if (isset($changes[$wrongColumn]) && $changes[$wrongColumn] == $validColumn) {
                             $selected = ' selected="selected" ';
                         } else {
                             $selected = '';
                         }
                         $changeColumn .= '<option value="' . $validColumn . '" ' . $selected . '>' . $validColumn . '</option>';
                     }
                     $changeColumn .= '</select><br/>';
                     echo $changeColumn;
                 }
                 echo '</fieldset>';
             }
             break;
         default:
             echo JText::_('HIKA_VALID_FILE');
             break;
     }
 }
Esempio n. 18
0
 /**
  * get the full server file path for the upload, including the file name i
  * @param int repeat group counter
  * @return string path
  */
 function _getFilePath($repeatCounter = 0)
 {
     if (!isset($this->_filePaths)) {
         $this->_filePaths = array();
     }
     if (array_key_exists($repeatCounter, $this->_filePaths)) {
         return $this->_filePaths[$repeatCounter];
     }
     $aData = JRequest::get('post');
     $elName = $this->getFullName(true, true, false);
     $elNameRaw = $elName . '_raw';
     $params = $this->getParams();
     //@TODO test with fileuploads in join groups
     $groupModel = $this->getGroup();
     if ($groupModel->isJoin()) {
         $joinid = $groupModel->getGroup()->join_id;
         $elNameNoJoinstr = $this->getFullName(false, true, false);
         if ($groupModel->canRepeat()) {
             //$myFileName = $_FILES['join']['name'][$joinid][$elNameNoJoinstr][$repeatCounter];
             $myFileName = array_key_exists('join', $_FILES) ? @$_FILES['join']['name'][$joinid][$elNameNoJoinstr][$repeatCounter] : @$_FILES['file']['name'];
             $myFileDir = JArrayHelper::getValue($aData['join'][$joinid][$elNameNoJoinstr], 'ul_end_dir', array());
             $myFileDir = JArrayHelper::getValue($myFileDir, $repeatCounter, '');
         } else {
             //$myFileName = $_FILES['join']['name'][$joinid][$elNameNoJoinstr];
             //@TODO test this:
             $myFileName = array_key_exists('join', $_FILES) ? @$_FILES['join']['name'][$joinid][$elNameNoJoinstr] : @$_FILES['file']['name'];
             $myFileDir = JArrayHelper::getValue($aData['join'][$joinid][$elNameNoJoinstr], 'ul_end_dir', '');
         }
     } else {
         if ($groupModel->canRepeat()) {
             //$myFileName   = @$_FILES[$elName]['name'][$repeatCounter];
             //@TODO test this:
             $myFileName = array_key_exists($elName, $_FILES) ? @$_FILES[$elName]['name'][$repeatCounter] : @$_FILES['file']['name'];
             $myFileDir = array_key_exists($elNameRaw, $aData) && is_array($aData[$elNameRaw]) ? @$aData[$elNameRaw]['ul_end_dir'][$repeatCounter] : '';
         } else {
             $myFileName = array_key_exists($elName, $_FILES) ? @$_FILES[$elName]['name'] : @$_FILES['file']['name'];
             $myFileDir = array_key_exists($elNameRaw, $aData) && is_array($aData[$elNameRaw]) ? @$aData[$elNameRaw]['ul_end_dir'] : '';
         }
     }
     $storage = $this->getStorage();
     // $$$ hugh - check if we need to blow away the cached filepath, set in validation
     $myFileName = $storage->cleanName($myFileName, $repeatCounter);
     $folder = $params->get('ul_directory');
     $folder = $folder . DS . $myFileDir;
     $folder = JPath::clean(JPATH_SITE . DS . $folder);
     $w = new FabrikWorker();
     $folder = $w->parseMessageForPlaceHolder($folder);
     JPath::check($folder);
     $storage->makeRecursiveFolders($folder);
     $p = $folder . DS . $myFileName;
     $this->_filePaths[$repeatCounter] = JPath::clean($p);
     return $this->_filePaths[$repeatCounter];
 }
Esempio n. 19
0
 /**
  * Adds to the search path for templates and resources.
  *
  * @param   string  $type  The path type (e.g. 'model', 'view').
  * @param   mixed   $path  The directory string  or stream array to search.
  *
  * @return  JController  A JController object to support chaining.
  *
  * @since   11.1
  * @note    Replaces _addPath.
  */
 protected function addPath($type, $path)
 {
     // Just force path to array
     settype($path, 'array');
     if (!isset($this->paths[$type])) {
         $this->paths[$type] = array();
     }
     // Loop through the path directories
     foreach ($path as $dir) {
         // No surrounding spaces allowed!
         $dir = rtrim(JPath::check($dir, '/'), '/') . '/';
         // Add to the top of the search dirs
         array_unshift($this->paths[$type], $dir);
     }
     return $this;
 }
Esempio n. 20
0
 function filebrowser($tpl = null)
 {
     $params =& JComponentHelper::getParams('com_media');
     $root = $params->get('file_path', 'media');
     $folder = JRequest::getVar('folder', $root, 'default', 'path');
     $type = JRequest::getCmd('type', 'image');
     if (JString::trim($folder) == "") {
         $folder = $root;
     }
     $path = JPATH_SITE . DS . JPath::clean($folder);
     JPath::check($path);
     if ($type == 'video') {
         $title = JText::_('Browse videos');
         $filter = '.wmv|avi|mp4|mpg|mpeg|flv|3gp|mov';
     } else {
         $title = JText::_('Browse images');
         $filter = '.jpg|png|gif|xcf|odg|bmp|jpeg';
     }
     if (JFolder::exists($path)) {
         $folderList = JFolder::folders($path);
         $filesList = JFolder::files($path, $filter);
     }
     if (!empty($folder) && $folder != $root) {
         $parent = substr($folder, 0, strrpos($folder, '/'));
     } else {
         $parent = $root;
     }
     $this->assignRef('folders', $folderList);
     $this->assignRef('files', $filesList);
     $this->assignRef('parent', $parent);
     $this->assignRef('path', $folder);
     $this->assignRef('type', $type);
     $this->assignRef('title', $title);
     $document =& JFactory::getDocument();
     $document->addStyleSheet(JURI::base() . 'components/com_media/assets/popup-imagelist.css');
     parent::display($tpl);
 }
Esempio n. 21
0
File: view.php Progetto: rodhoff/MNW
 function get($id, $default = null)
 {
     $parts = explode('|', $id);
     if (count($parts) != 6) {
         return false;
     }
     $obj = new stdClass();
     $obj->id = $id;
     $obj->client_id = (int) $parts[0];
     $obj->template = $parts[1];
     $obj->type = $parts[2];
     $obj->type_name = $parts[3];
     $obj->view = $parts[4];
     $obj->filename = $parts[5];
     if ($obj->type == 'plugin') {
         $obj->folder = rtrim(JPATH_PLUGINS, DS) . DS . $obj->type_name . DS;
     } else {
         if ($obj->type_name == HIKASHOP_COMPONENT) {
             switch ($obj->client_id) {
                 case 0:
                     $view = HIKASHOP_FRONT . 'views' . DS;
                     break;
                 case 1:
                     $view = HIKASHOP_BACK . 'views' . DS;
                     break;
                 default:
                     return false;
             }
         } else {
             $view = '';
             JPluginHelper::importPlugin('hikashop');
             $dispatcher = JDispatcher::getInstance();
             $pluginViews = array();
             $dispatcher->trigger('onViewsListingFilter', array(&$pluginViews, $obj->client_id));
             if (!empty($pluginViews)) {
                 foreach ($pluginViews as $pluginView) {
                     if ($pluginView['client_id'] == $obj->client_id && $pluginView['component'] == $obj->type_name) {
                         $view = $pluginView['view'];
                         $obj->type_pretty_name = $pluginView['name'];
                         break;
                     }
                 }
             }
             if (empty($view)) {
                 return false;
             }
         }
         $obj->folder = $view . $obj->view . DS . 'tmpl' . DS;
     }
     $obj->path = $obj->folder . $obj->filename;
     if (!JPath::check($obj->path) && HIKASHOP_J25) {
         return false;
     }
     $obj->file = substr($obj->filename, 0, strlen($obj->filename) - 4);
     $client = JApplicationHelper::getClientInfo($obj->client_id);
     $tBaseDir = $client->path . DS . 'templates';
     $templateFolder = $tBaseDir . DS . $obj->template . DS;
     $obj->override = $templateFolder . 'html' . DS . $obj->type_name . DS;
     if ($obj->type == 'component') {
         $obj->override .= $obj->view . DS;
     }
     $obj->override .= $obj->filename;
     $obj->overriden = false;
     if (file_exists($obj->override)) {
         $obj->overriden = true;
         $obj->edit = $obj->override;
     } else {
         $obj->edit = $obj->path;
     }
     return $obj;
 }
Esempio n. 22
0
 /**
  * 
  * File upload handler
  * 
  * @return string JSON response 
  */
 public function upload()
 {
     global $jlistConfig;
     $app = JFactory::getApplication();
     // 5 minutes execution time
     @set_time_limit(5 * 60);
     //enable valid json response when debugging is disabled
     if (!COM_MEDIAMU_DEBUG) {
         error_reporting(0);
     }
     $session = JFactory::getSession();
     $user = JFactory::getUser();
     $cleanupTargetDir = true;
     //remove old files
     $maxFileAge = 5 * 3600;
     // Temp file age in seconds
     //directory for file upload
     //$targetDirBase64  = $session->get('current_dir', null, 'com_jdownloads');
     //$targetDirDecoded  = base64_decode($jlistConfig['files.uploaddir']);
     $targetDirWithSep = $jlistConfig['files.uploaddir'] . DS;
     //check for snooping
     $targetDirCleaned = JPath::check($targetDirWithSep);
     //finally
     $targetDir = $targetDirCleaned;
     // Get parameters
     $chunk = $app->input->get('chunk', 0, 'request');
     $chunks = $app->input->get('chunks', 0, 'request');
     //current file name
     $fileNameFromReq = $app->input->get('name', '', 'request');
     // Clean the fileName for security reasons
     $fileName = JFile::makeSafe($fileNameFromReq);
     //check file extension
     $ext_images = $jlistConfig['plupload.image.file.extensions'];
     $ext_other = $jlistConfig['plupload.other.file.extensions'];
     //prepare extensions for validation
     $exts = $ext_images . ',' . $ext_other;
     $exts_lc = strtolower($exts);
     $exts_arr = explode(',', $exts_lc);
     //check token
     if (!$session->checkToken('request')) {
         $this->_setResponse(400, JText::_('JINVALID_TOKEN'));
     }
     //check user perms
     if (!$user->authorise('core.create', 'com_jdownloads')) {
         $this->_setResponse(400, JText::_('COM_JDOWNLOADS_ERROR_PERM_DENIDED'));
     }
     //directory check
     if (!file_exists($targetDir) && !is_dir($targetDir) && strpos(COM_MEDIAMU_BASE_ROOT, $targetDir) !== false) {
         $this->_setResponse(100, JText::_('COM_JDOWNLOADS_ERROR_UPLOAD_INVALID_PATH'));
     }
     //file type check
     if (!in_array(strtolower(JFile::getExt($fileName)), $exts_arr)) {
         $this->_setResponse(100, JText::_('COM_JDOWNLOADS_ERROR_UPLOAD_INVALID_FILE_EXTENSION'));
     }
     if (!in_array(JFile::getExt($fileName), $exts_arr)) {
         $this->_setResponse(100, JText::_('COM_JDOWNLOADS_ERROR_UPLOAD_INVALID_FILE_EXTENSION'));
     }
     // Make sure the fileName is unique but only if chunking is disabled
     if ($chunks < 2 && file_exists($targetDir . DS . $fileName)) {
         $ext = strrpos($fileName, '.');
         $fileName_a = substr($fileName, 0, $ext);
         $fileName_b = substr($fileName, $ext);
         $count = 1;
         while (file_exists($targetDir . DS . $fileName_a . '_' . $count . $fileName_b)) {
             $count++;
         }
         $fileName = $fileName_a . '_' . $count . $fileName_b;
     }
     $filePath = $targetDir . DS . $fileName;
     // Remove old temp files
     if ($cleanupTargetDir && ($dir = opendir($targetDir))) {
         while (($file = readdir($dir)) !== false) {
             $tmpfilePath = $targetDir . DS . $file;
             // Remove temp file if it is older than the max age and is not the current file
             if (preg_match('/\\.part$/', $file) && filemtime($tmpfilePath) < time() - $maxFileAge && $tmpfilePath != "{$filePath}.part") {
                 JFile::delete($tmpfilePath);
             }
         }
         closedir($dir);
     } else {
         $this->_setResponse(100, 'Failed to open temp directory.');
     }
     // Look for the content type header
     if (isset($_SERVER["HTTP_CONTENT_TYPE"])) {
         $contentType = $_SERVER["HTTP_CONTENT_TYPE"];
     }
     if (isset($_SERVER["CONTENT_TYPE"])) {
         $contentType = $_SERVER["CONTENT_TYPE"];
     }
     // Handle non multipart uploads older WebKit versions didn't support multipart in HTML5
     if (strpos($contentType, "multipart") !== false) {
         if (isset($_FILES['file']['tmp_name']) && is_uploaded_file($_FILES['file']['tmp_name'])) {
             // Open temp file
             $out = fopen("{$filePath}.part", $chunk == 0 ? "wb" : "ab");
             if ($out) {
                 // Read binary input stream and append it to temp file
                 $in = fopen($_FILES['file']['tmp_name'], "rb");
                 if ($in) {
                     while ($buff = fread($in, 4096)) {
                         fwrite($out, $buff);
                     }
                 } else {
                     $this->_setResponse(101, "Failed to open input stream.");
                 }
                 fclose($in);
                 fclose($out);
                 JFile::delete($_FILES['file']['tmp_name']);
             } else {
                 $this->_setResponse(102, "Failed to open output stream.");
             }
         } else {
             $this->_setResponse(103, "Failed to move uploaded file");
         }
     } else {
         // Open temp file
         $out = fopen("{$filePath}.part", $chunk == 0 ? "wb" : "ab");
         if ($out) {
             // Read binary input stream and append it to temp file
             $in = fopen("php://input", "rb");
             if ($in) {
                 while ($buff = fread($in, 4096)) {
                     fwrite($out, $buff);
                 }
             } else {
                 $this->_setResponse(101, "Failed to open input stream.");
             }
             fclose($in);
             fclose($out);
         } else {
             $this->_setResponse(102, "Failed to open output stream.");
         }
     }
     // Check if file has been uploaded
     if (!$chunks || $chunk == $chunks - 1) {
         // Strip the temp .part suffix off
         @rename("{$filePath}.part", $filePath);
     }
     $this->_setResponse(0, null, false);
 }
include_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sef' . DS . 'ajax.php';
defined('_JEXEC') or die('Restricted access');
JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sef' . DS . 'tables');
$controllerName = JRequest::getCmd('c', 'cp');
switch ($controllerName) {
    default:
        $controllerName = 'cp';
    case 'about':
    case 'alias':
        jimport('joomla.html.pagination');
        $init = new JPagination(0, 0, 0);
        $init = new JArrayHelper();
    case 'backup':
        jimport('joomla.filesystem.path');
        $init = JPath::check('');
    case 'config':
        jimport('joomla.cache.cache');
        $init = JCache::getInstance();
    case 'info':
    case 'logs':
        jimport('joomla.html.pagination');
        $init = new JPagination(0, 0, 0);
        $init = new JArrayHelper();
    case 'redirects':
        jimport('joomla.html.pagination');
        $init = new JPagination(0, 0, 0);
        $init = new JArrayHelper();
    case 'rss':
        jimport('simplepie.simplepie');
        $init = new SimplePie();
Esempio n. 24
0
 function connector()
 {
     $mainframe = JFactory::getApplication();
     $params = JComponentHelper::getParams('com_media');
     $root = $params->get('file_path', 'media');
     $folder = JRequest::getVar('folder', $root, 'default', 'path');
     $type = JRequest::getCmd('type', 'video');
     if (JString::trim($folder) == "") {
         $folder = $root;
     } else {
         // Ensure that we are always below the root directory
         if (strpos($folder, $root) !== 0) {
             $folder = $root;
         }
     }
     // Disable debug
     JRequest::setVar('debug', false);
     $url = JURI::root(true) . '/' . $folder;
     $path = JPATH_SITE . DS . JPath::clean($folder);
     JPath::check($path);
     include_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'lib' . DS . 'elfinder' . DS . 'elFinderConnector.class.php';
     include_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'lib' . DS . 'elfinder' . DS . 'elFinder.class.php';
     include_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'lib' . DS . 'elfinder' . DS . 'elFinderVolumeDriver.class.php';
     include_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'lib' . DS . 'elfinder' . DS . 'elFinderVolumeLocalFileSystem.class.php';
     function access($attr, $path, $data, $volume)
     {
         $mainframe = JFactory::getApplication();
         // Hide PHP files.
         $ext = strtolower(JFile::getExt(basename($path)));
         if ($ext == 'php') {
             return true;
         }
         // Hide files and folders starting with .
         if (strpos(basename($path), '.') === 0 && $attr == 'hidden') {
             return true;
         }
         // Read only access for front-end. Full access for administration section.
         switch ($attr) {
             case 'read':
                 return true;
                 break;
             case 'write':
                 return $mainframe->isSite() ? false : true;
                 break;
             case 'locked':
                 return $mainframe->isSite() ? true : false;
                 break;
             case 'hidden':
                 return false;
                 break;
         }
     }
     if ($mainframe->isAdmin()) {
         $permissions = array('read' => true, 'write' => true);
     } else {
         $permissions = array('read' => true, 'write' => false);
     }
     $options = array('debug' => false, 'roots' => array(array('driver' => 'LocalFileSystem', 'path' => $path, 'URL' => $url, 'accessControl' => 'access', 'defaults' => $permissions, 'uploadAllow' => array('image', 'video', 'audio', 'text/plain', 'text/html', 'application/json', 'application/pdf', 'application/zip', 'application/x-7z-compressed', 'application/x-bzip', 'application/x-bzip2', 'text/css', 'application/msword', 'application/vnd.ms-excel', 'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'), 'uploadOrder' => array('allow', 'deny'))));
     $connector = new elFinderConnector(new elFinder($options));
     $connector->run();
 }
Esempio n. 25
0
 /**
  * Get the full server file path for the upload, including the file name
  *
  * @param   int  $repeatCounter  Repeat group counter
  *
  * @return	string	Path
  */
 protected function _getFilePath($repeatCounter = 0)
 {
     $params = $this->getParams();
     if (!isset($this->_filePaths)) {
         $this->_filePaths = array();
     }
     if (array_key_exists($repeatCounter, $this->_filePaths)) {
         /*
          * $$$ hugh - if it uses element placeholders, there's a likelihood the element
          * data may have changed since we cached the path during validation, so we need
          * to rebuild it.  For instance, if the element data is changed by a onBeforeProcess
          * submission plugin, or by a 'replace' validation.
          */
         if (!FabrikString::usesElementPlaceholders($params->get('ul_directory'))) {
             return $this->_filePaths[$repeatCounter];
         }
     }
     $filter = JFilterInput::getInstance();
     $aData = $filter->clean($_POST, 'array');
     $elName = $this->getFullName(true, false);
     $elNameRaw = $elName . '_raw';
     /**
      * $$$ hugh - if we use the @ way of doing this, and one of the array keys doesn't exist,
      * PHP still sets an error, even though it doesn't toss it.  So if we then have some eval'd
      * code, like a PHP validation, and do the logError() thing, that will pick up and report this error,
      * and fail the validation.  Which is VERY hard to track.  So we'll have to do it long hand.
      */
     // $myFileName = array_key_exists($elName, $_FILES) ? @$_FILES[$elName]['name'] : @$_FILES['file']['name'];
     $myFileName = '';
     if (array_key_exists($elName, $_FILES) && is_array($_FILES[$elName])) {
         $myFileName = FArrayHelper::getValue($_FILES[$elName], 'name', '');
     } else {
         if (array_key_exists('file', $_FILES) && is_array($_FILES['file'])) {
             $myFileName = FArrayHelper::getValue($_FILES['file'], 'name', '');
         }
     }
     if (is_array($myFileName)) {
         $myFileName = FArrayHelper::getValue($myFileName, $repeatCounter, '');
     }
     $myFileDir = array_key_exists($elNameRaw, $aData) && is_array($aData[$elNameRaw]) ? @$aData[$elNameRaw]['ul_end_dir'] : '';
     if (is_array($myFileDir)) {
         $myFileDir = FArrayHelper::getValue($myFileDir, $repeatCounter, '');
     }
     $storage = $this->getStorage();
     // $$$ hugh - check if we need to blow away the cached filepath, set in validation
     $myFileName = $storage->cleanName($myFileName, $repeatCounter);
     $folder = $params->get('ul_directory');
     $folder = $folder . '/' . $myFileDir;
     if ($storage->appendServerPath()) {
         $folder = JPATH_SITE . '/' . $folder;
     }
     $folder = JPath::clean($folder);
     $w = new FabrikWorker();
     $formModel = $this->getFormModel();
     $folder = $w->parseMessageForRepeats($folder, $formModel->formData, $this, $repeatCounter);
     $folder = $w->parseMessageForPlaceHolder($folder);
     if ($storage->appendServerPath()) {
         JPath::check($folder);
     }
     $storage->makeRecursiveFolders($folder);
     $p = $folder . '/' . $myFileName;
     $this->_filePaths[$repeatCounter] = JPath::clean($p);
     return $this->_filePaths[$repeatCounter];
 }
Esempio n. 26
0
function jdGetDirectory($callback, $folder, $getFiles = false, $filter = '*')
{
    jimport('joomla.filesystem.file');
    jimport('joomla.filesystem.file');
    $folder = JPath::clean(JPATH_ROOT . DS . $folder);
    JPath::check($folder);
    $response = new XajaxResponse();
    if (!is_dir($folder)) {
        return $response;
    }
    $result = array();
    $dirs = JFolder::folders($folder, '', false, true);
    foreach ($dirs as $dir) {
        $dirData = array();
        $dirData['permission'] = substr(sprintf("%o", fileperms($dir)), -3);
        if ($getFiles) {
            $fileData = array();
            $files = glob($folder . DS . $filter);
            foreach ($files as $f) {
                $fileData[$f]['permission'] = substr(sprintf("%o", fileperms($f)), -3);
            }
        }
        $result[$dir]['info'] = $dirData;
        $result[$dir]['files'] = $fileData;
    }
    $response->script($callback . '(' . JHTMLBehavior::_getJSObject($result) . ')');
    return $response;
}
Esempio n. 27
0
 /**
  * Shows avatar in user extended profile (not in registration/change user data form)
  * process fields from plugin settings that have type "avatar"
  *
  * @return string (of html tags)
  */
 public static function avInProfile($link)
 {
     if ($link) {
         $file = JPATH_SITE . '/' . $link;
         jimport('joomla.filesystem.path');
         JPath::check($file);
         if (!file_exists($file)) {
             $link = "";
         } else {
             $linkLarge = trim(str_replace('/thumb', '/large', $link));
         }
     }
     if (!$link) {
         $link = self::$noavatar;
         $v1arr = '<img class="avatar" class="avInProfile" src="' . JURI::root() . $link . '">';
     } else {
         $v1arr = '<img class="hasTooltip avatar" class="avInProfile" src="' . JURI::root() . $link . '"title="<img src=\'' . JURI::root() . $linkLarge . '\'>">';
     }
     return $v1arr;
 }
Esempio n. 28
0
 /**
  * Method to initialize the language depended image (flag) browser
  * The browser is initialized with the default root path based on the Joomfish configuration
  * @param $tpl
  */
 public function filebrowser($tpl = null)
 {
     $document = JFactory::getDocument();
     $livesite = JURI::base();
     $document->addStyleSheet($livesite . 'components/com_joomfish/assets/css/joomfish.css');
     $document->addStyleSheet(JURI::root(true) . '/media/media/css/popup-imagelist.css');
     JHtml::_('behavior.modal');
     JHTML::script('com_joomfish/joomfish.mootools.js', true, true);
     $jfManager = JoomFishManager::getInstance();
     $root = $jfManager->getCfg('directory_flags');
     $current = JRequest::getVar('current', '');
     if ($current != '') {
         $root = dirname($current);
     }
     // remove leading / in case it exists
     $root = preg_replace('/^\\/(.*)/', "\$1", $root);
     $flagField = JRequest::getVar('flagField', '');
     $folder = JRequest::getVar('folder', $root, 'default', 'path');
     $type = JRequest::getCmd('type', 'image');
     if (JString::trim($folder) == "") {
         $path = JPATH_SITE . DS . JPath::clean('/');
     } else {
         $path = JPATH_SITE . DS . JPath::clean($folder);
     }
     JPath::check($path);
     $title = JText::_('BROWSE_LANGUAGE_FLAGS');
     $filter = '.jpg|png|gif|xcf|odg|bmp|jpeg';
     if (JFolder::exists($path)) {
         $folderList = JFolder::folders($path);
         $filesList = JFolder::files($path, $filter);
     }
     if (!empty($folder)) {
         $parent = substr($folder, 0, strrpos($folder, '/'));
     } else {
         $parent = '';
     }
     $this->assignRef('folders', $folderList);
     $this->assignRef('files', $filesList);
     $this->assignRef('parent', $parent);
     $this->assignRef('path', $folder);
     $this->assignRef('type', $type);
     $this->assignRef('title', $title);
     $this->assignRef('flagField', $flagField);
     parent::display($tpl);
 }
Esempio n. 29
0
 /**
  * Method to get a single record.
  *
  * @return  mixed  Object on success, false on failure.
  *
  * @since   1.6
  */
 public function &getSource()
 {
     $app = JFactory::getApplication();
     $item = new stdClass();
     if (!$this->template) {
         $this->getTemplate();
     }
     if ($this->template) {
         $input = JFactory::getApplication()->input;
         $fileName = base64_decode($input->get('file'));
         $client = JApplicationHelper::getClientInfo($this->template->client_id);
         try {
             $filePath = JPath::check($client->path . '/templates/' . $this->template->element . '/' . $fileName);
         } catch (Exception $e) {
             $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_SOURCE_FILE_NOT_FOUND'), 'error');
             return;
         }
         if (file_exists($filePath)) {
             $item->extension_id = $this->getState('extension.id');
             $item->filename = $fileName;
             $item->source = file_get_contents($filePath);
         } else {
             $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_SOURCE_FILE_NOT_FOUND'), 'error');
         }
     }
     return $item;
 }
Esempio n. 30
0
 /**
  *  method to display the filebrowser
  *  taken from K2 (administrator/components/com_k2/views/item/view.html.php)
  * @version		$Id: view.html.php 549 2010-08-30 15:39:45Z lefteris.kavadas $
  * @package		K2
  * @author		JoomlaWorks http://www.joomlaworks.gr
  * @copyright	Copyright (c) 2006 - 2010 JoomlaWorks, a business unit of Nuevvo Webware Ltd. All rights reserved.
  * @license		GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
  *  modified by Artur Neumann http://www.individual-it.net for the use with K2Import
  **/
 function filebrowser($tpl = null)
 {
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         JHtml::_('behavior.framework', true);
     }
     $document =& JFactory::getDocument();
     $document->addScript('components/com_k2import/js/k2import.mootools.js');
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         $document->addStyleSheet('../media/media/css/popup-imagelist.css');
     } else {
         $document->addStyleSheet(JURI::base() . 'components/com_media/assets/popup-imagelist.css');
     }
     $params =& JComponentHelper::getParams('com_media');
     $root = '/';
     $folder = JRequest::getVar('folder', $root, 'default', 'path');
     if (JString::trim($folder) == "") {
         $folder = $root;
     }
     $path = JPATH_SITE . DS . JPath::clean($folder);
     JPath::check($path);
     $title = JText::_('Browse Import-files (*.csv, *.gz, *.zip, *.bz2)');
     $filter = '.csv|gz|zip|bz2';
     if (JFolder::exists($path)) {
         $folderList = JFolder::folders($path);
         $filesList = JFolder::files($path, $filter);
     }
     if (!empty($folder) && $folder != $root) {
         $parent = substr($folder, 0, strrpos($folder, '/'));
     } else {
         $parent = $root;
     }
     if ($folder == '/') {
         $folder = '';
     }
     $this->assignRef('folders', $folderList);
     $this->assignRef('files', $filesList);
     $this->assignRef('parent', $parent);
     $this->assignRef('path', $folder);
     $this->assignRef('type', $type);
     $this->assignRef('title', $title);
     parent::display($tpl);
 }