AAAAPK÷‘?\Vùùÿ newsfeed.phpnuW+A„¶setState('newsfeed.id', $pk); $offset = JRequest::getUInt('limitstart', 0); $this->setState('list.offset', $offset); // Load the parameters. $params = $app->getParams(); $this->setState('params', $params); $user = JFactory::getUser(); if ((!$user->authorise('core.edit.state', 'com_newsfeeds')) && (!$user->authorise('core.edit', 'com_newsfeeds'))){ $this->setState('filter.published', 1); $this->setState('filter.archived', 2); } } /** * Method to get newsfeed data. * * @param integer The id of the newsfeed. * * @return mixed Menu item data object on success, false on failure. * @since 1.6 */ public function &getItem($pk = null) { // Initialise variables. $pk = (!empty($pk)) ? $pk : (int) $this->getState('newsfeed.id'); if ($this->_item === null) { $this->_item = array(); } if (!isset($this->_item[$pk])) { try { $db = $this->getDbo(); $query = $db->getQuery(true); $query->select($this->getState('item.select', 'a.*')); $query->from('#__newsfeeds AS a'); // Join on category table. $query->select('c.title AS category_title, c.alias AS category_alias, c.access AS category_access'); $query->join('LEFT', '#__categories AS c on c.id = a.catid'); // Join on user table. $query->select('u.name AS author'); $query->join('LEFT', '#__users AS u on u.id = a.created_by'); // Join over the categories to get parent category titles $query->select('parent.title as parent_title, parent.id as parent_id, parent.path as parent_route, parent.alias as parent_alias'); $query->join('LEFT', '#__categories as parent ON parent.id = c.parent_id'); $query->where('a.id = ' . (int) $pk); // Filter by start and end dates. $nullDate = $db->Quote($db->getNullDate()); $nowDate = $db->Quote(JFactory::getDate()->toSql()); // Filter by published state. $published = $this->getState('filter.published'); $archived = $this->getState('filter.archived'); if (is_numeric($published)) { $query->where('(a.published = ' . (int) $published . ' OR a.published =' . (int) $archived . ')'); $query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')'); $query->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')'); $query->where('(c.published = ' . (int) $published . ' OR c.published =' . (int) $archived . ')'); } $db->setQuery($query); $data = $db->loadObject(); if ($error = $db->getErrorMsg()) { throw new Exception($error); } if (empty($data)) { throw new JException(JText::_('COM_NEWSFEEDS_ERROR_FEED_NOT_FOUND'), 404); } // Check for published state if filter set. if (((is_numeric($published)) || (is_numeric($archived))) && (($data->published != $published) && ($data->published != $archived))) { JError::raiseError(404, JText::_('COM_NEWSFEEDS_ERROR_FEED_NOT_FOUND')); } // Convert parameter fields to objects. $registry = new JRegistry; $registry->loadString($data->params); $data->params = clone $this->getState('params'); $data->params->merge($registry); $registry = new JRegistry; $registry->loadString($data->metadata); $data->metadata = $registry; // Compute access permissions. if ($access = $this->getState('filter.access')) { // If the access filter has been set, we already know this user can view. $data->params->set('access-view', true); } else { // If no access filter is set, the layout takes some responsibility for display of limited information. $user = JFactory::getUser(); $groups = $user->getAuthorisedViewLevels(); $data->params->set('access-view', in_array($data->access, $groups) && in_array($data->category_access, $groups)); } $this->_item[$pk] = $data; } catch (JException $e) { $this->setError($e); $this->_item[$pk] = false; } } return $this->_item[$pk]; } } PK÷‘?\ívèää category.phpnuW+A„¶_params)) { $params = new JRegistry(); $item->params = $params; $params->loadString($item->params); } } return $items; } /** * Method to build an SQL query to load the list data. * * @return string An SQL query * @since 1.6 */ protected function getListQuery() { $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); // Select required fields from the categories. $query->select($this->getState('list.select', 'a.*')); $query->from($db->quoteName('#__newsfeeds').' AS a'); $query->where('a.access IN ('.$groups.')'); // Filter by category. if ($categoryId = $this->getState('category.id')) { $query->where('a.catid = '.(int) $categoryId); $query->join('LEFT', '#__categories AS c ON c.id = a.catid'); $query->where('c.access IN ('.$groups.')'); } // Filter by state $state = $this->getState('filter.published'); if (is_numeric($state)) { $query->where('a.published = '.(int) $state); } // Filter by start and end dates. $nullDate = $db->Quote($db->getNullDate()); $date = JFactory::getDate(); $nowDate = $db->Quote($date->format($db->getDateFormat())); if ($this->getState('filter.publish_date')){ $query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')'); $query->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')'); } // Filter by language if ($this->getState('filter.language')) { $query->where('a.language in ('.$db->Quote(JFactory::getLanguage()->getTag()).','.$db->Quote('*').')'); } // Add the list ordering clause. $query->order($db->escape($this->getState('list.ordering', 'a.ordering')).' '.$db->escape($this->getState('list.direction', 'ASC'))); return $query; } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @since 1.6 */ protected function populateState($ordering = null, $direction = null) { // Initialise variables. $app = JFactory::getApplication(); $params = JComponentHelper::getParams('com_newsfeeds'); // List state information $limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit'), 'uint'); $this->setState('list.limit', $limit); $limitstart = JRequest::getUInt('limitstart', 0); $this->setState('list.start', $limitstart); $orderCol = JRequest::getCmd('filter_order', 'ordering'); if (!in_array($orderCol, $this->filter_fields)) { $orderCol = 'ordering'; } $this->setState('list.ordering', $orderCol); $listOrder = JRequest::getCmd('filter_order_Dir', 'ASC'); if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', ''))) { $listOrder = 'ASC'; } $this->setState('list.direction', $listOrder); $id = JRequest::getVar('id', 0, '', 'int'); $this->setState('category.id', $id); $user = JFactory::getUser(); if ((!$user->authorise('core.edit.state', 'com_newsfeeds')) && (!$user->authorise('core.edit', 'com_newsfeeds'))){ // limit to published for people who can't edit or edit.state. $this->setState('filter.published', 1); // Filter by start and end dates. $this->setState('filter.publish_date', true); } $this->setState('filter.language', $app->getLanguageFilter()); // Load the parameters. $this->setState('params', $params); } /** * Method to get category data for the current category * * @param int An optional ID * * @return object * @since 1.5 */ public function getCategory() { if(!is_object($this->_item)) { $app = JFactory::getApplication(); $menu = $app->getMenu(); $active = $menu->getActive(); $params = new JRegistry(); if($active) { $params->loadString($active->params); } $options = array(); $options['countItems'] = $params->get('show_cat_items', 1) || $params->get('show_empty_categories', 0); $categories = JCategories::getInstance('Newsfeeds', $options); $this->_item = $categories->get($this->getState('category.id', 'root')); if(is_object($this->_item)) { $this->_children = $this->_item->getChildren(); $this->_parent = false; if($this->_item->getParent()) { $this->_parent = $this->_item->getParent(); } $this->_rightsibling = $this->_item->getSibling(); $this->_leftsibling = $this->_item->getSibling(false); } else { $this->_children = false; $this->_parent = false; } } return $this->_item; } /** * Get the parent category. * * @param int An optional category id. If not supplied, the model state 'category.id' will be used. * * @return mixed An array of categories or false if an error occurs. */ public function getParent() { if (!is_object($this->_item)) { $this->getCategory(); } return $this->_parent; } /** * Get the sibling (adjacent) categories. * * @return mixed An array of categories or false if an error occurs. */ function &getLeftSibling() { if (!is_object($this->_item)) { $this->getCategory(); } return $this->_leftsibling; } function &getRightSibling() { if(!is_object($this->_item)) { $this->getCategory(); } return $this->_rightsibling; } /** * Get the child categories. * * @param int An optional category id. If not supplied, the model state 'category.id' will be used. * * @return mixed An array of categories or false if an error occurs. */ function &getChildren() { if(!is_object($this->_item)) { $this->getCategory(); } return $this->_children; } } PK÷‘?\¦V‰ index.htmlnuW+A„¶ PK÷‘?\®)ÕÐ .htaccessnuW+A„¶ Order allow,deny Deny from all PK÷‘?\ðüÁ Á categories.phpnuW+A„¶setState('filter.extension', $this->_extension); // Get the parent id if defined. $parentId = JRequest::getInt('id'); $this->setState('filter.parentId', $parentId); $params = $app->getParams(); $this->setState('params', $params); $this->setState('filter.published', 1); $this->setState('filter.access', true); } /** * Method to get a store id based on model configuration state. * * This is necessary because the model is used by the component and * different modules that might need different sets of data or different * ordering requirements. * * @param string $id A prefix for the store id. * * @return string A store id. */ protected function getStoreId($id = '') { // Compile the store id. $id .= ':'.$this->getState('filter.extension'); $id .= ':'.$this->getState('filter.published'); $id .= ':'.$this->getState('filter.access'); $id .= ':'.$this->getState('filter.parentId'); return parent::getStoreId($id); } /** * redefine the function an add some properties to make the styling more easy * * @return mixed An array of data items on success, false on failure. */ public function getItems() { if(!count($this->_items)) { $app = JFactory::getApplication(); $menu = $app->getMenu(); $active = $menu->getActive(); $params = new JRegistry(); if($active) { $params->loadString($active->params); } $options = array(); $options['countItems'] = $params->get('show_cat_items_cat', 1) || !$params->get('show_empty_categories_cat', 0); $categories = JCategories::getInstance('Newsfeeds', $options); $this->_parent = $categories->get($this->getState('filter.parentId', 'root')); if(is_object($this->_parent)) { $this->_items = $this->_parent->getChildren(); } else { $this->_items = false; } } return $this->_items; } public function getParent() { if(!is_object($this->_parent)) { $this->getItems(); } return $this->_parent; } } PKF¥?\ìÚñbÚÚ banners.phpnuW+A„¶getState('filter.search'); $id .= ':' . $this->getState('filter.tag_search'); $id .= ':' . $this->getState('filter.client_id'); $id .= ':' . serialize($this->getState('filter.category_id')); $id .= ':' . serialize($this->getState('filter.keywords')); return parent::getStoreId($id); } /** * Gets a list of banners * * @return array An array of banner objects. * @since 1.6 */ protected function getListQuery() { $db = $this->getDbo(); $query = $db->getQuery(true); $ordering = $this->getState('filter.ordering'); $tagSearch = $this->getState('filter.tag_search'); $cid = $this->getState('filter.client_id'); $categoryId = $this->getState('filter.category_id'); $keywords = $this->getState('filter.keywords'); $randomise = ($ordering == 'random'); $nullDate = $db->quote($db->getNullDate()); $query->select( 'a.id as id,'. 'a.type as type,'. 'a.name as name,'. 'a.clickurl as clickurl,'. 'a.cid as cid,'. 'a.params as params,'. 'a.custombannercode as custombannercode,'. 'a.track_impressions as track_impressions,'. 'cl.track_impressions as client_track_impressions' ); $query->from('#__banners as a'); $query->join('LEFT', '#__banner_clients AS cl ON cl.id = a.cid'); $query->where('a.state=1'); $query->where('('.$query->currentTimestamp().' >= a.publish_up OR a.publish_up = '.$nullDate.')'); $query->where('('.$query->currentTimestamp().' <= a.publish_down OR a.publish_down = '.$nullDate.')'); $query->where('(a.imptotal = 0 OR a.impmade <= a.imptotal)'); if ($cid) { $query->join('LEFT', '#__categories as cat ON a.catid = cat.id'); $query->where('a.cid = ' . (int) $cid); $query->where('cl.state = 1'); } // Filter by a single or group of categories $categoryId = $this->getState('filter.category_id'); $catid = $this->getState('filter.category_id', array()); if (is_numeric($categoryId)) { $type = $this->getState('filter.category_id.include', true) ? '= ' : '<> '; // Add subcategory check $includeSubcategories = $this->getState('filter.subcategories', false); $categoryEquals = 'a.catid '.$type.(int) $categoryId; if ($includeSubcategories) { $levels = (int) $this->getState('filter.max_category_levels', '1'); // Create a subquery for the subcategory list $subQuery = $db->getQuery(true); $subQuery->select('sub.id'); $subQuery->from('#__categories as sub'); $subQuery->join('INNER', '#__categories as this ON sub.lft > this.lft AND sub.rgt < this.rgt'); $subQuery->where('this.id = '.(int) $categoryId); $subQuery->where('sub.level <= this.level + '.$levels); // Add the subquery to the main query $query->where('('.$categoryEquals.' OR a.catid IN ('.$subQuery->__toString().'))'); } else { $query->where($categoryEquals); } } elseif ((is_array($categoryId)) && (count($categoryId) > 0)) { JArrayHelper::toInteger($categoryId); $categoryId = implode(',', $categoryId); if($categoryId != '0') { $type = $this->getState('filter.category_id.include', true) ? 'IN' : 'NOT IN'; $query->where('a.catid '.$type.' ('.$categoryId.')'); } } if ($tagSearch) { if (count($keywords) == 0) { $query->where('0'); } else { $temp = array(); $config = JComponentHelper::getParams('com_banners'); $prefix = $config->get('metakey_prefix'); foreach ($keywords as $keyword) { $keyword=trim($keyword); $condition1 = "a.own_prefix=1 AND a.metakey_prefix=SUBSTRING(".$db->quote($keyword).",1,LENGTH( a.metakey_prefix)) OR a.own_prefix=0 AND cl.own_prefix=1 AND cl.metakey_prefix=SUBSTRING(".$db->quote($keyword).",1,LENGTH(cl.metakey_prefix)) OR a.own_prefix=0 AND cl.own_prefix=0 AND ".($prefix==substr($keyword, 0, strlen($prefix))?'1':'0'); $condition2="a.metakey REGEXP '[[:<:]]".$db->escape($keyword) . "[[:>:]]'"; if ($cid) { $condition2.=" OR cl.metakey REGEXP '[[:<:]]".$db->escape($keyword) . "[[:>:]]'"; } if ($catid) { $condition2.=" OR cat.metakey REGEXP '[[:<:]]".$db->escape($keyword) . "[[:>:]]'"; } $temp[]="($condition1) AND ($condition2)"; } $query->where('(' . implode(' OR ', $temp). ')'); } } // Filter by language if ($this->getState('filter.language')) { $query->where('a.language in (' . $db->Quote(JFactory::getLanguage()->getTag()) . ',' . $db->Quote('*') . ')'); } $query->order('a.sticky DESC,'. ($randomise ? 'RAND()' : 'a.ordering')); return $query; } /** * Get a list of banners. * * @return array * @since 1.6 */ public function getItems() { if (!isset($this->cache['items'])) { $this->cache['items'] = parent::getItems(); foreach ($this->cache['items'] as &$item) { $parameters = new JRegistry; $parameters->loadString($item->params); $item->params = $parameters; } } return $this->cache['items']; } /** * Makes impressions on a list of banners * * @return void * @since 1.6 */ public function impress() { $trackDate = JFactory::getDate()->format('Y-m-d H'); $items = $this->getItems(); $db = $this->getDbo(); $query = $db->getQuery(true); foreach ($items as $item) { // Increment impression made $id = $item->id; $query->clear(); $query->update('#__banners'); $query->set('impmade = (impmade + 1)'); $query->where('id = '.(int)$id); $db->setQuery((string)$query); if (!$db->query()) { JError::raiseError(500, $db->getErrorMsg()); } // track impressions $trackImpressions = $item->track_impressions; if ($trackImpressions < 0 && $item->cid) { $trackImpressions = $item->client_track_impressions; } if ($trackImpressions < 0) { $config = JComponentHelper::getParams('com_banners'); $trackImpressions = $config->get('track_impressions'); } if ($trackImpressions > 0) { // is track already created ? $query->clear(); $query->select($db->quoteName('count')); $query->from('#__banner_tracks'); $query->where('track_type=1'); $query->where('banner_id=' . (int) $id); $query->where('track_date=' . $db->Quote($trackDate)); $db->setQuery((string)$query); if (!$db->query()) { JError::raiseError(500, $db->getErrorMsg()); } $count = $db->loadResult(); $query->clear(); if ($count) { // update count $query->update('#__banner_tracks'); $query->set($db->quoteName('count').' = ('.$db->quoteName('count').' + 1)'); $query->where('track_type=1'); $query->where('banner_id='.(int)$id); $query->where('track_date='.$db->Quote($trackDate)); } else { // insert new count //sqlsrv change $query->insert('#__banner_tracks'); $query->columns(array($db->quoteName('count'), $db->quoteName('track_type'), $db->quoteName('banner_id'), $db->quoteName('track_date'))); $query->values( '1, 1, ' . (int) $id . ', ' . $db->Quote($trackDate)); } $db->setQuery((string)$query); if (!$db->query()) { JError::raiseError(500, $db->getErrorMsg()); } } } } } PKF¥?\SL££ banner.phpnuW+A„¶getState('banner.id'); // update click count $db = $this->getDbo(); $query = $db->getQuery(true); $query->update('#__banners'); $query->set('clicks = (clicks + 1)'); $query->where('id = ' . (int) $id); $db->setQuery((string) $query); if (!$db->query()) { JError::raiseError(500, $db->getErrorMsg()); } // track clicks $item = $this->getItem(); $trackClicks = $item->track_clicks; if ($trackClicks < 0 && $item->cid) { $trackClicks = $item->client_track_clicks; } if ($trackClicks < 0) { $config = JComponentHelper::getParams('com_banners'); $trackClicks = $config->get('track_clicks'); } if ($trackClicks > 0) { $trackDate = JFactory::getDate()->format('Y-m-d H'); $query->clear(); $query->select($db->quoteName('count')); $query->from('#__banner_tracks'); $query->where('track_type=2'); $query->where('banner_id='.(int)$id); $query->where('track_date='.$db->Quote($trackDate)); $db->setQuery((string) $query); if (!$db->query()) { JError::raiseError(500, $db->getErrorMsg()); } $count = $db->loadResult(); $query->clear(); if ($count) { // update count $query->update('#__banner_tracks'); $query->set($db->quoteName('count').' = ('.$db->quoteName('count') . ' + 1)'); $query->where('track_type=2'); $query->where('banner_id='.(int)$id); $query->where('track_date='.$db->Quote($trackDate)); } else { // insert new count //sqlsrv change $query->insert('#__banner_tracks'); $query->columns(array($db->quoteName('count'), $db->quoteName('track_type'), $db->quoteName('banner_id') , $db->quoteName('track_date'))); $query->values( '1, 2,' . (int)$id . ',' . $db->Quote($trackDate)); } $db->setQuery((string) $query); if (!$db->query()) { JError::raiseError(500, $db->getErrorMsg()); } } } /** * Get the data for a banner. * * @return object */ function &getItem() { if (!isset($this->_item)) { $cache = JFactory::getCache('com_banners', ''); $id = $this->getState('banner.id'); $this->_item = $cache->get($id); if ($this->_item === false) { // redirect to banner url $db = $this->getDbo(); $query = $db->getQuery(true); $query->select( 'a.clickurl as clickurl,'. 'a.cid as cid,'. 'a.track_clicks as track_clicks' ); $query->from('#__banners as a'); $query->where('a.id = ' . (int) $id); $query->join('LEFT', '#__banner_clients AS cl ON cl.id = a.cid'); $query->select('cl.track_clicks as client_track_clicks'); $db->setQuery((string) $query); if (!$db->query()) { JError::raiseError(500, $db->getErrorMsg()); } $this->_item = $db->loadObject(); $cache->store($this->_item, $id); } } return $this->_item; } /** * Get the URL for a banner * * @return string */ function getUrl() { $item = $this->getItem(); $url = $item->clickurl; // check for links if (!preg_match('#http[s]?://|index[2]?\.php#', $url)) { $url = "http://$url"; } return $url; } } PK÷‘?\Vùùÿ newsfeed.phpnuW+A„¶PK÷‘?\ívèää Dcategory.phpnuW+A„¶PK÷‘?\¦V‰ d0index.htmlnuW+A„¶PK÷‘?\®)ÕÐ ½0.htaccessnuW+A„¶PK÷‘?\ðüÁ Á u1categories.phpnuW+A„¶PKF¥?\ìÚñbÚÚ t=banners.phpnuW+A„¶PKF¥?\SL££ ‰]banner.phpnuW+A„¶PKfl