File manager - Edit - /home/capoccitel/www/wp-admin/com_banners.tar
Back
helpers/banner.php 0000604 00000001721 15242037142 0010161 0 ustar 00 <?php /** * @package Joomla.Site * @subpackage com_banners * * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Banner Helper Class * * @since 1.6 */ abstract class BannerHelper { /** * Checks if a URL is an image * * @param string $url The URL path to the potential image * * @return boolean True if an image of type bmp, gif, jp(e)g or png, false otherwise * * @since 1.6 */ public static function isImage($url) { return preg_match('#\.(?:bmp|gif|jpe?g|png)$#i', $url); } /** * Checks if a URL is a Flash file * * @param string $url The URL path to the potential flash file * * @return boolean True if an image of type bmp, gif, jp(e)g or png, false otherwise * * @since 1.6 */ public static function isFlash($url) { return preg_match('#\.swf$#i', $url); } } helpers/category.php 0000604 00000001171 15242037142 0010530 0 ustar 00 <?php /** * @package Joomla.Site * @subpackage com_banners * * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Banners Component Category Tree * * @since 1.6 */ class BannersCategories extends JCategories { /** * Constructor * * @param array $options Array of options * * @since 1.6 */ public function __construct($options = array()) { $options['table'] = '#__banners'; $options['extension'] = 'com_banners'; parent::__construct($options); } } helpers/index.html 0000705 00000000037 15242037142 0010201 0 ustar 00 <!DOCTYPE html><title></title> models/index.html 0000705 00000000037 15242037142 0010022 0 ustar 00 <!DOCTYPE html><title></title> models/banner.php 0000604 00000010221 15242037142 0007775 0 ustar 00 <?php /** * @package Joomla.Site * @subpackage com_banners * * @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . '/tables'); /** * Banner model for the Joomla Banners component. * * @since 1.5 */ class BannersModelBanner extends JModelLegacy { /** * Cached item object * * @var object * @since 1.6 */ protected $_item; /** * Clicks the URL, incrementing the counter * * @return void * * @since 1.5 */ public function click() { $item = $this->getItem(); if (empty($item)) { throw new Exception(JText::_('JERROR_PAGE_NOT_FOUND'), 404); } $id = $this->getState('banner.id'); // Update click count $db = $this->getDbo(); $query = $db->getQuery(true) ->update('#__banners') ->set('clicks = (clicks + 1)') ->where('id = ' . (int) $id); $db->setQuery($query); try { $db->execute(); } catch (RuntimeException $e) { JError::raiseError(500, $e->getMessage()); } // Track clicks $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:00:00'); $trackDate = JFactory::getDate($trackDate)->toSql(); $query->clear() ->select($db->quoteName('count')) ->from('#__banner_tracks') ->where('track_type=2') ->where('banner_id=' . (int) $id) ->where('track_date=' . $db->quote($trackDate)); $db->setQuery($query); try { $db->execute(); } catch (RuntimeException $e) { JError::raiseError(500, $e->getMessage()); } $count = $db->loadResult(); $query->clear(); if ($count) { // Update count $query->update('#__banner_tracks') ->set($db->quoteName('count') . ' = (' . $db->quoteName('count') . ' + 1)') ->where('track_type=2') ->where('banner_id=' . (int) $id) ->where('track_date=' . $db->quote($trackDate)); } else { // Insert new count $query->insert('#__banner_tracks') ->columns( array( $db->quoteName('count'), $db->quoteName('track_type'), $db->quoteName('banner_id'), $db->quoteName('track_date') ) ) ->values('1, 2,' . (int) $id . ',' . $db->quote($trackDate)); } $db->setQuery($query); try { $db->execute(); } catch (RuntimeException $e) { JError::raiseError(500, $e->getMessage()); } } } /** * Get the data for a banner. * * @return object * * @since 1.6 */ public function &getItem() { if (!isset($this->_item)) { /** @var JCacheControllerCallback $cache */ $cache = JFactory::getCache('com_banners', 'callback'); $id = $this->getState('banner.id'); // For PHP 5.3 compat we can't use $this in the lambda function below, so grab the database driver now to use it $db = $this->getDbo(); $loader = function ($id) use ($db) { $query = $db->getQuery(true) ->select( array( $db->quoteName('a.clickurl', 'clickurl'), $db->quoteName('a.cid', 'cid'), $db->quoteName('a.track_clicks', 'track_clicks'), $db->quoteName('cl.track_clicks', 'client_track_clicks'), ) ) ->from($db->quoteName('#__banners', 'a')) ->join('LEFT', '#__banner_clients AS cl ON cl.id = a.cid') ->where('a.id = ' . (int) $id); $db->setQuery($query); return $db->loadObject(); }; try { $this->_item = $cache->get($loader, array($id), md5(__METHOD__ . $id)); } catch (JCacheException $e) { $this->_item = $loader($id); } } return $this->_item; } /** * Get the URL for a banner * * @return string * * @since 1.5 */ public 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; } } models/banners.php 0000604 00000021130 15242037142 0010161 0 ustar 00 <?php /** * @package Joomla.Site * @subpackage com_banners * * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\Registry\Registry; use Joomla\Utilities\ArrayHelper; JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . '/tables'); /** * Banners model for the Joomla Banners component. * * @since 1.6 */ class BannersModelBanners extends JModelList { /** * 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. * * @since 1.6 */ protected function getStoreId($id = '') { // Compile the store id. $id .= ':' . $this->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); } /** * Method to get a JDatabaseQuery object for retrieving the data set from a database. * * @return JDatabaseQuery A JDatabaseQuery object to retrieve the data set. * * @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()); $nowDate = $db->quote(JFactory::getDate()->toSql()); $query->select( 'a.id as id,' . 'a.type as type,' . 'a.name as name,' . 'a.clickurl as clickurl,' . 'a.cid as cid,' . 'a.description as description,' . 'a.params as params,' . 'a.custombannercode as custombannercode,' . 'a.track_impressions as track_impressions,' . 'cl.track_impressions as client_track_impressions' ) ->from('#__banners as a') ->join('LEFT', '#__banner_clients AS cl ON cl.id = a.cid') ->where('a.state=1') ->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')') ->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')') ->where('(a.imptotal = 0 OR a.impmade < a.imptotal)'); if ($cid) { $query->where('a.cid = ' . (int) $cid) ->where('cl.state = 1'); } // Filter by a single or group of categories 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') ->from('#__categories as sub') ->join('INNER', '#__categories as this ON sub.lft > this.lft AND sub.rgt < this.rgt') ->where('this.id = ' . (int) $categoryId) ->where('sub.level <= this.level + ' . $levels); // Add the subquery to the main query $query->where('(' . $categoryEquals . ' OR a.catid IN (' . (string) $subQuery . '))'); } else { $query->where($categoryEquals); } } elseif (is_array($categoryId) && (count($categoryId) > 0)) { $categoryId = ArrayHelper::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 (!$keywords) { $query->where('0 != 0'); } else { $temp = array(); $config = JComponentHelper::getParams('com_banners'); $prefix = $config->get('metakey_prefix'); if ($categoryId) { $query->join('LEFT', '#__categories as cat ON a.catid = cat.id'); } foreach ($keywords as $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)) ? '0 = 0' : '0 != 0'); $regexp = $db->quote("[[:<:]]" . $db->escape($keyword) . "[[:>:]]"); $condition2 = "a.metakey " . $query->regexp($regexp) . " "; if ($cid) { $condition2 .= " OR cl.metakey " . $query->regexp($regexp) . " "; } if ($categoryId) { $condition2 .= " OR cat.metakey " . $query->regexp($regexp) . " "; } $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 ? $query->Rand() : 'a.ordering')); return $query; } /** * Get a list of banners. * * @return array * * @since 1.6 */ public function getItems() { if ($this->getState('filter.tag_search')) { // Filter out empty keywords. $keywords = array_values(array_filter(array_map('trim', $this->getState('filter.keywords')), 'strlen')); // Re-set state before running the query. $this->setState('filter.keywords', $keywords); // If no keywords are provided, avoid running the query. if (!$keywords) { $this->cache['items'] = array(); return $this->cache['items']; } } if (!isset($this->cache['items'])) { $this->cache['items'] = parent::getItems(); foreach ($this->cache['items'] as &$item) { $item->params = new Registry($item->params); } } 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:00:00'); $trackDate = JFactory::getDate($trackDate)->toSql(); $items = $this->getItems(); $db = $this->getDbo(); $query = $db->getQuery(true); if (!count($items)) { return; } foreach ($items as $item) { $bid[] = (int) $item->id; } // Increment impression made $query->clear() ->update('#__banners') ->set('impmade = (impmade + 1)') ->where('id IN (' . implode(',', $bid) . ')'); $db->setQuery($query); try { $db->execute(); } catch (JDatabaseExceptionExecuting $e) { JError::raiseError(500, $e->getMessage()); } foreach ($items as $item) { // 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? // Update count $query->clear(); $query->update('#__banner_tracks') ->set($db->quoteName('count') . ' = (' . $db->quoteName('count') . ' + 1)') ->where('track_type=1') ->where('banner_id=' . (int) $item->id) ->where('track_date=' . $db->quote($trackDate)); $db->setQuery($query); try { $db->execute(); } catch (JDatabaseExceptionExecuting $e) { JError::raiseError(500, $e->getMessage()); } if ($db->getAffectedRows() === 0) { // Insert new count $query->clear(); $query->insert('#__banner_tracks') ->columns( array( $db->quoteName('count'), $db->quoteName('track_type'), $db->quoteName('banner_id'), $db->quoteName('track_date') ) ) ->values('1, 1, ' . (int) $item->id . ', ' . $db->quote($trackDate)); $db->setQuery($query); try { $db->execute(); } catch (JDatabaseExceptionExecuting $e) { JError::raiseError(500, $e->getMessage()); } } } } } } index.html 0000705 00000000037 15242037142 0006537 0 ustar 00 <!DOCTYPE html><title></title> router.php 0000604 00000005232 15242037142 0006573 0 ustar 00 <?php /** * @package Joomla.Site * @subpackage com_banners * * @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Routing class from com_banners * * @since 3.3 */ class BannersRouter extends JComponentRouterBase { /** * Build the route for the com_banners component * * @param array &$query An array of URL arguments * * @return array The URL arguments to use to assemble the subsequent URL. * * @since 3.3 */ public function build(&$query) { $segments = array(); if (isset($query['task'])) { $segments[] = $query['task']; unset($query['task']); } if (isset($query['id'])) { $segments[] = $query['id']; unset($query['id']); } $total = count($segments); for ($i = 0; $i < $total; $i++) { $segments[$i] = str_replace(':', '-', $segments[$i]); } return $segments; } /** * Parse the segments of a URL. * * @param array &$segments The segments of the URL to parse. * * @return array The URL attributes to be used by the application. * * @since 3.3 */ public function parse(&$segments) { $total = count($segments); $vars = array(); for ($i = 0; $i < $total; $i++) { $segments[$i] = preg_replace('/-/', ':', $segments[$i], 1); } // View is always the first element of the array $count = count($segments); if ($count) { $count--; $segment = array_shift($segments); if (is_numeric($segment)) { $vars['id'] = $segment; } else { $vars['task'] = $segment; } } if ($count) { $segment = array_shift($segments); if (is_numeric($segment)) { $vars['id'] = $segment; } } return $vars; } } /** * Build the route for the com_banners component * * This function is a proxy for the new router interface * for old SEF extensions. * * @param array &$query An array of URL arguments * * @return array The URL arguments to use to assemble the subsequent URL. * * @since 3.3 * @deprecated 4.0 Use Class based routers instead */ function bannersBuildRoute(&$query) { $router = new BannersRouter; return $router->build($query); } /** * Parse the segments of a URL. * * This function is a proxy for the new router interface * for old SEF extensions. * * @param array $segments The segments of the URL to parse. * * @return array The URL attributes to be used by the application. * * @since 3.3 * @deprecated 4.0 Use Class based routers instead */ function bannersParseRoute($segments) { $router = new BannersRouter; return $router->parse($segments); } controller.php 0000604 00000001331 15242037142 0007432 0 ustar 00 <?php /** * @package Joomla.Site * @subpackage com_banners * * @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Banners Controller * * @since 1.5 */ class BannersController extends JControllerLegacy { /** * Method when a banner is clicked on. * * @return void * * @since 1.5 */ public function click() { $id = $this->input->getInt('id', 0); if ($id) { $model = $this->getModel('Banner', 'BannersModel', array('ignore_request' => true)); $model->setState('banner.id', $id); $model->click(); $this->setRedirect($model->getUrl()); } } } banners.php 0000604 00000000630 15242037142 0006700 0 ustar 00 <?php /** * @package Joomla.Site * @subpackage com_banners * * @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; $controller = JControllerLegacy::getInstance('Banners'); $controller->execute(JFactory::getApplication()->input->get('task')); $controller->redirect();
| ver. 1.6 |
Github
|
.
| PHP 7.4.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings