static function getConfig() { if (!self::$_conf) { include_once(JPATH_ROOT.'/administrator/components/com_adsmanager/models/configuration.php'); $model = new AdsmanagerModelConfiguration(); self::$_conf = $model->getConfiguration(); } return self::$_conf; }
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(); } } }
static function getPMSLink($content,$pmsText=null) { if ($pmsText == null) { $conf = TConf::getConfig(); if ($conf->display_fullname == 1) $pmsText= sprintf(JText::_('ADSMANAGER_PMS_FORM'),$content->fullname); else $pmsText= sprintf(JText::_('ADSMANAGER_PMS_FORM'),$content->user); } if (is_dir(JPATH_ROOT.'/components/com_uddeim')) { $pmsLink = JRoute::_("index.php?option=com_uddeim&task=new&recip=".$content->userid); return '<a href="'.$pmsLink.'">'.$pmsText.'</a><br />'; } else if (is_dir(JPATH_ROOT.'/components/com_community')) { include_once JPATH_ROOT.'/components/com_community/libraries/core.php'; include_once JPATH_ROOT.'/components/com_community/libraries/messaging.php'; $pmsLink = CMessaging::getPopup($content->userid); return '<a onclick="'.$pmsLink.';return false;" href="#">'.$pmsText.'</a><br />'; } else { return JText::_('ADSMANAGER_PMS_ERROR'); } }
function _getSQLFilter($filters) { /* Filters */ $search = ""; if (isset($filters)) { foreach ($filters as $key => $filter) { if ($search == "") { $temp = " WHERE "; } else { $temp = " AND "; } switch ($key) { case 'rootid': if ((int) $filter == 0) { continue; } $list = $this->getAllSubCatids((int) $filter, false); $listids = implode(',', $list); $search .= $temp . "c.id IN ({$listids}) "; break; case 'category': if ((int) $filter == 0) { continue; } $list = $this->getAllSubCatids((int) $filter); $listids = implode(',', $list); $search .= $temp . "c.id IN ({$listids}) "; break; case 'user': $search .= $temp . "u.id = " . (int) $filter; break; case 'content_ad_headline': //$search .= $temp."a.ad_headline LIKE '%".$this->_db->getEscaped($filter,true)."%'";break; $search .= $temp . "a.ad_headline LIKE '%" . $filter . "%'"; break; case 'username': if (version_compare(JVERSION, '1.7.0', '<')) { $search .= $temp . "u.username LIKE '%" . $this->_db->getEscaped($filter, true) . "%'"; } else { $search .= $temp . "u.username LIKE '%" . $this->_db->escape($filter, true) . "%'"; } break; case 'content_id': $search .= $temp . "a.id = " . (int) $filter; break; case "phone": if (version_compare(JVERSION, '1.7.0', '<')) { $search .= $temp . " a.ad_phone LIKE '%" . $this->_db->getEscaped($filter, true) . "%'"; } else { $search .= $temp . " a.ad_phone LIKE '%" . $this->_db->escape($filter, true) . "%'"; } break; case "ip": if (version_compare(JVERSION, '1.7.0', '<')) { $search .= $temp . " a.ad_ip LIKE '%" . $this->_db->getEscaped($filter, true) . "%'"; } else { $search .= $temp . " a.ad_ip LIKE '%" . $this->_db->escape($filter, true) . "%'"; } break; case 'mag': $search .= $temp . "a.ad_magazine = " . $this->_db->Quote($filter); break; case "online": if ($filter == 1) { $search .= $temp . " (a.ad_publishtype = 'online' OR a.ad_publishtype = 'both')"; } else { $search .= $temp . " (a.ad_publishtype = 'offline' OR a.ad_publishtype = 'both')"; } break; case 'publish': $search .= $temp . " a.published = " . (int) $filter . " AND c.published = TRUE "; break; case 'fields': $search .= $temp . $filter; break; case 'search': if ($filter != "") { if (intval($filter) != 0) { $id = intval($filter); $idsearch = "((a.id = {$id}) OR"; } else { $idsearch = "("; } $filter = preg_replace('!\\s+!', ' ', $filter); $filter = str_replace(" ", " +", trim($filter)) . "*"; $search .= $temp . "{$idsearch} MATCH (a.ad_headline,a.ad_text) AGAINST (" . $this->_db->Quote($filter) . " IN BOOLEAN MODE)) "; } break; case 'publication_date': $search .= $temp . " a.publication_date <= NOW()"; break; } } } $currentSession = JSession::getInstance('none', array()); $filter = $currentSession->get("sqlglobalfilter", ""); if ($filter != "") { if (isset($filters['user'])) { $conf = TConf::getConfig(); if (@$conf->globalfilter_user == 0) { return $search; } } // si on a que le super filter car pas de recherche classique fieldsFilter = WHERE + super filter if ($search == " ") { $search = " WHERE {$filter} "; } else { // si on a une recherche il faut cumuler les deux fieldsFIlters = fieldFilter + AND + super filter $search .= " AND {$filter}"; } } return $search; }
function _getSQLFilter($filters) { /* Filters */ $search = ""; if (isset($filters)) { foreach ($filters as $key => $filter) { if ($search == "") { $temp = " WHERE "; } else { $temp = " AND "; } switch ($key) { case 'category': $catid = $filter; $this->_db->setQuery("SELECT c.id, c.name,c.parent " . " FROM #__adsmanager_categories as c " . "WHERE c.published = 1 ORDER BY c.parent,c.ordering"); $listcats = $this->_db->loadObjectList(); $list[] = $catid; $this->_recurseSearch($listcats, $list, $catid); $listids = implode(',', $list); $search .= $temp . "c.id IN ({$listids}) "; break; case 'user': $search .= $temp . "u.id = " . (int) $filter; break; case 'username': if (version_compare(JVERSION, '1.7.0', '<')) { $search .= $temp . "u.username LIKE '%" . $this->_db->getEscaped($filter, true) . "%'"; } else { $search .= $temp . "u.username LIKE '%" . $this->_db->escape($filter, true) . "%'"; } break; case 'content_id': $search .= $temp . "a.id = " . (int) $filter; break; case "phone": if (version_compare(JVERSION, '1.7.0', '<')) { $search .= $temp . " a.ad_phone LIKE '%" . $this->_db->getEscaped($filter, true) . "%'"; } else { $search .= $temp . " a.ad_phone LIKE '%" . $this->_db->escape($filter, true) . "%'"; } break; case "ip": if (version_compare(JVERSION, '1.7.0', '<')) { $search .= $temp . " a.ad_ip LIKE '%" . $this->_db->getEscaped($filter, true) . "%'"; } else { $search .= $temp . " a.ad_ip LIKE '%" . $this->_db->escape($filter, true) . "%'"; } break; case 'mag': $search .= $temp . "a.ad_magazine = " . $this->_db->Quote($filter); break; case "online": if ($filter == 1) { $search .= $temp . " (a.ad_publishtype = 'online' OR a.ad_publishtype = 'both')"; } else { $search .= $temp . " (a.ad_publishtype = 'offline' OR a.ad_publishtype = 'both')"; } break; case 'publish': $search .= $temp . " a.published = " . (int) $filter . " AND c.published = TRUE "; break; case 'fields': $search .= $temp . $filter; break; case 'search': if (intval($filter) != 0) { $filter = JString::strtolower($filter); $id = intval($filter); if (version_compare(JVERSION, '1.7.0', '<')) { $search .= $temp . "(a.id = {$id} OR LOWER(a.ad_headline) LIKE '%" . $this->_db->getEscaped($filter, true) . "%' OR LOWER(a.ad_text) LIKE '%" . $this->_db->getEscaped($filter, true) . "%')"; } else { $search .= $temp . "(a.id = {$id} OR LOWER(a.ad_headline) LIKE '%" . $this->_db->escape($filter, true) . "%' OR LOWER(a.ad_text) LIKE '%" . $this->_db->escape($filter, true) . "%')"; } } else { $filter = JString::strtolower($filter); if (version_compare(JVERSION, '1.7.0', '<')) { $search .= $temp . "(LOWER(a.ad_headline) LIKE '%" . $this->_db->getEscaped($filter, true) . "%' OR LOWER(a.ad_text) LIKE '%" . $this->_db->getEscaped($filter, true) . "%')"; } else { $search .= $temp . "(LOWER(a.ad_headline) LIKE '%" . $this->_db->escape($filter, true) . "%' OR LOWER(a.ad_text) LIKE '%" . $this->_db->escape($filter, true) . "%')"; } } break; case 'publication_date': $search .= $temp . " a.publication_date <= NOW()"; break; } } } $currentSession = JSession::getInstance('none', array()); $filter = $currentSession->get("sqlglobalfilter", ""); if ($filter != "") { if (isset($filters['user'])) { $conf = TConf::getConfig(); if (@$conf->globalfilter_user == 0) { return $search; } } // si on a que le super filter car pas de recherche classique fieldsFilter = WHERE + super filter if ($search == " ") { $search = " WHERE {$filter} "; } else { // si on a une recherche il faut cumuler les deux fieldsFIlters = fieldFilter + AND + super filter $search .= " AND {$filter}"; } } return $search; }
/** * Generate content * @param object The article object. Note $article->text is also available * @param object The article params * @return string Returns html code or empty string. */ private function getContent($content) { $doc = JFactory::getDocument(); $currentView = JRequest::getWord("view"); if (version_compare(JVERSION, '1.6.0', '>=')) { $doc->addStyleSheet(JURI::base() . "plugins/adsmanagercontent/social/social/style.css"); } else { $doc->addStyleSheet(JURI::base() . "plugins/adsmanagercontent/social/style.css"); } $uri = JURI::getInstance(); $root = $uri->toString(array('scheme', 'host', 'port')); $url = $root . TRoute::_('index.php?option=com_adsmanager&view=details&id=' . $content->id . '&catid=' . $content->catid, false); $title = htmlentities($content->ad_headline, ENT_QUOTES, "UTF-8"); $head = "<meta property='og:title' content=\"" . htmlspecialchars($content->ad_headline) . "\" />\n"; $head .= "<meta property='og:url' content='{$url}' />\n"; $lang = JFactory::getLanguage(); $locales = $lang->getLocale(); if (count($locales) > 0) { $locale = str_replace('.utf8', '', $locales[0]); $head .= "<meta property='og:locale' content='" . $locale . "' />\n"; } $head .= "<meta property='og:description' content=\"" . htmlspecialchars($content->ad_text) . "\" />\n"; $config = TConf::getConfig(); if (count($content->images)) { $imageSize = $this->params->get("imageSize", "large"); switch ($imageSize) { case "thumbnail": $head .= "<meta property='og:image:width' content='" . $config->max_width_t . "'/>\n"; $head .= "<meta property='og:image:height' content='" . $config->max_height_t . "'/>\n"; break; case "medium": $head .= "<meta property='og:image:width' content='" . $config->max_width_m . "'/>\n"; $head .= "<meta property='og:image:height' content='" . $config->max_height_m . "'/>\n"; break; case "thumbnail": default: $head .= "<meta property='og:image:width' content='" . $config->max_width . "'/>\n"; $head .= "<meta property='og:image:height' content='" . $config->max_height . "'/>\n"; break; } } foreach ($content->images as $img) { $imageSize = $this->params->get("imageSize", "large"); switch ($imageSize) { case "thumbnail": $head .= "<meta property='og:image' content='" . JURI_IMAGES_FOLDER . "/" . $img->thumbnail . "'/>\n"; break; case "medium": $head .= "<meta property='og:image' content='" . JURI_IMAGES_FOLDER . "/" . $img->medium . "'/>\n"; break; case "thumbnail": default: $head .= "<meta property='og:image' content='" . JURI_IMAGES_FOLDER . "/" . $img->image . "'/>\n"; break; } } $doc->addCustomTag($head); // Start buttons box $html = ' <div class="itp-share">'; $html .= $this->getFacebookLike($this->params, $url, $title); $html .= $this->getTwitter($this->params, $url, $title); $html .= $this->getDigg($this->params, $url, $title); $html .= $this->getStumbpleUpon($this->params, $url, $title); $html .= $this->getBuzz($this->params, $url, $title); $html .= $this->getLinkedIn($this->params, $url, $title); $html .= $this->getGooglePlusOne($this->params, $url, $title); $html .= $this->getReTweetMeMe($this->params, $url, $title); $html .= $this->getYahooBuzz($this->params, $url, $title); $html .= $this->getFacebookShareMe($this->params, $url, $title); // Gets extra buttons $html .= $this->getExtraButtons($this->params, $url, $title); // End buttons box $html .= ' </div> <div style="clear:both;"></div> '; return $html; }
/** * Return if a user can see the ads contact * * @return boolean */ static public function checkRightContact(){ //If the static variable is already set, we directly return it if (self::$showContact == null) { $user = JFactory::getUser(); $conf = TConf::getConfig(); $userGroups = array(); if(version_compare(JVERSION, '1.6', 'ge')) { //If the user is a guest, we authorise the public group //else we return the authorised group of the user if($user->guest) $userGroups[] = 1; else $userGroups = JHTMLAdsmanagerUserGroups::getUserGroup($user->id); $authorisedContact = false; $allowedContacts = explode(',', $conf->show_contact); foreach ($userGroups as $userGroup) { if(array_search($userGroup, $allowedContacts) !== false){ $authorisedContact = true; } } self::$showContact = $authorisedContact; } else { self::$showContact = true; } } return self::$showContact; }
public function cron() { $conf = TConf::getConfig(); if ($conf->crontype == "webcron" && JRequest::getVar('task', '') == "cron") { TCron::execute(); echo "Done\n"; exit; } if ($conf->crontype == "onrequest" && JRequest::getVar('task', '') != "cron") { TCron::execute(); return; } echo "not allowed"; exit; }