Esempio n. 1
0
 /**
  * Upload files and attach them to an issue or a comment.
  *
  * @param   array  $files      Array containing the uploaded files.
  * @param   int    $issueId    ID of the issue/comment where to attach the files.
  * @param   int    $commentId  One of 'issue' or 'comment', indicating if the files should be attached to an issue or a comment.
  *
  * @return  boolean   True on success, false otherwise.
  */
 public function upload($files, $issueId, $commentId = null)
 {
     if (!$issueId || !is_array($files)) {
         return false;
     }
     jimport('joomla.filesystem.file');
     if ($commentId) {
         $type = 'comment';
         $id = $commentId;
     } else {
         $type = 'issue';
         $id = $issueId;
     }
     foreach ($files as $file) {
         $rand = MonitorHelper::genRandHash();
         $pathParts = array($type, $id, $rand . '-' . $file[0]['name']);
         $path = JPath::clean(implode(DIRECTORY_SEPARATOR, $pathParts));
         $values = array('issue_id' => $issueId, 'comment_id' => $commentId, 'path' => $path, 'name' => $file[0]['name']);
         if (!JFile::upload($file[0]['tmp_name'], $this->pathPrefix . $path)) {
             JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_MONITOR_ATTACHMENT_UPLOAD_FAILED', $file[0]['name']));
             return false;
         }
         $query = $this->db->getQuery(true);
         $query->insert('#__monitor_attachments')->set(MonitorHelper::sqlValues($values, $query));
         $this->db->setQuery($query);
         if ($this->db->execute() === false) {
             return false;
         }
     }
     return true;
 }
Esempio n. 2
0
 /**
  * 
  * Enter description here ...
  * @param JForm $form
  * @param unknown $data
  */
 function onContentPrepareForm($form, $data)
 {
     $app = JFactory::getApplication();
     $doc = JFactory::getDocument();
     $this->template = $this->getTemplateName();
     if ($this->template && ($app->isAdmin() && $form->getName() == 'com_templates.style' || $app->isSite() && ($form->getName() == 'com_config.templates' || $form->getName() == 'com_templates.style'))) {
         jimport('joomla.filesystem.path');
         //JForm::addFormPath( dirname(__FILE__) . DS. 'includes' . DS .'assets' . DS . 'admin' . DS . 'params');
         $plg_file = JPath::find(dirname(__FILE__) . DS . 'includes' . DS . 'assets' . DS . 'admin' . DS . 'params', 'template.xml');
         $tpl_file = JPath::find(JPATH_ROOT . DS . 'templates' . DS . $this->template, 'templateDetails.xml');
         if (!$plg_file) {
             return false;
         }
         if ($tpl_file) {
             $form->loadFile($plg_file, false, '//form');
             $form->loadFile($tpl_file, false, '//config');
         } else {
             $form->loadFile($plg_file, false, '//form');
         }
         if ($app->isSite()) {
             $jmstorage_fields = $form->getFieldset('jmstorage');
             foreach ($jmstorage_fields as $name => $field) {
                 $form->removeField($name, 'params');
             }
             $form->removeField('config', 'params');
         }
         if ($app->isAdmin()) {
             $doc->addStyleDeclaration('#jm-ef3plugin-info, .jm-row > .jm-notice {display: none !important;}');
         }
     }
 }
Esempio n. 3
0
/**
 * Disables the unsupported eAccelerator caching method, replacing it with the
 * "file" caching method.
 *
 * @return  void
 *
 * @since   3.2
 */
function admin_postinstall_eaccelerator_action()
{
    $prev = new JConfig();
    $prev = JArrayHelper::fromObject($prev);
    $data = array('cacheHandler' => 'file');
    $data = array_merge($prev, $data);
    $config = new Registry('config');
    $config->loadArray($data);
    jimport('joomla.filesystem.path');
    jimport('joomla.filesystem.file');
    // Set the configuration file path.
    $file = JPATH_CONFIGURATION . '/configuration.php';
    // Get the new FTP credentials.
    $ftp = JClientHelper::getCredentials('ftp', true);
    // Attempt to make the file writeable if using FTP.
    if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0644')) {
        JError::raiseNotice('SOME_ERROR_CODE', JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTWRITABLE'));
    }
    // Attempt to write the configuration file as a PHP class named JConfig.
    $configuration = $config->toString('PHP', array('class' => 'JConfig', 'closingtag' => false));
    if (!JFile::write($file, $configuration)) {
        JFactory::getApplication()->enqueueMessage(JText::_('COM_CONFIG_ERROR_WRITE_FAILED'), 'error');
        return;
    }
    // Attempt to make the file unwriteable if using FTP.
    if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0444')) {
        JError::raiseNotice('SOME_ERROR_CODE', JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTUNWRITABLE'));
    }
}
Esempio n. 4
0
 /**
  * Retrieve path to file in hard disk based from file URL
  *
  * @param   string  $file  URL to the file
  * @return  string
  */
 public static function getFilePath($file)
 {
     // Located file from root
     if (strpos($file, '/') === 0) {
         if (file_exists($tmp = realpath(str_replace(JUri::root(true), JPATH_ROOT, $file)))) {
             return $tmp;
         } elseif (file_exists($tmp = realpath($_SERVER['DOCUMENT_ROOT'] . '/' . $file))) {
             return $tmp;
         } elseif (file_exists($tmp = realpath(JPATH_ROOT . '/' . $file))) {
             return $tmp;
         }
     }
     if (strpos($file, '://') !== false && JURI::isInternal($file)) {
         $path = parse_url($file, PHP_URL_PATH);
         if (file_exists($tmp = realpath($_SERVER['DOCUMENT_ROOT'] . '/' . $path))) {
             return $tmp;
         } elseif (file_exists($tmp = realpath(JPATH_ROOT . '/' . $path))) {
             return $tmp;
         }
     }
     $rootURL = JUri::root();
     $currentURL = JUri::current();
     $currentPath = JPATH_ROOT . '/' . substr($currentURL, strlen($rootURL));
     $currentPath = str_replace(DIRECTORY_SEPARATOR, '/', $currentPath);
     $currentPath = dirname($currentPath);
     return JPath::clean($currentPath . '/' . $file);
 }
Esempio n. 5
0
 /**
  * Extract a ZIP compressed file to a given path
  *
  * @access	public
  * @param	string	$archive		Path to ZIP archive to extract
  * @param	string	$destination	Path to extract archive into
  * @param	array	$options		Extraction options [unused]
  * @return	boolean	True if successful
  * @since	1.5
  */
 function extract($archive, $destination, $options = array())
 {
     // Initialize variables
     $this->_data = null;
     $this->_metadata = null;
     if (!($this->_data = JFile::read($archive))) {
         $this->set('error.message', 'Unable to read archive');
         return JError::raiseWarning(100, $this->get('error.message'));
     }
     if (!$this->_getTarInfo($this->_data)) {
         return JError::raiseWarning(100, $this->get('error.message'));
     }
     for ($i = 0, $n = count($this->_metadata); $i < $n; $i++) {
         $type = strtolower($this->_metadata[$i]['type']);
         if ($type == 'file' || $type == 'unix file') {
             $buffer = $this->_metadata[$i]['data'];
             $path = JPath::clean($destination . DS . $this->_metadata[$i]['name']);
             // Make sure the destination folder exists
             if (!JFolder::create(dirname($path))) {
                 $this->set('error.message', 'Unable to create destination');
                 return JError::raiseWarning(100, $this->get('error.message'));
             }
             if (JFile::write($path, $buffer) === false) {
                 $this->set('error.message', 'Unable to write entry');
                 return JError::raiseWarning(100, $this->get('error.message'));
             }
         }
     }
     return true;
 }
Esempio n. 6
0
 /**
  * Method to get a list of all the files to edit in a template.
  *
  * @return	array	A nested array of relevant files.
  * @since	1.6
  */
 public function getFiles()
 {
     // Initialise variables.
     $result = array();
     if ($template = $this->getTemplate()) {
         jimport('joomla.filesystem.folder');
         $client = JApplicationHelper::getClientInfo($template->client_id);
         $path = JPath::clean($client->path . '/templates/' . $template->element . '/');
         $lang = JFactory::getLanguage();
         // Load the core and/or local language file(s).
         $lang->load('tpl_' . $template->element, $client->path, null, false, false) || $lang->load('tpl_' . $template->element, $client->path . '/templates/' . $template->element, null, false, false) || $lang->load('tpl_' . $template->element, $client->path, $lang->getDefault(), false, false) || $lang->load('tpl_' . $template->element, $client->path . '/templates/' . $template->element, $lang->getDefault(), false, false);
         // Check if the template path exists.
         if (is_dir($path)) {
             $result['main'] = array();
             $result['css'] = array();
             $result['clo'] = array();
             $result['mlo'] = array();
             $result['html'] = array();
             // Handle the main PHP files.
             $result['main']['index'] = $this->getFile($path, 'index.php');
             $result['main']['error'] = $this->getFile($path, 'error.php');
             $result['main']['print'] = $this->getFile($path, 'component.php');
             $result['main']['offline'] = $this->getFile($path, 'offline.php');
             // Handle the CSS files.
             $files = JFolder::files($path . '/css', '\\.css$', false, false);
             foreach ($files as $file) {
                 $result['css'][] = $this->getFile($path . '/css/', 'css/' . $file);
             }
         } else {
             $this->setError(JText::_('COM_TEMPLATES_ERROR_TEMPLATE_FOLDER_NOT_FOUND'));
             return false;
         }
     }
     return $result;
 }
Esempio n. 7
0
 public function setupTheme()
 {
     // Load our CSS and Javascript files
     if (!$this->isJFBConnectInstalled) {
         $this->doc->addStyleSheet(JURI::base(true) . '/media/sourcecoast/css/sc_bootstrap.css');
     }
     $this->doc->addStyleSheet(JURI::base(true) . '/media/sourcecoast/css/common.css');
     $paths = array();
     $paths[] = JPATH_ROOT . '/templates/' . JFactory::getApplication()->getTemplate() . '/html/mod_sclogin/themes/';
     $paths[] = JPATH_ROOT . '/media/sourcecoast/themes/sclogin/';
     $theme = $this->params->get('theme', 'default.css');
     $file = JPath::find($paths, $theme);
     $file = str_replace(JPATH_SITE, '', $file);
     $file = str_replace('\\', "/", $file);
     //Windows support for file separators
     $this->doc->addStyleSheet(JURI::base(true) . $file);
     // Add placeholder Javascript for old browsers that don't support the placeholder field
     if ($this->user->guest) {
         jimport('joomla.environment.browser');
         $browser = JBrowser::getInstance();
         $browserType = $browser->getBrowser();
         $browserVersion = $browser->getMajor();
         if ($browserType == 'msie' && $browserVersion <= 9) {
             // Using addCustomTag to ensure this is the last section added to the head, which ensures that jfbcJQuery has been defined
             $this->doc->addCustomTag('<script src="' . JURI::base(true) . '/media/sourcecoast/js/jquery.placeholder.js" type="text/javascript"> </script>');
             $this->doc->addCustomTag("<script>jfbcJQuery(document).ready(function() { jfbcJQuery('input').placeholder(); });</script>");
         }
     }
 }
Esempio n. 8
0
 function getInput()
 {
     $lang = JFactory::getLanguage();
     $extension = "com_joomleague";
     $source = JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $extension);
     $lang->load($extension, JPATH_ADMINISTRATOR, null, false, false) || $lang->load($extension, $source, null, false, false) || $lang->load($extension, JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load($extension, $source, $lang->getDefault(), false, false);
     $mitems = array();
     $mitems[] = JHtml::_('select.option', 0, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_FIRST_NICK_LAST'));
     $mitems[] = JHtml::_('select.option', 1, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_LAST_NICK_FIRST'));
     $mitems[] = JHtml::_('select.option', 2, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_LAST_FIRST_NICK'));
     $mitems[] = JHtml::_('select.option', 3, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_FIRST_LAST'));
     $mitems[] = JHtml::_('select.option', 4, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_LAST_FIRST'));
     $mitems[] = JHtml::_('select.option', 5, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_NICK_FIRST_LAST'));
     $mitems[] = JHtml::_('select.option', 6, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_NICK_LAST_FIRST'));
     $mitems[] = JHtml::_('select.option', 7, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_FIRST_LAST_NICK'));
     $mitems[] = JHtml::_('select.option', 8, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_FIRST_LAST2'));
     $mitems[] = JHtml::_('select.option', 9, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_LAST_FIRST2'));
     $mitems[] = JHtml::_('select.option', 10, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_LAST'));
     $mitems[] = JHtml::_('select.option', 11, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_FIRST_NICK_LAST2'));
     $mitems[] = JHtml::_('select.option', 12, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_NICK'));
     $mitems[] = JHtml::_('select.option', 13, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_FIRST_LAST3'));
     $mitems[] = JHtml::_('select.option', 14, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_LAST2_FIRST'));
     $mitems[] = JHtml::_('select.option', 15, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_LAST_NEWLINE_FIRST'));
     $mitems[] = JHtml::_('select.option', 16, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_FIRST_NEWLINE_LAST'));
     $mitems[] = JHtml::_('select.option', 17, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_LAST_FIRST_NICK'));
     $mitems[] = JHtml::_('select.option', 18, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_LAST_FIRSTNAME_FIRST_CHAR_DOT'));
     $output = JHtml::_('select.genericlist', $mitems, $this->name, 'class="inputbox" size="1"', 'value', 'text', $this->value, $this->id);
     return $output;
 }
 /**
  * Pre-processor for $table->delete($pk)
  *
  * @param   mixed $pk An optional primary key value to delete.  If not set the instance property value is used.
  *
  * @return  void
  *
  * @since   3.1.2
  * @throws  UnexpectedValueException
  */
 public function onAfterDelete($pk)
 {
     $params = JComponentHelper::getParams('com_gamification');
     /** @var  $params Joomla\Registry\Registry */
     $filesystemHelper = new Prism\Filesystem\Helper($params);
     $mediaFolder = $filesystemHelper->getMediaFolder();
     if ($this->table->get('image') !== null and $this->table->get('image') !== '') {
         $file = JPath::clean(JPATH_ROOT . DIRECTORY_SEPARATOR . $mediaFolder . DIRECTORY_SEPARATOR . $this->table->get('image'));
         if (JFile::exists($file)) {
             JFile::delete($file);
         }
     }
     if ($this->table->get('image_small') !== null and $this->table->get('image_small') !== '') {
         $file = JPath::clean(JPATH_ROOT . DIRECTORY_SEPARATOR . $mediaFolder . DIRECTORY_SEPARATOR . $this->table->get('image_small'));
         if (JFile::exists($file)) {
             JFile::delete($file);
         }
     }
     if ($this->table->get('image_square') !== null and $this->table->get('image_square') !== '') {
         $file = JPath::clean(JPATH_ROOT . DIRECTORY_SEPARATOR . $mediaFolder . DIRECTORY_SEPARATOR . $this->table->get('image_square'));
         if (JFile::exists($file)) {
             JFile::delete($file);
         }
     }
 }
Esempio n. 10
0
 /**
  * Returns a reference to the a Table object, always creating it
  *
  * @param type 		$type 	 The table type to instantiate
  * @param string 	$prefix	 A prefix for the table class name. Optional.
  * @param array		$options Configuration array for model. Optional.
  * @return database A database object
  * @since 1.5
  */
 function &getInstance($type, $prefix = 'JTable', $config = array())
 {
     $false = false;
     $type = preg_replace('/[^A-Z0-9_\\.-]/i', '', $type);
     $tableClass = $prefix . ucfirst($type);
     if (!class_exists($tableClass)) {
         jimport('joomla.filesystem.path');
         if ($path = JPath::find(JTable::addIncludePath(), strtolower($type) . '.php')) {
             require_once $path;
             if (!class_exists($tableClass)) {
                 JError::raiseWarning(0, 'Table class ' . $tableClass . ' not found in file.');
                 return $false;
             }
         } else {
             JError::raiseWarning(0, 'Table ' . $type . ' not supported. File not found.');
             return $false;
         }
     }
     //Make sure we are returning a DBO object
     if (array_key_exists('dbo', $config)) {
         $db =& $config['dbo'];
     } else {
         $db =& JFactory::getDBO();
     }
     $instance = new $tableClass($db);
     //$instance->setDBO($db);
     return $instance;
 }
Esempio n. 11
0
 public function downloadLangInstaller($resources, $language)
 {
     // check tmp
     if ($warning = $this->app->zlfw->path->checkSystemPaths()) {
         $response['success'] = false;
         $response['errors'][] = $warning;
         echo json_encode($response);
         jexit();
     }
     $this->_initCheck();
     // set default file name
     $filename = $language . '.' . (count($resources) > 1 ? 'language_pack' : $resources[0]) . '.zip';
     // set url
     $url = self::$apiUrl . 'getLangInstaller&resources=' . implode(',', $resources) . '&language=' . $language;
     // attempt to override file name with one from header response
     $headers = get_headers($url, 1);
     if (isset($headers['Content-Disposition'])) {
         if (preg_match('/name="(?P<filename>.+?)"/', $headers['Content-Disposition'], $matches)) {
             $filename = $matches['filename'];
         }
     }
     // set file destination
     $file = JPath::clean(JPATH_SITE . '/tmp/' . $filename);
     // download
     $result = $this->app->zl->extensions->download($url, $file);
     return $file;
 }
Esempio n. 12
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. 13
0
 /**
  * Remove an extra image from database and file system.
  *
  * <code>
  * $imageId = 1;
  * $imagesFolder = "/.../folder";
  *
  * $image   = new CrowdFundingImageRemoverExtra(JFactory::getDbo(), $image, $imagesFolder);
  * $image->remove();
  * </code>
  */
 public function remove()
 {
     // Get the image
     $query = $this->db->getQuery(true);
     $query->select("a.image, a.thumb")->from($this->db->quoteName("#__crowdf_images", "a"))->where("a.id = " . (int) $this->imageId);
     $this->db->setQuery($query);
     $row = $this->db->loadObject();
     if (!empty($row)) {
         // Remove the image from the filesystem
         $file = JPath::clean($this->imagesFolder . DIRECTORY_SEPARATOR . $row->image);
         if (JFile::exists($file)) {
             JFile::delete($file);
         }
         // Remove the thumbnail from the filesystem
         $file = JPath::clean($this->imagesFolder . DIRECTORY_SEPARATOR . $row->thumb);
         if (JFile::exists($file)) {
             JFile::delete($file);
         }
         // Delete the record
         $query = $this->db->getQuery(true);
         $query->delete($this->db->quoteName("#__crowdf_images"))->where($this->db->quoteName("id") . " = " . (int) $this->imageId);
         $this->db->setQuery($query);
         $this->db->execute();
     }
 }
 /**
  * Returns a Controller object, always creating it
  *
  * @param   string $type   The contlorer type to instantiate
  * @param   string $prefix Prefix for the controller class name. Optional.
  * @param   array  $config Configuration array for controller. Optional.
  *
  * @return  mixed   A model object or false on failure
  *
  * @since       1.1.0
  */
 public static function getInstance($type, $prefix = '', $config = array())
 {
     // Check for array format.
     $filter = JFilterInput::getInstance();
     $type = $filter->clean($type, 'cmd');
     $prefix = $filter->clean($prefix, 'cmd');
     $controllerClass = $prefix . ucfirst($type);
     if (!class_exists($controllerClass)) {
         if (!isset(self::$paths[$controllerClass])) {
             // Get the environment configuration.
             $basePath = JArrayHelper::getValue($config, 'base_path', JPATH_COMPONENT);
             $nameConfig = empty($type) ? array('name' => 'controller') : array('name' => $type, 'format' => JFactory::getApplication()->input->get('format', '', 'word'));
             // Define the controller path.
             $paths[] = $basePath . '/controllers';
             $paths[] = $basePath;
             $path = JPath::find($paths, self::createFileName($nameConfig));
             self::$paths[$controllerClass] = $path;
             // If the controller file path exists, include it.
             if ($path) {
                 require_once $path;
             }
         }
         if (!class_exists($controllerClass)) {
             JLog::add(JText::sprintf('JLIB_APPLICATION_ERROR_INVALID_CONTROLLER', $controllerClass), JLog::WARNING, 'kextensions');
             return false;
         }
     }
     return new $controllerClass($config);
 }
Esempio n. 15
0
 /**
  * 
  * Check and convert to css real path
  * @var url
  */
 public static function cssPath($url = '')
 {
     $url = preg_replace('#[?\\#]+.*$#', '', $url);
     $base = JURI::base();
     $root = JURI::root(true);
     $path = false;
     $ret = false;
     if (substr($url, 0, 2) === '//') {
         //check and append if url is omit http
         $url = JURI::getInstance()->getScheme() . ':' . $url;
     }
     //check for css file extensions
     foreach (self::$cssexts as $ext) {
         if (substr_compare($url, $ext, -strlen($ext), strlen($ext)) === 0) {
             $ret = true;
             break;
         }
     }
     if ($ret) {
         if (preg_match('/^https?\\:/', $url)) {
             //is full link
             if (strpos($url, $base) === false) {
                 // external css
                 return false;
             }
             $path = JPath::clean(JPATH_ROOT . '/' . substr($url, strlen($base)));
         } else {
             $path = JPath::clean(JPATH_ROOT . '/' . ($root && strpos($url, $root) === 0 ? substr($url, strlen($root)) : $url));
         }
         return is_file($path) ? $path : false;
     }
     return false;
 }
Esempio n. 16
0
    function getInput()
    {
        $required = $this->element['required'] == "true" ? 'true' : 'false';
        $result = array();
        $db = JFactory::getDbo();
        $lang = JFactory::getLanguage();
        $extension = "com_joomleague";
        $source = JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $extension);
        $lang->load($extension, JPATH_ADMINISTRATOR, null, false, false) || $lang->load($extension, $source, null, false, false) || $lang->load($extension, JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load($extension, $source, $lang->getDefault(), false, false);
        $query = 'SELECT	pos.id,
						pos.name AS name
					FROM #__joomleague_position pos
					INNER JOIN #__joomleague_sports_type AS s ON s.id=pos.sports_type_id
					WHERE pos.published=1
					ORDER BY pos.ordering, pos.name	';
        $db->setQuery($query);
        if (!($result = $db->loadObjectList())) {
            return false;
        }
        foreach ($result as $position) {
            $position->name = JText::_($position->name);
        }
        if ($this->required == false) {
            $mitems = array(JHtml::_('select.option', '', JText::_('COM_JOOMLEAGUE_GLOBAL_SELECT_POSITION')));
        }
        foreach ($result as $item) {
            $mitems[] = JHtml::_('select.option', $item->id, '&nbsp;' . $item->name . ' (' . $item->id . ')');
        }
        return JHtml::_('select.genericlist', $mitems, $this->name, 'class="inputbox" size="1"', 'value', 'text', $this->value, $this->id);
    }
 /**
  * Convenience method to cleanup before and after test
  *
  * @return  void
  *
  * @since   12.1
  */
 private function _cleanupTestFiles()
 {
     $this->_cleanupFile(JPath::clean(JPATH_TESTS . '/tmp/patcher/lao2tzu.diff'));
     $this->_cleanupFile(JPath::clean(JPATH_TESTS . '/tmp/patcher/lao'));
     $this->_cleanupFile(JPath::clean(JPATH_TESTS . '/tmp/patcher/tzu'));
     $this->_cleanupFile(JPath::clean(JPATH_TESTS . '/tmp/patcher'));
 }
Esempio n. 18
0
 /**
  * Get the list with files from logs folder
  *
  * <code>
  * $logFiles   = new CrowdfundingLogFiles();
  * $logFiles->load();
  *
  * foreach ($logFiles as $file) {
  * ....
  * }
  * </code>
  */
 public function load()
 {
     // Read files in folder /logs
     $config = \JFactory::getConfig();
     /** @var  $config Registry */
     $logFolder = $config->get('log_path');
     $files = \JFolder::files($logFolder);
     if (!is_array($files)) {
         $files = array();
     }
     foreach ($files as $key => $file) {
         if (strcmp('index.html', $file) !== 0) {
             $this->items[] = \JPath::clean($logFolder . DIRECTORY_SEPARATOR . $files[$key]);
         }
     }
     if (count($this->files) > 0) {
         foreach ($this->files as $fileName) {
             // Check for a file in site folder.
             $errorLogFile = \JPath::clean(JPATH_ROOT . DIRECTORY_SEPARATOR . $fileName);
             if (\JFile::exists($errorLogFile)) {
                 $this->items[] = $errorLogFile;
             }
             // Check for a file in admin folder.
             $errorLogFile = \JPath::clean(JPATH_BASE . DIRECTORY_SEPARATOR . $fileName);
             if (\JFile::exists($errorLogFile)) {
                 $this->items[] = $errorLogFile;
             }
         }
     }
     sort($this->items);
 }
Esempio n. 19
0
 /**
  * Returns a reference to the a Helper object, only creating it if it doesn't already exist
  *
  * @param type 		$type 	 The helper type to instantiate
  * @param string 	$prefix	 A prefix for the helper class name. Optional.
  * @return helper The Helper Object
  */
 public static function getInstance($type = 'Base', $prefix = 'TiendaHelper')
 {
     //parent::getInstance( $type , $prefix );
     static $instances;
     if (!isset($instances)) {
         $instances = array();
     }
     $type = preg_replace('/[^A-Z0-9_\\.-]/i', '', $type);
     // The Base helper is in _base.php, but it's named TiendaHelperBase
     if (strtolower($type) == 'Base') {
         $helperClass = $prefix . ucfirst($type);
         $type = '_Base';
     }
     $helperClass = $prefix . ucfirst($type);
     if (empty($instances[$helperClass])) {
         if (!class_exists($helperClass)) {
             jimport('joomla.filesystem.path');
             if ($path = JPath::find(TiendaHelperBase::addIncludePath(), strtolower($type) . '.php')) {
                 require_once $path;
                 if (!class_exists($helperClass)) {
                     JError::raiseWarning(0, 'Helper class ' . $helperClass . ' not found in file.');
                     return false;
                 }
             } else {
                 JError::raiseWarning(0, 'Helper ' . $type . ' not supported. File not found.');
                 return false;
             }
         }
         $instance = new $helperClass();
         $instances[$helperClass] =& $instance;
     }
     return $instances[$helperClass];
 }
Esempio n. 20
0
 public function getArrayImageLinks()
 {
     $pathRoot = JPath::clean(JPATH_ROOT . DIRECTORY_SEPARATOR . 'images/');
     sort($this->path);
     for ($p = 0; $p < $this->numberFolder; $p++) {
         $ListImage[$p] = JFolder::files($pathRoot . $this->path[$p], $filter = '.');
         sort($ListImage[$p]);
     }
     $tmpListImage = array();
     for ($p = 0; $p < $this->numberFolder; $p++) {
         $imgInFolder = 0;
         $tmpListImage[$p] = array();
         for ($n = 0; $n < sizeof($ListImage[$p]); $n++) {
             $tmp = $ListImage[$p][$n];
             $pattern = '/[^A-Za-z0-9._\\-+\\s]/';
             $tmpname = explode('.', $tmp);
             $ext = end($tmpname);
             if (strtolower($ext) == 'png' || strtolower($ext) == 'jpeg' || strtolower($ext) == 'jpg' || strtolower($ext) == 'gif' || strtolower($ext) == 'bmp') {
                 if (preg_match($pattern, $tmp)) {
                 } else {
                     $tmpListImage[$p][$imgInFolder++] = $ListImage[$p][$n];
                 }
             }
         }
     }
     return $tmpListImage;
 }
 public function __construct($config = array())
 {
     parent::__construct($config);
     $this->app = JFactory::getApplication();
     // Get project ID.
     $this->projectId = $this->input->getUint('pid');
     // Prepare log object.
     $this->log = new Prism\Log\Log();
     // Set database log adapter if Joomla! debug is enabled.
     if ($this->logTable !== null and $this->logTable !== '' and JDEBUG) {
         $this->log->addAdapter(new Prism\Log\Adapter\Database(\JFactory::getDbo(), $this->logTable));
     }
     // Set file log adapter.
     if ($this->logFile !== null and $this->logFile !== '') {
         $file = \JPath::clean($this->app->get('log_path') . DIRECTORY_SEPARATOR . basename($this->logFile));
         $this->log->addAdapter(new Prism\Log\Adapter\File($file));
     }
     // Prepare context
     $filter = new JFilterInput();
     $paymentService = $filter->clean(trim(strtolower($this->input->getCmd('payment_service'))), 'ALNUM');
     $this->context = Joomla\String\StringHelper::strlen($paymentService) > 0 ? 'com_crowdfunding.notify.' . $paymentService : 'com_crowdfunding.notify';
     // Prepare params
     $this->params = JComponentHelper::getParams('com_crowdfunding');
     // Prepare container and some of the most used objects.
     $this->container = Prism\Container::getContainer();
     $this->prepareCurrency($this->container, $this->params);
     $this->prepareMoneyFormatter($this->container, $this->params);
 }
Esempio n. 22
0
 function send()
 {
     JRequest::checkToken() or die('Invalid Token');
     $bodyEmail = JRequest::getString('mailbody');
     $code = JRequest::getString('code');
     JRequest::setVar('code', $code);
     if (empty($code)) {
         return;
     }
     $config = acymailing::config();
     $mailer = acymailing::get('helper.mailer');
     $mailer->Subject = '[ACYMAILING LANGUAGE FILE] ' . $code;
     $mailer->Body = 'The website ' . ACYMAILING_LIVE . ' using AcyMailing ' . $config->get('level') . $config->get('version') . ' sent a language file : ' . $code;
     $mailer->Body .= "\n" . "\n" . "\n" . $bodyEmail;
     $user = JFactory::getUser();
     $mailer->AddAddress($user->email, $user->name);
     $mailer->AddAddress('*****@*****.**', 'Acyba Translation Team');
     $mailer->report = false;
     jimport('joomla.filesystem.file');
     $path = JPath::clean(JLanguage::getLanguagePath(JPATH_ROOT) . DS . $code . DS . $code . '.com_acymailing.ini');
     $mailer->AddAttachment($path);
     $result = $mailer->Send();
     if ($result) {
         acymailing::display(JText::_('THANK_YOU_SHARING'), 'success');
         acymailing::display($mailer->reportMessage, 'success');
     } else {
         acymailing::display($mailer->reportMessage, 'error');
     }
 }
Esempio n. 23
0
 public function __construct($config)
 {
     parent::__construct($config);
     $this->app = JFactory::getApplication();
     $this->option = $this->app->input->get("option");
     $this->layoutsBasePath = JPath::clean(JPATH_COMPONENT_ADMINISTRATOR . DIRECTORY_SEPARATOR . "layouts");
 }
Esempio n. 24
0
 /**
  * Method to perform sanity checks on the JTable instance properties to ensure
  * they are safe to store in the database.  Child classes should override this
  * method to make sure the data they are storing in the database is safe and
  * as expected before storage.
  *
  * @return  boolean  True if the instance is sane and able to be stored in the database.
  *
  * @link    http://docs.joomla.org/JTable/check
  * @since   11.1
  */
 public function check()
 {
     $input = JFactory::getApplication()->input;
     $file = $input->files->get('jform', '', 'ARRAY');
     $post = $input->post->get('jform', '', 'ARRAY');
     $bookId = $post['book_id'];
     $file = $file['audio_upload'];
     if (empty($file['error'])) {
         // Make the filename safe
         $audioFile = JFile::makeSafe($file['name']);
         $fileExt = explode('.', $audioFile);
         if (isset($audioFile)) {
             $filepath = JPath::clean(JPATH_SITE . '/media/englishconcept/media/audio/' . strtolower(md5($bookId . $file['name'])) . '.' . $fileExt[1]);
             $objectFile = new JObject($file);
             $objectFile->filepath = $filepath;
             if (JFile::exists($objectFile->filepath)) {
                 JFile::delete($objectFile->filepath);
             }
             if (!JFile::upload($objectFile->tmp_name, $objectFile->filepath)) {
                 return false;
             }
         }
     }
     return true;
 }
Esempio n. 25
0
 /**
  * Method to delete the images
  *
  * @access	public
  * @return int
  */
 public function delete($type)
 {
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     JClientHelper::setCredentialsFromRequest('ftp');
     // Get some data from the request
     $images = $this->getImages($type);
     $folder = $this->map[$type]['folder'];
     $count = count($images);
     $fail = 0;
     if ($count) {
         foreach ($images as $image) {
             if ($image !== JFilterInput::getInstance()->clean($image, 'path')) {
                 JError::raiseWarning(100, JText::_('COM_JEM_HOUSEKEEPING_UNABLE_TO_DELETE') . ' ' . htmlspecialchars($image, ENT_COMPAT, 'UTF-8'));
                 $fail++;
                 continue;
             }
             $fullPath = JPath::clean(JPATH_SITE . '/images/jem/' . $folder . '/' . $image);
             $fullPaththumb = JPath::clean(JPATH_SITE . '/images/jem/' . $folder . '/small/' . $image);
             if (is_file($fullPath)) {
                 JFile::delete($fullPath);
                 if (JFile::exists($fullPaththumb)) {
                     JFile::delete($fullPaththumb);
                 }
             }
         }
     }
     $deleted = $count - $fail;
     return $deleted;
 }
Esempio n. 26
0
 public function getVarsToPush()
 {
     $black_list = array('spacer');
     $data = array();
     if (JVM_VERSION === 2) {
         $filename = JPATH_SITE . '/plugins/' . $this->_type . '/' . $this->_name . '/' . $this->_name . '.xml';
     } else {
         $filename = JPATH_SITE . '/plugins/' . $this->_type . '/' . $this->_name . '.xml';
     }
     // Check of the xml file exists
     $filePath = JPath::clean($filename);
     if (is_file($filePath)) {
         $xml = JFactory::getXMLParser('simple');
         $result = $xml->loadFile($filename);
         if ($result) {
             if ($params = $xml->document->params) {
                 foreach ($params as $param) {
                     if ($param->_name = "params") {
                         if ($children = $param->_children) {
                             foreach ($children as $child) {
                                 if (isset($child->_attributes['name'])) {
                                     $data[$child->_attributes['name']] = array('', 'char');
                                     $result = TRUE;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $data;
 }
Esempio n. 27
0
 /**
  * Configure the Submenu links.
  *
  * @param   string    The extension being used for the categories.
  *
  * @return  void
  * @since   1.6
  */
 public static function addSubmenu($extension)
 {
     // Avoid nonsense situation.
     if ($extension == 'com_categories') {
         return;
     }
     $parts = explode('.', $extension);
     $component = $parts[0];
     if (count($parts) > 1) {
         $section = $parts[1];
     }
     // Try to find the component helper.
     $eName = str_replace('com_', '', $component);
     $file = JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $component . '/helpers/' . $eName . '.php');
     if (file_exists($file)) {
         require_once $file;
         $prefix = ucfirst(str_replace('com_', '', $component));
         $cName = $prefix . 'Helper';
         if (class_exists($cName)) {
             if (is_callable(array($cName, 'addSubmenu'))) {
                 $lang = JFactory::getLanguage();
                 // loading language file from the administrator/language directory then
                 // loading language file from the administrator/components/*extension*/language directory
                 $lang->load($component, JPATH_BASE, null, false, false) || $lang->load($component, JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $component), null, false, false) || $lang->load($component, JPATH_BASE, $lang->getDefault(), false, false) || $lang->load($component, JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $component), $lang->getDefault(), false, false);
                 call_user_func(array($cName, 'addSubmenu'), 'categories' . (isset($section) ? '.' . $section : ''));
             }
         }
     }
 }
Esempio n. 28
0
 protected function getOptions()
 {
     $options = array();
     foreach ($this->element->children() as $option) {
         $disable = false;
         if ($option->getName() != 'option') {
             continue;
         }
         if ($option['filter'] == true) {
             if ($option['value'] == "ccomment") {
                 $file = JPATH_ROOT . '/administrator/components/com_comment/comment.php';
             } else {
                 $com = 'com_' . $option['value'];
                 $file = JPATH_ROOT . '/administrator/components/' . $com . '/' . $option['value'] . '.php';
             }
             $file = JPath::clean($file);
             if (!JFile::exists($file)) {
                 $disable = true;
             }
         }
         $tmp = JHtml::_('select.option', (string) $option['value'], JText::alt(trim((string) $option), preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname)), 'value', 'text', $disable);
         $tmp->class = (string) $option['class'];
         $tmp->onclick = (string) $option['onclick'];
         $options[] = $tmp;
     }
     reset($options);
     return $options;
 }
Esempio n. 29
0
 protected function getInput()
 {
     // Initialize variables.
     $html = array();
     $attr = '';
     // Initialize some field attributes.
     $attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
     // To avoid user's confusion, readonly="true" should imply disabled="true".
     if ((string) $this->element['readonly'] == 'true' || (string) $this->element['disabled'] == 'true') {
         $attr .= ' disabled="disabled"';
     }
     $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
     $attr .= $this->multiple ? ' multiple="multiple"' : '';
     // Initialize JavaScript field attributes.
     $attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
     $path = JPath::clean(JPATH_BASE . DS . 'components' . DS . 'com_k2');
     if (!file_exists($path)) {
         // do nothing because K2 is not installed
     } else {
         $this->getOptions();
     }
     if ((string) $this->element['readonly'] == 'true') {
         $html[] = JHtml::_('select.genericlist', $this->options, '', trim($attr), 'value', 'text', $this->value, $this->id);
         $html[] = '<input type="hidden" name="' . $this->name . '" value="' . $this->value . '"/>';
     } else {
         if (isset($this->options[0]) && $this->options[0] != '') {
             $html[] = JHtml::_('select.genericlist', $this->options, $this->name, trim($attr), 'value', 'text', $this->value, $this->id);
         } else {
             return '<select id="jform_params_com_solidres_hotel_categories" style="display:none!important;"></select><strong style="line-height: 2.6em" class="gk-hidden-field">Solidres is not installed or any solidres assets categories are available.</strong>';
         }
     }
     return implode($html);
 }
Esempio n. 30
0
 function _displayPopulate($tpl)
 {
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     $document = JFactory::getDocument();
     $uri = JFactory::getURI();
     $url = $uri->toString();
     $model = $this->getModel();
     $projectws = $this->get('Data', 'project');
     $document->setTitle(JText::_('COM_JOOMLEAGUE_ADMIN_ROUNDS_POPULATE_TITLE'));
     $lists = array();
     $iScheduleType = 0;
     $options = array();
     $options[] = JHtml::_('select.option', $iScheduleType++, JText::_('COM_JOOMLEAGUE_ADMIN_ROUNDS_POPULATE_TYPE_SINGLE_ROUND_ROBIN'));
     $options[] = JHtml::_('select.option', $iScheduleType++, JText::_('COM_JOOMLEAGUE_ADMIN_ROUNDS_POPULATE_TYPE_DOUBLE_ROUND_ROBIN'));
     $path = JPath::clean(JPATH_ROOT . '/images/com_joomleague/database/round_populate_templates');
     $files = JFolder::files($path, '.', false);
     foreach ($files as $file) {
         $filename = strtoupper(JFile::stripExt($file));
         $options[] = JHtml::_('select.option', $file, JText::_('COM_JOOMLEAGUE_ADMIN_ROUNDS_POPULATE_TYPE_' . $filename));
     }
     // 		$lists['scheduling'] = JHtml::_('select.genericlist', $options, 'scheduling', 'onchange="handleOnChange_scheduling(this)"', 'value', 'text');
     $lists['scheduling'] = JHtml::_('select.genericlist', $options, 'scheduling', '', 'value', 'text');
     // 		$teams = $this->get('projectteams');
     // 		$options = array();
     // 		foreach ($teams as $t) {
     // 			$options[] = JHtml::_('select.option', $t->projectteam_id, $t->text);
     // 		}
     // 		$lists['teamsorder'] = JHtml::_('select.genericlist', $options, 'teamsorder[]', 'multiple="multiple" size="20"');
     $this->projectws = $projectws;
     $this->request_url = $url;
     $this->lists = $lists;
     $this->addToolbar_Populate();
     parent::display($tpl);
 }