예제 #1
0
파일: media.php 프로젝트: SeventF/ikea.com
 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();
 }
예제 #2
0
 function onAfterK2Save(&$item, $isNew)
 {
     jimport('joomla.filesystem.folder');
     JLoader::register('SigProHelper', JPATH_ADMINISTRATOR . '/components/com_sigpro/helper.php');
     $path = SigProHelper::getPath('k2');
     $folder = JRequest::getCmd('sigProFolder');
     if ($isNew && $folder && $folder != $item->id && JFolder::exists($path . '/' . $folder)) {
         JFolder::move($path . '/' . $folder, $path . '/' . $item->id);
     }
     if (JFolder::exists($path . '/' . $item->id) && $item->gallery == null) {
         $item->gallery = '{gallery}' . $item->id . '{/gallery}';
         $item->store();
     }
 }
예제 #3
0
 public function display($tpl = null)
 {
     $info = array();
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         $info['plg_content_sigpro'] = JFile::exists(JPATH_PLUGINS . '/content/jw_sigpro/jw_sigpro.php');
         $info['plg_k2_sigpro'] = JFile::exists(JPATH_PLUGINS . '/k2/jw_sigpro/jw_sigpro.php');
         $info['plg_editors-xtd_sigpro'] = JFile::exists(JPATH_PLUGINS . '/editors-xtd/jw_sigpro/jw_sigpro.php');
     } else {
         $info['plg_content_sigpro'] = JFile::exists(JPATH_PLUGINS . '/content/jw_sigpro.php');
         $info['plg_k2_sigpro'] = JFile::exists(JPATH_PLUGINS . '/k2/jw_sigpro.php');
         $info['plg_editors-xtd_sigpro'] = JFile::exists(JPATH_PLUGINS . '/editors-xtd/jw_sigpro.php');
     }
     $info['plg_content_sigpro_enabled'] = JPluginHelper::isEnabled('content', 'jw_sigpro');
     $info['plg_k2_sigpro_enabled'] = JPluginHelper::isEnabled('k2', 'jw_sigpro');
     $info['plg_editors-xtd_sigpro_enabled'] = JPluginHelper::isEnabled('editors-xtd', 'jw_sigpro');
     $info['php'] = phpversion();
     if (extension_loaded('gd')) {
         $gdinfo = gd_info();
         $info['gd'] = $gdinfo["GD Version"];
     } else {
         $info['gd'] = false;
     }
     $info['upload'] = ini_get('upload_max_filesize');
     $info['memory'] = ini_get('memory_limit');
     $info['permissions'] = array();
     $info['permissions']['cache'] = is_writable(JPATH_SITE . '/cache');
     if (file_exists(JPATH_SITE . '/cache/jw_sigpro')) {
         $info['permissions']['cache/jw_sigpro'] = is_writable(JPATH_SITE . '/cache/jw_sigpro');
     }
     if (file_exists(JPATH_SITE . '/media/jw_sigpro/users')) {
         $info['permissions']['media/jw_sigpro/users'] = is_writable(JPATH_SITE . '/media/jw_sigpro/users');
     }
     $params = JComponentHelper::getParams('com_sigpro');
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         $defaultImagePath = 'images';
     } else {
         $defaultImagePath = 'images/stories';
     }
     $path = $params->get('galleries_rootfolder', $defaultImagePath);
     if ($path) {
         $info['permissions'][$path] = is_writable(SigProHelper::getPath('site'));
     }
     $K2Path = SigProHelper::getPath('k2');
     if (JFolder::exists($K2Path)) {
         $info['permissions']['media/k2/galleries'] = is_writable($K2Path);
     }
     $this->assignRef('info', $info);
     parent::display($tpl);
 }
예제 #4
0
 public function validate()
 {
     jimport('joomla.filesystem.folder');
     $type = $this->getState('type');
     $path = SigProHelper::getPath($type);
     $folder = $this->getState('folder');
     $response = new stdClass();
     $response->status = 0;
     $response->message = '';
     if (JString::trim($folder) == '') {
         $response->status = 0;
         $response->message = JText::_('COM_SIGPRO_INVALID_FOLDER_NAME');
     } else {
         if (JFolder::exists($path . '/' . $folder)) {
             $response->status = 0;
             $response->message = JText::_('COM_SIGPRO_FOLDER_ALREADY_EXISTS');
         } else {
             $response->status = 1;
             $response->message = JText::_('COM_SIGPRO_FOLDER_DOES_NOT_EXIST');
         }
     }
     return $response;
 }
예제 #5
0
 public function delete()
 {
     $db = JFactory::getDBO();
     $path = SigProHelper::getPath($this->getState('type', 'site'));
     $folders = $this->getState('folders', array());
     foreach ($folders as $folder) {
         $folder = SigProHelper::cleanPath($folder);
         $folder = JString::str_ireplace(DIRECTORY_SEPARATOR, '', $folder);
         if ($folder && JFolder::exists($path . '/' . $folder)) {
             JFolder::delete($path . '/' . $folder);
             if ($this->getState('type') == 'k2') {
                 $db->setQuery("UPDATE #__k2_items SET gallery = '' WHERE id = " . (int) $folder);
                 $db->query();
             }
         }
     }
     return true;
 }