Example #1
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     parent::__construct();
     $this->config = KunenaConfig::getInstance();
     $this->limit = $this->config->userlist_rows;
     $this->query->leftJoin('#__kunena_users AS ku ON ku.userid=a.id');
 }
Example #2
0
 /**
  * Load user list.
  *
  * @throws KunenaExceptionAuthorise
  */
 protected function before()
 {
     parent::before();
     $config = KunenaConfig::getInstance();
     if ($config->userlist_allowed && JFactory::getUser()->guest) {
         throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), '401');
     }
     require_once KPATH_SITE . '/models/user.php';
     $this->model = new KunenaModelUser(array(), $this->input);
     $this->model->initialize($this->getOptions(), $this->getOptions()->get('embedded', false));
     $this->state = $this->model->getState();
     $this->me = KunenaUserHelper::getMyself();
     $this->config = KunenaConfig::getInstance();
     $start = $this->state->get('list.start');
     $limit = $this->state->get('list.limit');
     // Get list of super admins to exclude or not in filter by configuration.
     $filter = JAccess::getUsersByGroup(8);
     $finder = new KunenaUserFinder();
     $finder->filterByConfiguration($filter)->filterByName($this->state->get('list.search'));
     $this->total = $finder->count();
     $this->pagination = new KunenaPagination($this->total, $start, $limit);
     $alias = 'ku';
     $aliasList = array('id', 'name', 'username', 'email', 'block', 'registerDate', 'lastvisitDate');
     if (in_array($this->state->get('list.ordering'), $aliasList)) {
         $alias = 'a';
     }
     $this->users = $finder->order($this->state->get('list.ordering'), $this->state->get('list.direction') == 'asc' ? 1 : -1, $alias)->start($this->pagination->limitstart)->limit($this->pagination->limit)->find();
 }
Example #3
0
	/**
	 * Prepare announcement box display.
	 *
	 * @return bool
	 */
	protected function before()
	{
		parent::before();

		$config = KunenaConfig::getInstance();

		if (!$config->showannouncement)
		{
			return false;
		}

		$items = KunenaForumAnnouncementHelper::getAnnouncements();
		$this->announcement = array_pop($items);

		if (!$this->announcement || !$this->announcement->authorise('read'))
		{
			return false;
		}

		$view = $this->input->getWord('view', 'default');
		$layout = $this->input->getWord('layout', 'default');

		if ($view == 'topic' && $layout != 'default'  || $view == 'user' || $view == 'search' || $view == 'announcement' && $layout == 'default') {
			return false;
		}

		return true;
	}
Example #4
0
 /**
  * Method to instantiate the layout.
  *
  * @param	string			$name
  * @param   array  $paths  The paths queue.
  */
 public function __construct($name, array $paths = null)
 {
     // Setup dependencies.
     $this->_name = $name;
     $this->includePaths = isset($paths) ? $paths : $this->loadPaths();
     $this->debug = JDEBUG || KunenaConfig::getInstance()->get('debug');
 }
Example #5
0
	/**
	 * Initialize class.
	 */
	static public function initialize()
	{
		KUNENA_PROFILER ? KunenaProfiler::instance()->start('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;

		if (KunenaConfig::getInstance()->get('cache_cat'))
		{
			// FIXME: Experimental caching.
			/** @var JCache|JCacheControllerCallback $cache */
			$cache = JFactory::getCache('com_kunena', 'callback');
			$cache->setLifeTime(180);
			self::$_instances = $cache->call(array('KunenaForumCategoryHelper', 'loadCategories'));
		}
		else
		{
			self::$_instances = self::loadCategories();
		}

		if (is_null(self::$_tree))
		{
			self::buildTree(self::$_instances);
		}

		self::$allowed = KunenaAccess::getInstance()->getAllowedCategories();
		KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;
	}
Example #6
0
 /**
  * Executed before display.
  */
 protected function before()
 {
     $this->layout = $this->input->getCmd('layout', 'default');
     $this->config = KunenaConfig::getInstance();
     if ($this->primary) {
         $this->document = JFactory::getDocument();
     }
 }
Example #7
0
 protected function after()
 {
     KUNENA_PROFILER ? KunenaProfiler::instance()->start('function ' . get_class($this) . '::' . __FUNCTION__ . '()') : null;
     // Use our own browser side cache settings.
     JResponse::allowCache(false);
     JResponse::setHeader('Expires', 'Mon, 1 Jan 2001 00:00:00 GMT', true);
     JResponse::setHeader('Last-Modified', gmdate("D, d M Y H:i:s") . ' GMT', true);
     JResponse::setHeader('Cache-Control', 'no-store, must-revalidate, post-check=0, pre-check=0', true);
     if ($this->config->get('credits', 1)) {
         $this->output->appendAfter($this->poweredBy());
     }
     KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . get_class($this) . '::' . __FUNCTION__ . '()') : null;
 }
Example #8
0
 /**
  * Prepare AJAX display.
  *
  * @return void
  */
 protected function before()
 {
     // Load language files.
     KunenaFactory::loadLanguage('com_kunena.sys', 'admin');
     KunenaFactory::loadLanguage('com_kunena.templates');
     KunenaFactory::loadLanguage('com_kunena.models');
     KunenaFactory::loadLanguage('com_kunena.views');
     $this->me = KunenaUserHelper::getMyself();
     $this->config = KunenaConfig::getInstance();
     $this->document = JFactory::getDocument();
     $this->template = KunenaFactory::getTemplate();
     $this->template->initialize();
 }
Example #9
0
 /**
  * Prepare statistics box display.
  *
  * @return boolean
  */
 protected function before()
 {
     parent::before();
     $this->config = KunenaConfig::getInstance();
     if (!$this->config->get('showstats') || !$this->config->statslink_allowed && !KunenaUserHelper::get()->exists()) {
         throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), '404');
     }
     $statistics = KunenaForumStatistics::getInstance();
     $statistics->loadGeneral();
     $this->setProperties($statistics);
     $this->latestMemberLink = KunenaFactory::getUser(intval($this->lastUserId))->getLink();
     $this->statisticsUrl = KunenaFactory::getProfile()->getStatisticsURL();
     return true;
 }
Example #10
0
 /**
  * Prepare general statistics display.
  *
  * @return void
  *
  * @throws KunenaExceptionAuthorise
  */
 protected function before()
 {
     parent::before();
     $this->config = KunenaConfig::getInstance();
     if (!$this->config->get('showstats')) {
         throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), '404');
     }
     if (!$this->config->statslink_allowed && JFactory::getUser()->guest) {
         throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), '401');
     }
     $statistics = KunenaForumStatistics::getInstance();
     $statistics->loadAll();
     $this->setProperties($statistics);
     $this->latestMemberLink = KunenaFactory::getUser((int) $this->lastUserId)->getLink();
     $this->userlistUrl = KunenaFactory::getProfile()->getUserListUrl();
 }
Example #11
0
 /**
  * Prepare Who is online display.
  *
  * @return void
  *
  * @throws KunenaExceptionAuthorise
  */
 protected function before()
 {
     parent::before();
     $this->config = KunenaConfig::getInstance();
     if (!$this->config->get('showwhoisonline')) {
         throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), '404');
     }
     $me = KunenaUserHelper::getMyself();
     $moderator = intval($me->isModerator()) + intval($me->isAdmin());
     $users = KunenaUserHelper::getOnlineUsers();
     KunenaUserHelper::loadUsers(array_keys($users));
     $onlineusers = KunenaUserHelper::getOnlineCount();
     $who = '<strong>' . $onlineusers['user'] . ' </strong>';
     if ($onlineusers['user'] == 1) {
         $who .= JText::_('COM_KUNENA_WHO_ONLINE_MEMBER') . '&nbsp;';
     } else {
         $who .= JText::_('COM_KUNENA_WHO_ONLINE_MEMBERS') . '&nbsp;';
     }
     $who .= JText::_('COM_KUNENA_WHO_AND');
     $who .= '<strong> ' . $onlineusers['guest'] . ' </strong>';
     if ($onlineusers['guest'] == 1) {
         $who .= JText::_('COM_KUNENA_WHO_ONLINE_GUEST') . '&nbsp;';
     } else {
         $who .= JText::_('COM_KUNENA_WHO_ONLINE_GUESTS') . '&nbsp;';
     }
     $who .= JText::_('COM_KUNENA_WHO_ONLINE_NOW');
     $this->membersOnline = $who;
     $this->onlineList = array();
     $this->hiddenList = array();
     foreach ($users as $userid => $usertime) {
         $user = KunenaUserHelper::get($userid);
         if (!$user->showOnline) {
             if ($moderator) {
                 $this->hiddenList[$user->getName()] = $user;
             }
         } else {
             $this->onlineList[$user->getName()] = $user;
         }
     }
     ksort($this->onlineList);
     ksort($this->hiddenList);
     $profile = KunenaFactory::getProfile();
     $this->usersUrl = $profile->getUserListURL();
 }
Example #12
0
 /**
  * Check if filesize on file which on going to be uploaded doesn't exceed the limits set by Kunena configuration and Php configuration
  *
  * @param   int      $filesize  The size of file in bytes
  * @param   boolean  $avatar    If the file is an avatar
  *
  * @return boolean
  */
 protected function checkFileSize($filesize, $avatar)
 {
     if (!$avatar) {
         if ($filesize > $this->getMaxSize()) {
             return false;
         }
     } else {
         if ($avatar && $filesize > intval(KunenaConfig::getInstance()->avatarsize) * 1024) {
             return false;
         }
     }
     return true;
 }
Example #13
0
	/**
	 * Get a Kunena configuration object
	 *
	 * Returns the global {@link KunenaConfig} object, only creating it if it doesn't already exist.
	 *
	 * @return KunenaConfig
	 */
	public static function getConfig() {
		return KunenaConfig::getInstance();
	}
Example #14
0
	protected static function build()
	{
		KUNENA_PROFILER ? KunenaProfiler::instance()->start('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;

		if (self::$search === false)
		{
			$user = KunenaUserHelper::getMyself();
			$language = strtolower(JFactory::getDocument()->getLanguage());
			self::$search = false;

			if (KunenaConfig::getInstance()->get('cache_mid'))
			{
				// FIXME: Experimental caching.
				$cache = self::getCache();
				self::$search = unserialize($cache->get('search', "com_kunena.route.v1.{$language}.{$user->userid}"));
			}

			if (self::$search === false)
			{
				self::$search['home'] = array();
				foreach (self::$menu as $item)
				{
					// Skip menu items that aren't pointing to Kunena or are using wrong language.
					if (($item->component != 'com_kunena' && $item->type != 'alias')
						|| ($item->language  != '*' && strtolower($item->language) != $language))
					{
						continue;
					}

					// Follow links.
					if ($item->type == 'alias')
					{
						if (empty($item->query['Itemid']) || empty(self::$menu[$item->query['Itemid']]))
						{
							continue;
						}

						$item = self::$menu[$item->query['Itemid']];
						if ($item->component != 'com_kunena' || ($item->language  != '*' && strtolower($item->language) != $language))
						{
							continue;
						}
					}

					// Ignore legacy menu items without view in it.
					if (!isset($item->query['view']))
					{
						continue;
					}

					// Save Kunena menu items so that we can make fast searches
					$home = self::getHome($item);
					self::$search[$item->query['view']][$home ? $home->id : 0][$item->id] = $item->id;
				}

				if (isset($cache))
				{
					$cache->store(serialize(self::$search), 'search', "com_kunena.route.v1.{$language}.{$user->userid}");
				}
			}
		}
		KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;
	}
Example #15
0
 /**
  * Find filename which isn't already taken in the filesystem.
  *
  * @param  string  $folder      Relative path from JPATH_ROOT.
  * @param  string  $basename    Filename without extension.
  * @param  string  $extension   File extension.
  * @param  bool    $protected   True to randomize the filename. If not given, uses Kunena configuration setting.
  *
  * @return string
  *
  * @since  K4.0
  */
 public static function getAvailableFilename($folder, $basename, $extension, $protected = null)
 {
     if (is_null($protected)) {
         $protected = (bool) KunenaConfig::getInstance()->attachment_protection;
     }
     if ($protected) {
         // Ignore proposed filename and return totally random and unique name without file extension.
         do {
             $name = md5(rand());
         } while (file_exists(JPATH_ROOT . "/{$folder}/{$name}"));
         return $name;
     }
     // Lets find out if we need to rename the filename.
     $basename = preg_replace('/[[:space:]]/', '', KunenaFile::makeSafe($basename));
     $extension = trim($extension, '.');
     if (empty($basename)) {
         $basename = 'file_' . substr(md5(rand()), 2, 7);
     }
     $newName = "{$basename}.{$extension}";
     $date = date('Y-m-d');
     // Rename file if there is already one with the same name
     if (file_exists(JPATH_ROOT . "/{$folder}/{$newName}")) {
         $newName = "{$basename}_{$date}.{$extension}";
         for ($i = 2; file_exists(JPATH_ROOT . "/{$folder}/{$newName}"); $i++) {
             $newName = "{$basename}_{$date}-{$i}.{$extension}";
         }
     }
     return $newName;
 }
Example #16
0
 /**
  * Get a list of the menu items (taken from Joomla 2.5.1).
  * This only method need to be used only in frontend part
  *
  * @param	JRegistry	$params	The module options.
  *
  * @return	array
  * @see		modules/mod_menu/helper.php
  */
 public static function getList(&$params)
 {
     $app = JFactory::getApplication();
     $menu = $app->getMenu();
     // If no active menu, use default
     $active = $menu->getActive() ? $menu->getActive() : $menu->getDefault();
     $items = false;
     // FIXME: Experimental caching.
     if (KunenaConfig::getInstance()->get('cache_menu')) {
         $levels = JFactory::getUser()->getAuthorisedViewLevels();
         asort($levels);
         $key = 'menu_items' . $params . implode(',', $levels) . '.' . $active->id;
         $cache = JFactory::getCache('com_kunena.menu', '');
         $items = $cache->get($key);
     }
     if ($items === false) {
         // Initialise variables.
         $path = $active->tree;
         $start = (int) $params->get('startLevel');
         $end = (int) $params->get('endLevel');
         $showAll = $params->get('showAllChildren');
         $items = $menu->getItems('menutype', $params->get('menutype'));
         if ($items) {
             foreach ($items as $i => $item) {
                 if ($start && $start > $item->level || $end && $item->level > $end || !$showAll && $item->level > 1 && !in_array($item->parent_id, $path) || $start > 1 && !in_array($item->tree[$start - 2], $path)) {
                     unset($items[$i]);
                     continue;
                 }
                 $item->deeper = false;
                 $item->shallower = false;
                 $item->level_diff = 0;
                 if (isset($lastitem)) {
                     $lastitem->deeper = $item->level > $lastitem->level;
                     $lastitem->shallower = $item->level < $lastitem->level;
                     $lastitem->level_diff = $lastitem->level - $item->level;
                 }
                 $item->parent = (bool) $menu->getItems('parent_id', (int) $item->id, true);
                 $lastitem = $item;
                 $item->active = false;
                 $item->flink = $item->link;
                 switch ($item->type) {
                     case 'separator':
                         // No further action needed.
                         continue;
                     case 'url':
                         if (strpos($item->link, 'index.php?') === 0 && strpos($item->link, 'Itemid=') === false) {
                             // If this is an internal Joomla link, ensure the Itemid is set.
                             $item->flink = $item->link . '&Itemid=' . $item->id;
                         }
                         break;
                     case 'alias':
                         // If this is an alias use the item id stored in the parameters to make the link.
                         $item->flink = 'index.php?Itemid=' . $item->params->get('aliasoptions');
                         break;
                     default:
                         $router = $app::getRouter();
                         if ($router->getMode() == JROUTER_MODE_SEF) {
                             $item->flink = 'index.php?Itemid=' . $item->id;
                         } else {
                             $item->flink .= '&Itemid=' . $item->id;
                         }
                         break;
                 }
                 if (strcasecmp(substr($item->flink, 0, 4), 'http') && strpos($item->flink, 'index.php?') !== false) {
                     $item->flink = JRoute::_($item->flink, false, $item->params->get('secure'));
                 } else {
                     $item->flink = JRoute::_($item->flink, false);
                 }
                 $item->title = htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8');
                 $item->anchor_css = htmlspecialchars($item->params->get('menu-anchor_css', ''), ENT_COMPAT, 'UTF-8');
                 $item->anchor_title = htmlspecialchars($item->params->get('menu-anchor_title', ''), ENT_COMPAT, 'UTF-8');
                 $item->menu_image = $item->params->get('menu_image', '') ? htmlspecialchars($item->params->get('menu_image', ''), ENT_COMPAT, 'UTF-8') : '';
             }
             if (isset($lastitem)) {
                 $lastitem->deeper = ($start ? $start : 1) > $lastitem->level;
                 $lastitem->shallower = ($start ? $start : 1) < $lastitem->level;
                 $lastitem->level_diff = $lastitem->level - ($start ? $start : 1);
             }
         }
         if (isset($cache)) {
             $cache->store($items, $key);
         }
     }
     return $items;
 }
Example #17
0
 /**
  * @throws Exception
  */
 public function clearCache()
 {
     $this->adminsByCatid = array();
     $this->adminsByUserid = array();
     $this->moderatorsByCatid = array();
     $this->moderatorsByUserid = array();
     // Reset read access for the current session
     $me = KunenaUserHelper::getMyself();
     JFactory::getApplication()->setUserState("com_kunena.user{$me->userid}_read", null);
     // @var KunenaAccess $access
     foreach ($this->accesstypes['all'] as $access) {
         if (method_exists($access, 'loadCategoryRoles')) {
             $this->storeRoles((array) $access->loadCategoryRoles());
         }
     }
     // Load native category moderators and administrators
     $db = JFactory::getDBO();
     $query = "SELECT user_id, category_id, role FROM #__kunena_user_categories WHERE role IN (1,2)";
     $db->setQuery($query);
     $this->storeRoles((array) $db->loadObjectList());
     KunenaError::checkDatabaseError();
     // FIXME: enable caching after fixing the issues
     if (KunenaConfig::getInstance()->get('cache_adm')) {
         // Store new data into cache
         $cache = JFactory::getCache('com_kunena', 'output');
         $cache->store(serialize(array('ac' => $this->adminsByCatid, 'au' => $this->adminsByUserid, 'mc' => $this->moderatorsByCatid, 'mu' => $this->moderatorsByUserid)), self::$cacheKey, 'com_kunena');
     }
 }
Example #18
0
<?php

/**
 * Kunena Component
 * @package     Kunena.Template.Crypsis
 * @subpackage  Layout.Email
 *
 * @copyright   (C) 2008 - 2015 Kunena Team. All rights reserved.
 * @license     http://www.gnu.org/copyleft/gpl.html GNU/GPL
 * @link        http://www.kunena.org
 **/
defined('_JEXEC') or die;
// New post email for subscribers (HTML)
$this->mail->isHtml(true);
$config = KunenaConfig::getInstance();
$subject = $this->message->subject ? $this->message->subject : $this->message->getTopic()->subject;
$author = $this->message->getAuthor();
?>

<h2><?php 
echo JText::_('COM_KUNENA_POST_EMAIL_MOD1') . " " . $config->board_title;
?>
</h2>

<div><?php 
echo JText::_('COM_KUNENA_MESSAGE_SUBJECT') . " : " . $subject;
?>
</div>
<div><?php 
echo JText::_('COM_KUNENA_CATEGORY') . " : " . $this->message->getCategory()->name;
?>
Example #19
0
	/**
	 * Upload and resize if needed the new avatar for user, or set one from the gallery or the default one
	 *
	 * @return boolean
	 */
	protected function saveAvatar()
	{
		$action         = JRequest::getString('avatar', 'keep');
		$current_avatar = $this->me->avatar;

		$avatarFile = $this->app->input->files->get('avatarfile');

		if (!empty($avatarFile['tmp_name']))
		{
			if ($avatarFile['size'] < intval(KunenaConfig::getInstance()->avatarsize) * 1024)
			{
				$this->deleteOldAvatars();
			}

			$upload = KunenaUpload::getInstance(array('gif, jpeg, jpg, png'));

			$uploaded = $upload->upload($avatarFile, KPATH_MEDIA . '/avatars/users/avatar' . $this->me->userid, 'avatar');

			if (!empty($uploaded))
			{
				$imageInfo = KunenaImage::getImageFileProperties($uploaded->destination);

				// If image is not inside allowed size limits, resize it
				if ($uploaded->size > intval($this->config->avatarsize) * 1024 || $imageInfo->width > '200' || $imageInfo->height > '200')
				{
					if ($this->config->avatarquality < 1 || $this->config->avatarquality > 100)
					{
						$quality = 70;
					}
					else
					{
						$quality = $this->config->avatarquality;
					}

					$resized = KunenaImageHelper::version($uploaded->destination, KPATH_MEDIA . '/avatars/users', 'avatar' . $this->me->userid . '.' . $uploaded->ext, 200, 200, $quality, KunenaImage::SCALE_INSIDE, $this->config->avatarcrop);
				}

				$this->app->enqueueMessage(JText::sprintf('COM_KUNENA_PROFILE_AVATAR_UPLOADED'));
				$this->me->avatar = 'users/avatar' . $this->me->userid . '.' . $uploaded->ext;
			}
			else
			{
				$this->me->avatar = $current_avatar;
				return false;
			}
		}
		elseif ($action == 'delete')
		{
			$this->deleteOldAvatars();

			// Set default avatar
			$this->me->avatar = '';
		}
		elseif (substr($action, 0, 8) == 'gallery/' && strpos($action, '..') === false)
		{
			$this->me->avatar = $action;
		}

		return true;
	}
Example #20
0
	$lang->load('com_kunena.install', JPATH_ADMINISTRATOR . '/components/com_kunena');
	JResponse::setHeader('Status', '503 Service Temporarily Unavailable', true);
	?>
	<h2><?php echo JText::_('COM_KUNENA_INSTALL_OFFLINE_TOPIC') ?></h2>
	<div><?php echo JText::_('COM_KUNENA_INSTALL_OFFLINE_DESC') ?></div>
	<?php
	return;
}

// Display time it took to create the entire page in the footer.
$kunena_profiler = KunenaProfiler::instance('Kunena');
$kunena_profiler->start('Total Time');
KUNENA_PROFILER ? $kunena_profiler->mark('afterLoad') : null;

// Prevent direct access to the component if the option has been disabled.
if (!KunenaConfig::getInstance()->get('access_component', 1))
{
	$active = JFactory::getApplication()->getMenu()->getActive();

	if (!$active)
	{
		// Prevent access without using a menu item.
		JLog::add("Kunena: Direct access denied: " . JUri::getInstance()->toString(array('path', 'query')), JLog::WARNING, 'kunena');
		JError::raiseError(404, JText::_('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND'));
	}
	elseif ($active->type != 'component' || $active->component != 'com_kunena')
	{
		// Prevent spoofed access by using random menu item.
		JLog::add("Kunena: spoofed access denied: " . JUri::getInstance()->toString(array('path', 'query')), JLog::WARNING, 'kunena');
		JError::raiseError(404, JText::_('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND'));
	}
Example #21
0
 /**
  * Upload files with AJAX.
  *
  * @throws RuntimeException
  */
 public function upload()
 {
     // Only support JSON requests.
     if ($this->input->getWord('format', 'html') != 'json') {
         throw new RuntimeException(JText::_('Bad Request'), 400);
     }
     $upload = KunenaUpload::getInstance();
     // We are converting all exceptions into JSON.
     try {
         if (!JSession::checkToken('request')) {
             throw new RuntimeException(JText::_('Forbidden'), 403);
         }
         $me = KunenaUserHelper::getMyself();
         $catid = $this->input->getInt('catid', 0);
         $mesid = $this->input->getInt('mesid', 0);
         if ($mesid) {
             $message = KunenaForumMessageHelper::get($mesid);
             $message->tryAuthorise('attachment.create');
             $category = $message->getCategory();
         } else {
             $category = KunenaForumCategoryHelper::get($catid);
             // TODO: Some room for improvements in here... (maybe ask user to pick up category first)
             if ($category->id) {
                 if (stripos($this->input->getString('mime'), 'image/') !== false) {
                     $category->tryAuthorise('topic.post.attachment.createimage');
                 } else {
                     $category->tryAuthorise('topic.post.attachment.createfile');
                 }
             }
         }
         $caption = $this->input->getString('caption');
         $options = array('filename' => $this->input->getString('filename'), 'size' => $this->input->getInt('size'), 'mime' => $this->input->getString('mime'), 'hash' => $this->input->getString('hash'), 'chunkStart' => $this->input->getInt('chunkStart', 0), 'chunkEnd' => $this->input->getInt('chunkEnd', 0));
         // Upload!
         $upload->addExtensions(KunenaAttachmentHelper::getExtensions($category->id, $me->userid));
         $response = (object) $upload->ajaxUpload($options);
         if (!empty($response->completed)) {
             // We have it all, lets create the attachment.
             $uploadFile = $upload->getProtectedFile();
             list($basename, $extension) = $upload->splitFilename();
             $attachment = new KunenaAttachment();
             $attachment->bind(array('mesid' => 0, 'userid' => (int) $me->userid, 'protected' => null, 'hash' => $response->hash, 'size' => $response->size, 'folder' => null, 'filetype' => $response->mime, 'filename' => null, 'filename_real' => $response->filename, 'caption' => $caption));
             // Resize image if needed.
             if ($attachment->isImage()) {
                 $imageInfo = KunenaImage::getImageFileProperties($uploadFile);
                 $config = KunenaConfig::getInstance();
                 if ($imageInfo->width > $config->imagewidth || $imageInfo->height > $config->imageheight) {
                     // Calculate quality for both JPG and PNG.
                     $quality = $config->imagequality;
                     if ($quality < 1 || $quality > 100) {
                         $quality = 70;
                     }
                     if ($imageInfo->type == IMAGETYPE_PNG) {
                         $quality = intval(($quality - 1) / 10);
                     }
                     $image = new KunenaImage($uploadFile);
                     $image = $image->resize($config->imagewidth, $config->imageheight, false);
                     $options = array('quality' => $quality);
                     $image->toFile($uploadFile, $imageInfo->type, $options);
                     unset($image);
                     $attachment->hash = md5_file($uploadFile);
                     $attachment->size = filesize($uploadFile);
                 }
             }
             $attachment->saveFile($uploadFile, $basename, $extension, true);
             // Set id and override response variables just in case if attachment was modified.
             $response->id = $attachment->id;
             $response->hash = $attachment->hash;
             $response->size = $attachment->size;
             $response->mime = $attachment->filetype;
             $response->filename = $attachment->filename_real;
         }
     } catch (Exception $response) {
         $upload->cleanup();
         // Use the exception as the response.
     }
     header('Content-type: application/json');
     header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
     header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
     header("Cache-Control: no-store, no-cache, must-revalidate");
     header("Cache-Control: post-check=0, pre-check=0", false);
     header("Pragma: no-cache");
     while (@ob_end_clean()) {
     }
     echo $upload->ajaxResponse($response);
     jexit();
 }
Example #22
0
 function SefExt_com_kunena()
 {
     if (is_null(self::$kunenaprefix)) {
         // Check Kunena component version
         $db =& JFactory::getDbo();
         $query = "SELECT `manifest_cache` FROM `#__extensions` WHERE `type` = 'component' AND `element` = 'com_kunena'";
         $db->setQuery($query);
         $data = $db->loadResult();
         if (is_null($data)) {
             // Version < 1.6 (used manifest.xml)
             $ver = '1.5';
         } else {
             // Check version
             $data = json_decode($data);
             if (isset($data->version)) {
                 $ver = $data->version;
             } else {
                 $ver = '1.5';
             }
         }
         if (version_compare($ver, '1.6.0', '<')) {
             // Before 1.6
             self::$kunenaprefix = 'fb';
             self::$fieldCatParent = 'parent';
         } else {
             // 1.6 or higher
             self::$is16 = true;
             self::$kunenaprefix = 'kunena';
             if (version_compare($ver, '2.0.0', '<')) {
                 // Lower than 2.0
                 self::$fieldCatParent = 'parent';
             } else {
                 // 2.0 or higher
                 self::$is20 = true;
                 self::$fieldCatParent = 'parent_id';
                 if (version_compare($ver, '2.0.2', '>=')) {
                     // 2.0.2 or higher
                     self::$hasAlias = true;
                 }
             }
         }
         self::$tableMessages = '`#__' . self::$kunenaprefix . '_messages`';
         self::$tableCategories = '`#__' . self::$kunenaprefix . '_categories`';
         self::$tableAnnouncement = '`#__' . self::$kunenaprefix . '_announcement`';
         // Get Kunena configuration
         global $fbConfig;
         if (is_object($fbConfig)) {
             self::$kunenaConfig = $fbConfig;
         } else {
             $file = JPATH_ROOT . '/administrator/components/com_kunena/libraries/config.php';
             $file2 = JPATH_ROOT . '/components/com_kunena/lib/kunena.config.class.php';
             $file3 = JPATH_ROOT . '/libraries/kunena/config.php';
             if (file_exists($file3)) {
                 jimport('kunena.config');
                 self::$kunenaConfig = KunenaConfig::getInstance();
             } else {
                 if (file_exists($file)) {
                     require_once $file;
                     self::$kunenaConfig = KunenaConfig::getInstance();
                 } else {
                     if (file_exists($file2)) {
                         require_once $file2;
                         self::$kunenaConfig = new CKunenaConfig();
                         self::$kunenaConfig->load();
                     }
                 }
             }
             $fbConfig = self::$kunenaConfig;
         }
     }
     // call parent constructor
     parent::__construct();
 }
Example #23
0
 /**
  * Render user signature.
  *
  * @return string
  *
  * @since  K4.0
  */
 public function getSignature()
 {
     if (!isset($this->_signature)) {
         $this->_signature = KunenaHtmlParser::parseBBCode($this->signature, $this, KunenaConfig::getInstance()->maxsig);
     }
     return $this->_signature;
 }
Example #24
0
 /**
  * Check if filesize on image file which on going to be uploaded doesn't exceed the limits set by Kunena configuration and PHP configuration
  *
  * @param   int      $filesize  The size of file in bytes
  *
  * @return boolean
  */
 protected function checkFileSizeImageAttachment($filesize)
 {
     $image = $filesize > intval(KunenaConfig::getInstance()->imagesize * 1024);
     if ($image) {
         return false;
     }
     return (int) max(0, min($this->toBytes(ini_get('upload_max_filesize')) - 1024, $this->toBytes(ini_get('post_max_size')) - 1024, $this->toBytes(ini_get('memory_limit')) - 1024 * 1024));
 }
Example #25
0
<?php

/**
 * Kunena Component
 * @package     Kunena.Template.Crypsis
 * @subpackage  Layout.User
 *
 * @copyright   (C) 2008 - 2015 Kunena Team. All rights reserved.
 * @license     http://www.gnu.org/copyleft/gpl.html GNU/GPL
 * @link        http://www.kunena.org
 **/
defined('_JEXEC') or die;
// @var KunenaUser $user
$user = $this->user;
$avatar = $user->getAvatarImage('img-polaroid', 'post');
$show = KunenaConfig::getInstance()->showuserstats;
$activityIntegration = KunenaFactory::getActivityIntegration();
$points = $activityIntegration->getUserPoints($user->userid);
$medals = $activityIntegration->getUserMedals($user->userid);
if ($show) {
    $rankImage = $user->getRank($this->category_id, 'image');
    $rankTitle = $user->getRank($this->category_id, 'title');
    $personalText = $user->getPersonalText();
}
?>
<ul class="unstyled center profilebox">
	<li>
		<strong><?php 
echo $user->getLink(null, null, 'nofollow', '', null, $this->category_id);
?>
</strong>
Example #26
0
 /**
  * Prepare attachment display.
  *
  * @return void
  */
 protected function before()
 {
     // Load language files.
     KunenaFactory::loadLanguage('com_kunena.sys', 'admin');
     $this->me = KunenaUserHelper::getMyself();
     $this->config = KunenaConfig::getInstance();
     $this->document = JFactory::getDocument();
 }
Example #27
0
 /**
  * @param KunenaUser $user
  *
  * @return KunenaExceptionAuthorise|null
  *
  * @since  K4.0
  */
 protected function authoriseRead(KunenaUser $user)
 {
     // Checks if attachment exists
     if (!$this->exists()) {
         return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_ATTACHMENT_NO_ACCESS'), 404);
     }
     if (!$user->exists()) {
         $config = KunenaConfig::getInstance();
         if ($this->isImage() && !$config->showimgforguest) {
             return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_SHOWIMGFORGUEST_HIDEIMG'), 401);
         }
         if (!$this->isImage() && !$config->showfileforguest) {
             return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_SHOWIMGFORGUEST_HIDEFILE'), 401);
         }
     }
     return null;
 }
Example #28
0
 /**
  * Method to retrieve the URL of category RSS feed
  *
  * @param   int    $catid The Id of category
  * @param   string $xhtml Replace & by & for XML compliance.
  *
  * @return string|null
  */
 public function getCategoryRSSURL($catid, $xhtml = true)
 {
     if (KunenaConfig::getInstance()->enablerss) {
         $params = '&catid=' . (int) $catid;
         return KunenaRoute::_("index.php?option=com_kunena&view=topics&format=feed&layout=default&mode=topics{$params}", $xhtml);
     }
     return null;
 }
Example #29
0
 public function reset()
 {
     $instance = new KunenaConfig();
     $this->bind($instance->getProperties());
 }
Example #30
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     parent::__construct();
     $this->limit = KunenaConfig::getInstance()->threads_per_page;
 }