static function execute() { $conf = TConf::getConfig(); require_once(JPATH_BASE.'/administrator/components/com_adsmanager/models/cron.php'); $cronmodel = new AdsmanagerModelCron(); $last = $cronmodel->getLastCronTime(); $current = time(); $cronmodel->saveCronTime($current); //Daily Action if (date("d",$current) != date("d",$last)) { if ($conf->crontype != "onrequest") echo "Daily Action<br/>\n"; $contentmodel = new AdsmanagerModelContent(); $fieldmodel = new AdsmanagerModelField(); $contentmodel->manage_expiration($fieldmodel->getPlugins(),$conf); } //Hourly Action if (date("H",$current) != date("H",$last)) { if ($conf->crontype != "onrequest") echo "Hourly Action<br/>\n"; if (function_exists("managePaidOption")) { managePaidOption(); } $db = JFactory::getDbo(); $query = "SELECT id FROM #__adsmanager_ads"; $db->setQuery($query); $ads = $db->loadObjectList(); foreach($ads as $ad) { $query = "UPDATE #__adsmanager_ads SET ordering = ".rand(0, 1000)." WHERE id = ".(int)$ad->id; $db->setQuery($query); $db->query(); } } }
function display($cachable = false, $urlparams = false) { $app = JFactory::getApplication(); $document = JFactory::getDocument(); $user = JFactory::getUser(); if (!JRequest::getCmd('view')) { $default = 'front'; JRequest::setVar('view', $default); } $viewName = JRequest::getVar('view', 'front', 'default', 'cmd'); $type = JRequest::getVar('format', 'html', 'default', 'cmd'); $view = $this->getView($viewName, $type); if ($viewName == "edit") { $this->write(); return; } $uri = JFactory::getURI(); $baseurl = JURI::base(); $view->assign("baseurl", $baseurl); $view->assignRef("baseurl", $baseurl); if ($type == "html" && !defined('_ADSMANAGER_CSS')) { /** ensure that functions are declared only once */ define('_ADSMANAGER_CSS', 1); $uri = JFactory::getURI(); $baseurl = JURI::base(); $document = JFactory::getDocument(); $app = JFactory::getApplication(); $templateDir = JPATH_ROOT . '/templates/' . $app->getTemplate(); if (is_file($templateDir . '/html/com_adsmanager/css/adsmanager.css')) { $templateDir = JURI::base() . 'templates/' . $app->getTemplate(); $document->addStyleSheet($templateDir . '/html/com_adsmanager/css/adsmanager.css'); } else { $document->addStyleSheet($baseurl . 'components/com_adsmanager/css/adsmanager.css'); } } // Push a model into the view $this->addModelPath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_adsmanager' . DS . 'models'); $contentmodel = $this->getModel("content"); $catmodel = $this->getModel("category"); $positionmodel = $this->getModel("position"); $columnmodel = $this->getModel("column"); $fieldmodel = $this->getModel("field"); $usermodel = $this->getModel("user"); $adsmanagermodel = $this->getModel("adsmanager"); $configurationmodel = $this->getModel("configuration"); if (!JError::isError($contentmodel)) { $view->setModel($contentmodel, true); } $view->setModel($contentmodel); $view->setModel($catmodel); $view->setModel($positionmodel); $view->setModel($columnmodel); $view->setModel($fieldmodel); $view->setModel($usermodel); $view->setModel($adsmanagermodel); $view->setModel($configurationmodel); $conf = $configurationmodel->getConfiguration(); if (ADSMANAGER_SPECIAL == "abrivac" && (JRequest::getCmd('view') == 'front' || JRequest::getCmd('view') == 'rules')) { return; } if (file_exists(JPATH_BASE . '/components/com_adsmanager/cron.php')) { require_once JPATH_BASE . '/components/com_adsmanager/cron.php'; } if ($last_cron_date != date("Ymd")) { $contentmodel->manage_expiration($fieldmodel->getPlugins(), $conf); } if (function_exists("managePaidOption")) { managePaidOption(); } if ($viewName == "details") { $contentid = JRequest::getInt('id', 0); $content = $contentmodel->getContent($contentid, false); // increment views. views from ad author are not counted to prevent highclicking views of own ad if ($user->id != $content->userid || $content->userid == 0) { $contentmodel->increaseHits($content->id); } } if ($viewName == "list" && $user->get('id') == 0 && JRequest::getInt('user', -1) == 0) { TTools::redirectToLogin("index.php?option=com_adsmanager&view=list&user="******"result") { parent::display(false); } else { if ($viewName == "list") { $cache = JFactory::getCache('com_adsmanager'); $method = array($view, 'display'); $session = JFactory::getSession(); $tsearch = JRequest::getVar('tsearch', $session->get('tsearch', '', 'adsmanager')); $limit = $conf->ads_per_page; $order = $app->getUserStateFromRequest('com_adsmanager.front_content.order', 'order', 0, 'int'); $mode = $app->getUserStateFromRequest('com_adsmanager.front_content.mode', 'mode', $conf->display_expand); $url = $uri->toString(); echo $cache->call($method, null, $url, $tsearch, $limit, $order, $mode) . "\n"; } else { parent::display(true); } } } $path = JPATH_ADMINISTRATOR . '/../libraries/joomla/database/table'; JTable::addIncludePath($path); }