Esempio n. 1
0
 /**
  * get the list of k2 items
  * 
  * @param JParameter $params;
  * @return Array
  */
 public function __getList($params)
 {
     $mainframe =& JFactory::getApplication();
     $maxTitle = $params->get('max_title', '100');
     $maxDesciption = $params->get('max_description', 100);
     $openTarget = $params->get('open_target', 'parent');
     $formatter = $params->get('style_displaying', 'title');
     $titleMaxChars = $params->get('title_max_chars', '100');
     $descriptionMaxChars = $params->get('description_max_chars', 100);
     $condition = $this->buildConditionQuery($params);
     $ordering = $params->get('k2_ordering', 'created_asc');
     $limit = $params->get('limit_items', 5);
     $ordering = str_replace('_', '  ', $ordering);
     $my =& JFactory::getUser();
     $aid = $my->get('aid', 0);
     $thumbWidth = (int) $params->get('thumbnail_width', 35);
     $thumbHeight = (int) $params->get('thumbnail_height', 60);
     $imageHeight = (int) $params->get('main_height', 300);
     $imageWidth = (int) $params->get('main_width', 660);
     $isThumb = $params->get('auto_renderthumb', 1);
     $isStripedTags = $params->get('auto_strip_tags', 0);
     $extraURL = $params->get('open_target') != 'modalbox' ? '' : '&tmpl=component';
     $db =& JFactory::getDBO();
     $date =& JFactory::getDate();
     $now = $date->toMySQL();
     require_once JPath::clean(JPATH_SITE . '/components/com_k2/helpers/route.php');
     $query = "SELECT a.*, cr.rating_sum/cr.rating_count as rating, c.name as categoryname,\n              c.id as categoryid, c.alias as categoryalias, c.params as categoryparams, cc.commentcount as commentcount" . " FROM #__k2_items as a" . " LEFT JOIN #__k2_categories c ON c.id = a.catid" . " LEFT JOIN #__k2_rating as cr ON a.id = cr.itemid" . " LEFT JOIN (select cm.itemid  as id, count(cm.id) as commentcount from #__k2_comments as cm\n                                  where cm.published=1 group by cm.itemid) as cc on a.id = cc.id";
     $query .= " WHERE a.published = 1" . " AND a.access <= {$aid}" . " AND a.trash = 0" . " AND c.published = 1" . " AND c.access <= {$aid}" . " AND c.trash = 0 ";
     if ($params->get('featured_items_show', '0') == 0) {
         $query .= " AND a.featured != 1";
     } elseif ($params->get('featured_items_show', '0') == 2) {
         $query .= " AND a.featured = 1";
     }
     $query .= $condition . ' ORDER BY ' . $ordering;
     $query .= $limit ? ' LIMIT ' . $limit : '';
     $db->setQuery($query);
     $data = $db->loadObjectlist();
     if (empty($data)) {
         return array();
     }
     foreach ($data as $key => &$item) {
         if ($item->access <= $aid) {
             $item->link = JRoute::_(K2HelperRoute::getItemRoute($item->id . ':' . $item->alias, $item->catid . ':' . $item->categoryalias) . $extraURL);
         } else {
             $item->link = JRoute::_('index.php?option=com_user&view=login');
         }
         $item->date = JHtml::_('date', $item->created, JText::_('DATE_FORMAT_LC2'));
         $item->subtitle = self::substring($item->title, $titleMaxChars);
         $item->description = self::substring($item->introtext, $descriptionMaxChars, true);
         $item = self::parseImages($item);
         if ($item->mainImage && ($image = $this->renderThumb($item->mainImage, $imageWidth, $imageHeight, $item->title, $isThumb))) {
             $item->mainImage = $image;
         }
         $item->rating = is_numeric($item->rating) ? floatval($item->rating / 5 * 100) : null;
         if ($item->thumbnail && ($image = $this->renderThumb($item->thumbnail, $thumbWidth, $thumbHeight, $item->title, $isThumb))) {
             $item->thumbnail = $image;
         }
     }
     return $data;
 }
Esempio n. 2
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. 3
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. 4
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. 5
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. 6
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. 7
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. 8
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();
     }
 }
Esempio n. 9
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. 10
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);
 }
Esempio n. 11
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. 12
0
 public function download()
 {
     $file = $this->input->get->get('file', null, 'raw');
     if (!$file) {
         JFactory::getApplication()->close(404);
     }
     $model = $this->getModel();
     /** @var $model CrowdfundingModelLog */
     try {
         $fileSource = $model->prepareFile(JPath::clean($file));
         $fileName = basename($fileSource);
         $fileSize = filesize($fileSource);
         $doc = JFactory::getDocument();
         if (strcmp('error_log', $fileName) == 0) {
             JResponse::setHeader('Content-Type', 'text/plain', true);
             $doc->setMimeEncoding('text/plain');
         } else {
             JResponse::setHeader('Content-Type', 'application/octet-stream', true);
             JResponse::setHeader('Content-Transfer-Encoding', 'binary', true);
             $doc->setMimeEncoding('application/octet-stream');
         }
         JResponse::setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
         JResponse::setHeader('Pragma', 'no-cache', true);
         JResponse::setHeader('Expires', '0', true);
         JResponse::setHeader('Content-Disposition', 'attachment; filename=' . $fileName, true);
         JResponse::setHeader('Content-Length', $fileSize, true);
     } catch (Exception $e) {
         JLog::add($e->getMessage(), JLog::ERROR, 'com_crowdfunding');
         throw new Exception(JText::_('COM_CROWDFUNDING_ERROR_SYSTEM'));
     }
     echo file_get_contents($fileSource);
     JFactory::getApplication()->close();
 }
Esempio n. 13
0
 /**
  * Configure the Submenu links.
  *
  * @param	string	The extension being used for the categories.
  */
 public function addSubmenu($extension)
 {
     // Avoid nonsense situation.
     if ($extension == 'com_categories') {
         return;
     }
     // Try to find the component helper.
     $eName = str_replace('com_', '', $extension);
     $file = JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $extension . '/helpers/' . $eName . '.php');
     if (file_exists($file)) {
         require_once $file;
         $prefix = ucfirst(str_replace('com_', '', $extension));
         $cName = $prefix . 'Helper';
         if (class_exists($cName)) {
             if (is_callable(array($cName, 'addSubmenu'))) {
                 $lang =& JFactory::getLanguage();
                 // loading language file from the administrator/components/*extension*/language directory
                 $lang->load($extension, JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $extension));
                 // loading language file from the administrator/language directory
                 $lang->load($extension);
                 call_user_func(array($cName, 'addSubmenu'), 'categories');
             }
         }
     }
 }
Esempio n. 14
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'] . '"' : '';
     // Get the field options.
     $path = JPath::clean(JPATH_BASE . DS . 'components' . DS . 'com_k2');
     if (file_exists($path)) {
         $options = (array) $this->getOptions();
         // Create a read-only list (no name) with a hidden input to store the value.
         if ((string) $this->element['readonly'] == 'true') {
             $html[] = JHtml::_('select.genericlist', $options, '', trim($attr), 'value', 'text', $this->value, $this->id);
             $html[] = '<input type="hidden" name="' . $this->name . '" value="' . $this->value . '"/>';
         } else {
             if ($options[0] != '') {
                 $html[] = JHtml::_('select.genericlist', $options, $this->name, trim($attr), 'value', 'text', $this->value, $this->id);
             } else {
                 return '<select id="jform_params_k2_tags" style="display:none"></select><strong style="line-height: 2.6em">K2 is not installed or any K2 tags are available.</strong>';
             }
         }
     } else {
         return '<select id="jform_params_k2_tags" style="display:none"></select><strong style="line-height: 2.6em">K2 is not installed or any K2 tags are available.</strong>';
     }
     return implode($html);
 }
Esempio n. 15
0
 function getItem()
 {
     global $mainframe;
     jimport('joomla.filesystem.path');
     if (!$this->template) {
         return JError::raiseWarning(500, 'Template not specified');
     }
     $tBaseDir = JPath::clean(JPATH_RSGALLERY2_SITE . '/templates');
     if (!is_dir($tBaseDir . '/' . $this->template)) {
         return JError::raiseWarning(500, 'Template not found');
     }
     $lang =& JFactory::getLanguage();
     $lang->load('tpl_' . $this->template, JPATH_RSGALLERY2_SITE);
     $ini = JPATH_RSGALLERY2_SITE . '/templates/' . $this->template . '/params.ini';
     $xml = JPATH_RSGALLERY2_SITE . '/templates/' . $this->template . '/templateDetails.xml';
     $row = TemplatesHelper::parseXMLTemplateFile($tBaseDir, $this->template);
     jimport('joomla.filesystem.file');
     // Read the ini file
     if (JFile::exists($ini)) {
         $content = JFile::read($ini);
     } else {
         $content = null;
     }
     $params = new JParameter($content, $xml, 'template');
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     $ftp =& JClientHelper::setCredentialsFromRequest('ftp');
     $item = new stdClass();
     $item->params = $params;
     $item->row = $row;
     $item->type = $this->_type;
     $item->template = $this->template;
     return $item;
 }
Esempio n. 16
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. 17
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. 18
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;
 }
Esempio n. 19
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. 20
0
 /**
  * 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);
         }
     }
 }
 /**
  * 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. 22
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);
    }
 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. 24
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. 25
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. 26
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;
 }
Esempio n. 27
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. 28
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. 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
 /**
  * Loads the plugins from the CMS location.
  *
  */
 public function load($cmsPath, $group = 'cron')
 {
     // Initialiase variables.
     jimport('joomla.filesystem.path');
     jimport('joomla.html.parameter');
     jimport('joomla.plugin.plugin');
     // Must do a lot of manual work. Can't afford to trip the session (mainly a call to JFactory::getUser()).
     $query = $this->db->getQuery(true);
     // Get a list of the plugins from the database.
     $query->select('p.*')->from('saas_extensions AS p')->where('p.enabled = 1')->where('p.type = ' . $this->db->quote('plugin'))->where('p.folder = ' . $this->db->quote('cron'))->order('p.ordering');
     $this->db->setQuery($query);
     $plugins = $this->db->loadObjectList();
     $result = array();
     // Convert the parameters for each plugin.
     foreach ($plugins as $plugin) {
         //	$className = 'plg' . ucfirst($plugin->folder) . ucfirst($plugin->element);
         $className = 'plgSaasmarketsMerchants';
         // Preload the plugins.
         $path = JPath::clean(sprintf('%s/plugins/%s/%s/%s.php', $cmsPath, $plugin->folder, $plugin->element, $plugin->element));
         require_once $path;
         if (class_exists($className)) {
             $result[] = new $className($this, array('params' => new JRegistry($plugin->params)));
         }
     }
     return $result;
 }