function getContent($url)
 {
     return rsseoHelper::fopen($url);
 }
예제 #2
0
<?php

/**
* @version 1.0.0
* @package RSSeo! 1.0.0
* @copyright (C) 2009 www.rsjoomla.com
* @license GPL, http://www.gnu.org/copyleft/gpl.html
*/
defined('_JEXEC') or die('Restricted access');
?>

<script language="javascript" type="text/javascript">
<?php 
if (rsseoHelper::is16()) {
    ?>
Joomla.submitbutton = function(task) 
{
	var form = document.adminForm;
	
	if(task == 'cancel')
		Joomla.submitform(task);
	else  
	{
		ret = true;
		if(form.RedirectFrom.value=='') { form.RedirectFrom.className = 'rserror'; ret=false; } else { form.RedirectFrom.className = '';  }	
		if(ret) submitform(task);
	}
	return false;
}
<?php 
} else {
예제 #3
0
 function GetPR($url, $forceNoCache = false)
 {
     $total_exec_start = $this->microtimeFloat();
     $result = array("", -1);
     if ($url . "" != "" && $url . "" != "http://") {
         $this->debugRes("url", $url);
         $this->cacheDir .= substr($this->cacheDir, -1) != "/" ? "/" : "";
         // check for protocol
         $url_ = substr(strtolower($url), 0, 7) != "http://" ? "http://" . $url : $url;
         $host = $this->googleDomains[mt_rand(0, count($this->googleDomains) - 1)];
         $target = "/search";
         $querystring = sprintf("client=navclient-auto&ch=%s&features=Rank&q=%s", $this->CheckHash($this->HashURL($url_)), urlencode("info:" . $url_));
         $contents = "";
         $this->debugRes("host", $host);
         $this->debugRes("query_string", $querystring);
         $this->debugRes("user_agent", $this->userAgent);
         $query_exec_start = $this->microtimeFloat();
         if ($forceNoCache == true) {
             $this->debugRes("force_no_cache", "true");
         } elseif ($contents = $this->readCacheResult($url)) {
             $this->debugRes("read_from_cache", "true");
         } else {
             $this->cacheExpired = true;
         }
         $contents = rsseoHelper::fopen("http://" . $host . $target . "?" . $querystring, 0);
         if ($this->cacheExpired == true) {
             $this->updateCacheResult($url, $contents);
         }
         $this->debugRes("query_exec_time", $this->microtimeFloat() - $query_exec_start);
         $result[0] = $contents;
         // Rank_1:1:0 = 0
         // Rank_1:1:5 = 5
         // Rank_1:1:9 = 9
         // Rank_1:2:10 = 10 etc
         $p = explode(":", $contents);
         if (isset($p[2])) {
             $result[1] = $p[2];
         }
     }
     if ($result[1] == -1) {
         $result[1] = 0;
     }
     $this->PageRank = (int) $result[1];
     $this->debugRes("total_exec_time", $this->microtimeFloat() - $total_exec_start);
     $this->debugRes("result", $result);
     return $this->PageRank;
 }
예제 #4
0
 function crawl()
 {
     $db =& JFactory::getDBO();
     $app =& JFactory::getApplication();
     $start = JRequest::getInt('start', 0);
     $idPage = JRequest::getInt('idPage', 0);
     $rsseoConfig = $app->getuserState('rsseoConfig');
     $autocrawler = $rsseoConfig['crawler.enable.auto'];
     if ($autocrawler) {
         $db->setQuery("UPDATE #__rsseo_config SET ConfigValue = '0' WHERE ConfigName = 'crawler.enable.auto' ");
         $db->query();
     }
     if ($start == 1) {
         $db->setQuery("UPDATE #__rsseo_pages SET PageCrawled=0");
         $db->query();
     }
     if ($idPage != 0) {
         //load the selected page
         $db->setQuery("SELECT * FROM #__rsseo_pages WHERE IdPage='" . $idPage . "'");
     } else {
         //load the first un-crawled page
         $db->setQuery("SELECT * FROM #__rsseo_pages WHERE PageCrawled = 0 AND PageLevel != 127 ORDER BY PageLevel asc, IdPage asc LIMIT 1");
     }
     $page = $db->loadObject();
     if (!empty($page)) {
         $newPage = rsseoHelper::checkPage($page->IdPage, $idPage);
         $newPage->PageCrawled = 1;
         $newPage->DatePageCrawled = time();
         if ($newPage->PageLevel < 127) {
             $newPage->store();
         }
         $link = $newPage->_link;
         //get the ignored href`s
         $ignored = $rsseoConfig['crawler.ignore'];
         $ignored = str_replace("\r", '', $ignored);
         $ignored = explode("\n", $ignored);
         $parser = rsseoHelper::file_get_html($link);
         if ($rsseoConfig['crawler.level'] == -1 || $rsseoConfig['crawler.level'] != -1 && $page->PageLevel < $rsseoConfig['crawler.level']) {
             while ($parser->parse()) {
                 if (strtolower($parser->iNodeName) == 'a') {
                     $href = rsseoHelper::clean_url(@$parser->iNodeAttributes['href']);
                     foreach ($ignored as $ignore) {
                         if (!empty($ignore)) {
                             $ignore = str_replace('&', '&amp;', $ignore);
                             if ($this->is_ignored($href, $ignore)) {
                                 continue 2;
                             }
                         }
                     }
                     if (strpos($href, 'mailto:') !== FALSE) {
                         continue;
                     }
                     if (strpos($href, 'javascript:') !== FALSE) {
                         continue;
                     }
                     if ($newPage->PageLevel >= 127) {
                         continue;
                     }
                     if ($href == 'administrator/' || $href == 'administrator') {
                         continue;
                     }
                     if ($href != null) {
                         $href = str_replace(JURI::root(), '', $href);
                         $db->setQuery("SELECT COUNT(*) FROM #__rsseo_pages WHERE PageURL='" . $href . "'");
                         if ($db->loadResult() == 0) {
                             $db->setQuery("INSERT INTO #__rsseo_pages SET PageURL = '" . $href . "', PageTitle ='', PageKeywords ='', PageDescription = '', PageInSitemap = 1 , PageSitemap=0, PageCrawled=0, PageLevel = '" . ($page->PageLevel + 1) . "' ");
                             $db->query();
                         }
                     }
                 }
             }
         }
         //count the number of pages crawled
         $db->setQuery("SELECT COUNT(*) FROM #__rsseo_pages WHERE PageCrawled != 0 AND PageLevel != 127");
         $pages_crawled = $db->loadResult();
         //count the number of pages left on this level..
         $db->setQuery("SELECT COUNT(*) FROM #__rsseo_pages WHERE PageCrawled = 0 AND PageLevel='" . $page->PageLevel . "'");
         $pages_left = $db->loadResult();
         //count total pages crawled
         $db->setQuery("SELECT COUNT(*) FROM #__rsseo_pages");
         $total_pages = $db->loadResult();
         if ($autocrawler) {
             $db->setQuery("UPDATE #__rsseo_config SET ConfigValue = '1' WHERE ConfigName = 'crawler.enable.auto' ");
             $db->query();
         }
         $page_properties = array();
         $page_properties[] = $newPage->PageURL;
         $page_properties[] = $newPage->PageLevel;
         $page_properties[] = $pages_crawled;
         $page_properties[] = $pages_left;
         $page_properties[] = date($rsseoConfig['global.dateformat']);
         $page_properties[] = $newPage->PageTitle;
         $page_properties[] = $total_pages;
         $page_properties[] = ceil($newPage->PageGrade);
         echo implode("\n", $page_properties);
     } else {
         if ($autocrawler) {
             $db->setQuery("UPDATE #__rsseo_config SET ConfigValue = '1' WHERE ConfigName = 'crawler.enable.auto' ");
             $db->query();
         }
         echo 'Finished' . "\n\n\n\n\n\n\n\n\n";
     }
     exit;
 }
예제 #5
0
 function _getItemData(&$params, $item)
 {
     jimport('joomla.html.parameter');
     $data = null;
     // Menu Link is a special type that is a link to another item
     if ($item->type == 'menulink') {
         $menu =& JSite::getMenu();
         if ($newItem = $menu->getItem($item->query['Itemid'])) {
             $tmp = clone $newItem;
             if (rsseoHelper::is16()) {
                 $tmp->title = '<span><![CDATA[' . $item->title . ']]></span>';
             } else {
                 $tmp->name = '<span><![CDATA[' . $item->name . ']]></span>';
             }
             $tmp->mid = $item->id;
             if (rsseoHelper::is16()) {
                 $tmp->parent_id = $item->parent_id;
             } else {
                 $tmp->parent = $item->parent;
             }
         } else {
             return false;
         }
     } else {
         $tmp = clone $item;
         if (rsseoHelper::is16()) {
             $tmp->title = '<span><![CDATA[' . $item->title . ']]></span>';
         } else {
             $tmp->name = '<span><![CDATA[' . $item->name . ']]></span>';
         }
     }
     $iParams = new JParameter($tmp->params);
     switch ($tmp->type) {
         case 'separator':
             if (rsseoHelper::is16()) {
                 return '<span class="separator">' . $tmp->title . '</span>';
             } else {
                 return '<span class="separator">' . $tmp->name . '</span>';
             }
             break;
         case 'url':
             if (strpos($tmp->link, 'index.php?') === 0 && strpos($tmp->link, 'Itemid=') === false) {
                 $tmp->url = $tmp->link . '&amp;Itemid=' . $tmp->id;
             } else {
                 $tmp->url = $tmp->link;
             }
             break;
         default:
             $router = JSite::getRouter();
             $tmp->url = $router->getMode() == JROUTER_MODE_SEF ? 'index.php?Itemid=' . $tmp->id : $tmp->link . '&Itemid=' . $tmp->id;
             break;
     }
     // Print a link if it exists
     if ($tmp->url != null) {
         // Handle SSL links
         $iSecure = $iParams->def('secure', 0);
         if ($tmp->home == 1) {
             $tmp->url = JURI::base();
         } elseif (strcasecmp(substr($tmp->url, 0, 4), 'http') && strpos($tmp->link, 'index.php?') !== false) {
             $tmp->url = JRoute::_($tmp->url, true, $iSecure);
         } else {
             $tmp->url = str_replace('&', '&amp;', $tmp->url);
         }
         switch ($tmp->browserNav) {
             default:
             case 0:
                 // _top
                 if (rsseoHelper::is16()) {
                     $data = '<a href="' . $tmp->url . '">' . $tmp->title . '</a>';
                 } else {
                     $data = '<a href="' . $tmp->url . '">' . $tmp->name . '</a>';
                 }
                 break;
             case 1:
                 // _blank
                 if (rsseoHelper::is16()) {
                     $data = '<a href="' . $tmp->url . '" target="_blank">' . $tmp->title . '</a>';
                 } else {
                     $data = '<a href="' . $tmp->url . '" target="_blank">' . $tmp->name . '</a>';
                 }
                 break;
             case 2:
                 // window.open
                 $attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,' . $this->_params->get('window_open');
                 // hrm...this is a bit dickey
                 $link = str_replace('index.php', 'index2.php', $tmp->url);
                 if (rsseoHelper::is16()) {
                     $data = '<a href="' . $link . '" onclick="window.open(this.href,\'targetWindow\',\'' . $attribs . '\');return false;">' . $tmp->title . '</a>';
                 } else {
                     $data = '<a href="' . $link . '" onclick="window.open(this.href,\'targetWindow\',\'' . $attribs . '\');return false;">' . $tmp->name . '</a>';
                 }
                 break;
         }
     } else {
         if (rsseoHelper::is16()) {
             $data = '<a>' . $tmp->title . '</a>';
         } else {
             $data = '<a>' . $tmp->name . '</a>';
         }
     }
     return $data;
 }
예제 #6
0
<?php

/**
* @version 1.0.0
* @package RSSEO! 1.0.0
* @copyright (C) 2009 www.rsjoomla.com
* @license GPL, http://www.gnu.org/licenses/gpl-2.0.html
*/
// No direct access
defined('_JEXEC') or die('Restricted access');
require_once JPATH_COMPONENT . DS . 'helper.php';
$app =& JFactory::getApplication();
$params =& $app->getParams('com_rsseo');
if ($params->get('show_page_title', 1) && $params->get('page_title') != '') {
    echo '<div class="componentheading' . $params->get('pageclass_sfx') . '">' . $params->get('page_title') . '</div>';
}
echo rsseoHelper::generateSitemap();
예제 #7
0
    echo $row->IdPage;
    ?>
"><?php 
    echo $row->DatePageCrawled == 0 ? JText::_('RSSEO_PAGE_NOT_CRAWLED') : date($this->rsseoConfig['global.dateformat'], $row->DatePageCrawled);
    ?>
</span></td>
				<td align="center"><?php 
    echo $publish;
    ?>
</td>				
				<td align="center"><?php 
    echo $modified;
    ?>
</td>				
				<td align="center"><?php 
    echo rsseoHelper::add_to_sitemap($row, $i);
    ?>
</td>		
				<td align="center"><a href="#" onclick="crawl(0,<?php 
    echo $row->IdPage;
    ?>
);return false;"><?php 
    echo JText::_('RSSEO_REFRESH');
    ?>
</a></td>		
			</tr>
	<?php 
    $k = 1 - $k;
}
?>
		<tfoot>
예제 #8
0
 function _parseRequest()
 {
     $folder = $this->getFolder();
     $type = JRequest::getVar('type', false, 'post');
     if ($type) {
         $query = JRequest::getVar('query', false, 'post', 'BASE64');
         $start = JRequest::getInt('start', 0);
         $num = count(JFolder::files($folder, '.xml$', 1, false));
         switch ($type) {
             case 'clear':
                 $this->_db->setQuery("TRUNCATE TABLE `#__rsseo_pages`");
                 $this->_db->query();
                 $this->_db->setQuery("TRUNCATE TABLE `#__rsseo_redirects`");
                 $this->_db->query();
                 break;
             case 'backup':
                 $buffer = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
                 $buffer .= '<query>' . "\n";
                 $query = $this->decode($query);
                 if (preg_match('# (\\#__.*?) #is', $query['query'], $matches)) {
                     $table = trim($matches[1]);
                 }
                 $buffer .= $this->addTag('table', $table);
                 $this->_db->setQuery($query['query']);
                 $results = $this->_db->loadObjectList();
                 $buffer .= '<rows>' . "\n";
                 foreach ($results as $result) {
                     $buffer .= '<row>' . "\n";
                     foreach ($result as $key => $value) {
                         if (isset($query['primary']) && $key == $query['primary']) {
                             continue;
                         }
                         $buffer .= $this->addTag('column', $value, $key);
                     }
                     $buffer .= '</row>' . "\n";
                 }
                 $buffer .= '</rows>';
                 $buffer .= '</query>';
                 JFile::write($folder . DS . 'package' . $num . '.xml', $buffer);
                 break;
             case 'restore':
                 jimport('joomla.utilities.simplexml');
                 $file = urldecode(JRequest::getVar('file', false, 'post', ''));
                 $xml = new JSimpleXML();
                 $xml->loadFile($file);
                 $root = $xml->document;
                 $table = $root->getElementByPath('table')->data();
                 $rows = $root->getElementByPath('rows')->children();
                 $table_fields = $name = $data = array();
                 $fields = $this->_db->getTableFields($table);
                 foreach ($fields[$table] as $field => $type) {
                     $table_fields[] = $this->_db->NameQuote($field);
                 }
                 foreach ($rows as $row) {
                     $sql = array();
                     $columns = $row->children();
                     foreach ($columns as $column) {
                         $properties = $column->children();
                         foreach ($properties as $prop) {
                             if ($prop->name() == 'name') {
                                 $name[] = $this->_db->NameQuote($prop->data());
                             }
                             if ($prop->name() == 'value') {
                                 $data[] = $this->_db->Quote($prop->data());
                             }
                         }
                     }
                     foreach ($name as $i => $val) {
                         if (!in_array($val, $table_fields)) {
                             unset($name[$i]);
                             unset($data[$i]);
                         }
                     }
                     if (!empty($name) && !empty($data)) {
                         $this->_db->setQuery("INSERT INTO `" . $table . "` (" . implode(',', $name) . ") VALUES (" . implode(',', $data) . "); ");
                         $this->_db->query();
                         unset($name);
                         unset($data);
                     }
                 }
                 break;
         }
     }
     $pack = JRequest::getInt('pack', 0, 'post');
     if ($pack) {
         if (rsseoHelper::is16()) {
             $adapter = JArchive::getAdapter('zip');
             $archivefiles = array();
             $xmlfiles = JFolder::files($folder, '.xml$', 1, true);
             foreach ($xmlfiles as $xmlfile) {
                 $data = JFile::read($xmlfile);
                 $archivefiles[] = array('name' => JFile::getName($xmlfile), 'data' => $data);
             }
             $adapter->create($folder . DS . 'package.zip', $archivefiles);
         } else {
             JArchive::create($folder . DS . 'package.tar', JFolder::files($folder, '.xml$', 1, true), 'gz', '', $folder, true, true);
         }
     }
     die;
 }
예제 #9
0
 function checkPage($idPage)
 {
     $app =& JFactory::getApplication();
     $rsseoConfig = $app->getuserState('rsseoConfig');
     $db =& JFactory::getDBO();
     JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_rsseo' . DS . 'tables');
     $page =& JTable::getInstance('rsseo_pages', 'Table');
     $page->load($idPage);
     $parser = rsseoHelper::file_get_html(JURI::root() . $page->PageURL, 0);
     $html = rsseoHelper::fopen(JURI::root() . $page->PageURL);
     $link = JURI::root() . $page->PageURL;
     $title = '';
     $description = '';
     $keywords = '';
     $images = 0;
     $images_no_alt = 0;
     $images_no_hw = 0;
     $links = 0;
     preg_match('#<title>(.*?)<\\/title>#', $html, $match);
     preg_match_all('#<h([0-9+])(.*?)<\\/h([0-9+])>#is', $html, $matches);
     $title = @$match[1];
     $headings = count($matches[0]);
     while ($parser->parse()) {
         if ($parser->iNodeName == 'a' && isset($parser->iNodeAttributes['href'])) {
             $links++;
         }
         if (strtolower($parser->iNodeName) == 'meta' && @$parser->iNodeAttributes['name'] == 'description') {
             $description = $parser->iNodeAttributes['content'];
         }
         if (strtolower($parser->iNodeName) == 'meta' && @$parser->iNodeAttributes['name'] == 'keywords') {
             $keywords = $parser->iNodeAttributes['content'];
         }
         if (empty($title) && strtolower($parser->iNodeName) == 'meta' && @$parser->iNodeAttributes['name'] == 'title') {
             $title = $parser->iNodeAttributes['content'];
         }
         if (strtolower($parser->iNodeName) == 'img') {
             $images++;
         }
         if (strtolower($parser->iNodeName) == 'img' && !isset($parser->iNodeAttributes['alt'])) {
             $images_no_alt++;
         }
         if (strtolower($parser->iNodeName) == 'img' && !isset($parser->iNodeAttributes['width']) && !isset($parser->iNodeAttributes['height'])) {
             $images_no_hw++;
         }
     }
     $valid_text = strtolower(strip_tags($html));
     $density_keywords = $page->PageKeywordsDensity;
     if (!empty($density_keywords)) {
         $density_keywords = explode(',', $density_keywords);
         array_walk($density_keywords, array('rsseoHelper', 'lowercasearray'));
         $density_keywords = array_unique($density_keywords);
         $densityparams = array();
         foreach ($density_keywords as $keyword) {
             if (empty($keyword)) {
                 continue;
             }
             $densityparams[$keyword] = rsseoHelper::keywordDensity($valid_text, $keyword);
         }
         $registry = JRegistry::getInstance('density');
         $registry->loadArray($densityparams);
         $page->densityparams = $registry->toString();
     } else {
         $page->densityparams = '';
     }
     $page->PageTitle = $title;
     $page->PageDescription = $description;
     $page->PageKeywords = $keywords;
     //build the params
     $params = array();
     //check if url is sef friendly
     if (strpos($page->PageURL, ".php?") === FALSE) {
         $params['url_sef'] = 1;
     } else {
         $params['url_sef'] = 0;
     }
     //check if page title is unique
     $db->setQuery("SELECT COUNT(*) cnt FROM #__rsseo_pages WHERE PageTitle = '" . $db->getEscaped($page->PageTitle) . "' AND published = 1 ");
     $params['duplicate_title'] = $db->loadResult();
     //check title length
     $params['title_length'] = strlen($page->PageTitle);
     //check if page meta description is unique
     $db->setQuery("SELECT COUNT(*) cnt FROM #__rsseo_pages WHERE PageDescription = '" . $db->getEscaped($page->PageDescription) . "' AND published = 1 ");
     $params['duplicate_desc'] = $db->loadResult();
     //check description length
     $params['description_length'] = strlen($page->PageDescription);
     //check number of keywords
     $keyw = trim($keywords) != '' ? explode(',', $page->PageKeywords) : array();
     $params['keywords'] = count($keyw);
     $params['headings'] = $headings;
     $params['images'] = $images;
     $params['images_wo_alt'] = $images_no_alt;
     $params['images_wo_hw'] = $images_no_hw;
     $params['links'] = $links;
     $reg = JRegistry::getInstance('');
     $reg->loadArray($params);
     $page->params = $reg->toString();
     //the raw html
     $page->_link = $link;
     //the page grade
     $grade = 0;
     $total = 0;
     if ($params['url_sef'] == 1 && $rsseoConfig['crawler.sef']) {
         $grade++;
     }
     if ($params['duplicate_title'] == 1 && $rsseoConfig['crawler.title.duplicate']) {
         $grade++;
     }
     if ($params['title_length'] >= 10 && $params['title_length'] <= 70 && $rsseoConfig['crawler.title.length']) {
         $grade++;
     }
     if ($params['duplicate_desc'] == 1 && $rsseoConfig['crawler.description.duplicate']) {
         $grade++;
     }
     if ($params['description_length'] >= 70 && $params['description_length'] <= 150 && $rsseoConfig['crawler.description.length']) {
         $grade++;
     }
     if ($params['keywords'] <= 10 && $rsseoConfig['crawler.keywords']) {
         $grade++;
     }
     if ($params['headings'] > 0 && $rsseoConfig['crawler.headings']) {
         $grade++;
     }
     if ($params['images'] <= 10 && $rsseoConfig['crawler.images']) {
         $grade++;
     }
     if ($params['images_wo_alt'] == 0 && $rsseoConfig['crawler.images.alt']) {
         $grade++;
     }
     if ($params['images_wo_hw'] == 0 && $rsseoConfig['crawler.images.hw']) {
         $grade++;
     }
     if ($params['links'] <= 100) {
         $grade++;
     }
     if ($rsseoConfig['crawler.sef']) {
         $total++;
     }
     if ($rsseoConfig['crawler.title.duplicate']) {
         $total++;
     }
     if ($rsseoConfig['crawler.title.length']) {
         $total++;
     }
     if ($rsseoConfig['crawler.description.duplicate']) {
         $total++;
     }
     if ($rsseoConfig['crawler.description.length']) {
         $total++;
     }
     if ($rsseoConfig['crawler.keywords']) {
         $total++;
     }
     if ($rsseoConfig['crawler.headings']) {
         $total++;
     }
     if ($rsseoConfig['crawler.images']) {
         $total++;
     }
     if ($rsseoConfig['crawler.images.alt']) {
         $total++;
     }
     if ($rsseoConfig['crawler.images.hw']) {
         $total++;
     }
     if ($rsseoConfig['crawler.intext.links']) {
         $total++;
     }
     $page->PageGrade = $grade * 100 / $total;
     return $page;
 }
예제 #10
0
 function checkpage()
 {
     $cid = JRequest::getVar('cid', array(0), 'request', 'array');
     if (is_array($cid)) {
         $cid = intval($cid[0]);
     }
     $newPage = rsseoHelper::checkPage($cid, $cid);
     $newPage->PageTitle = str_replace('&amp;', '&', $newPage->PageTitle);
     $newPage->PageKeywords = str_replace('&amp;', '&', $newPage->PageKeywords);
     $newPage->PageDescription = str_replace('&amp;', '&', $newPage->PageDescription);
     $newPage->DatePageCrawled = time();
     $newPage->store();
     $this->setRedirect('index.php?option=com_rsseo&task=editpage&cid=' . $cid);
 }
예제 #11
0
    function sitemapGenerate()
    {
        $db =& JFactory::getDBO();
        $SitemapFrequency = JRequest::getVar('SitemapFrequency');
        $SitemapModification = JRequest::getVar('SitemapModification');
        $SitemapPriority = JRequest::getVar('SitemapPriority');
        $SitemapNew = JRequest::getVar('SitemapNew');
        $protocol = JRequest::getInt('protocol', 0);
        $sitemap = JPATH_SITE . DS . 'sitemap.xml';
        $ror = JPATH_SITE . DS . 'ror.xml';
        $root = JURI::root();
        if (substr($root, 0, 8) == 'https://' && $protocol == 0) {
            $root = str_replace('https://', 'http://', $root);
        }
        if (substr($root, 0, 7) == 'http://' && $protocol == 1) {
            $root = str_replace('http://', 'https://', $root);
        }
        if (filesize($sitemap) == 0) {
            $SitemapNew = 'new';
        }
        $replace = array();
        $db->setQuery("SELECT RedirectFrom,RedirectTo FROM #__rsseo_redirects WHERE published = 1");
        $redirects = $db->loadObjectList();
        foreach ($redirects as $redirect) {
            $redirect->RedirectFrom = htmlentities($redirect->RedirectFrom);
            $redirect->RedirectTo = htmlentities($redirect->RedirectTo);
            $replace[$redirect->RedirectFrom] = $redirect->RedirectTo;
        }
        if ($SitemapNew == 'new') {
            $db->setQuery("UPDATE #__rsseo_pages SET PageSitemap=0");
            $db->query();
            $xml_string = '<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
';
            $ror_string = '<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:ror="http://rorweb.com/0.1/" >
<channel>
<title>ROR Sitemap for ' . $root . '</title>
<link>' . $root . '</link>
<item>
	<title>ROR Sitemap for ' . $root . '</title>
	<link>' . $root . '</link>
	<ror:about>sitemap</ror:about>
	<ror:type>SiteMap</ror:type>
</item>
';
        } else {
            $xml_string = '';
            $ror_string = '';
        }
        $db->setQuery("SELECT * FROM #__rsseo_pages WHERE PageSitemap=0 AND PageInSitemap = 1 ORDER BY PageLevel LIMIT 500");
        $pages = $db->loadObjectList();
        if (!empty($pages)) {
            foreach ($pages as $page) {
                if ($page->PageLevel == 0) {
                    $page->PageLevel = 1;
                }
                if ($SitemapPriority == 'auto') {
                    $priority = number_format(1 / $page->PageLevel, 2, '.', '');
                } else {
                    $priority = '';
                }
                if (!empty($replace[$page->PageURL])) {
                    $page->PageURL = $replace[$page->PageURL];
                }
                $xml_string .= '<url>
	<loc>' . rsseoControllersitemap::xmlentities($root . $page->PageURL) . '</loc>
	<priority>' . $priority . '</priority>
	<changefreq>' . $SitemapFrequency . '</changefreq>
	<lastmod>' . $SitemapModification . '</lastmod>  
</url>
';
                $ror_string .= '<item>
	<link>' . rsseoControllersitemap::xmlentities($root . $page->PageURL) . '</link>
	<title>' . rsseoControllersitemap::xmlentities($page->PageTitle) . '</title>
    <ror:updatePeriod>' . $SitemapFrequency . '</ror:updatePeriod>
    <ror:sortOrder>' . $page->PageLevel . '</ror:sortOrder>
    <ror:resourceOf>sitemap</ror:resourceOf>
</item>
';
                $db->setQuery("UPDATE #__rsseo_pages SET PageSitemap=1 WHERE IdPage = '" . $page->IdPage . "'");
                $db->query();
            }
            rsseoHelper::fwrite($sitemap, $xml_string, $SitemapNew ? 'w' : 'a');
            rsseoHelper::fwrite($ror, $ror_string, $SitemapNew ? 'w' : 'a');
        } else {
            $filename = JPATH_SITE . DS . 'sitemap.xml';
            rsseoHelper::fwrite($filename, "\n" . '</urlset>', 'a');
            $filename = JPATH_SITE . DS . 'ror.xml';
            rsseoHelper::fwrite($filename, '</channel>' . "\n" . '</rss>', 'a');
            echo 'finish';
            exit;
        }
        //get total number of pages
        $db->setQuery("SELECT count(*) FROM #__rsseo_pages WHERE PageInSitemap = 1");
        $total = $db->loadResult();
        $db->setQuery("SELECT count(*) FROM #__rsseo_pages WHERE PageSitemap=1 AND PageInSitemap = 1");
        $processed = $db->loadResult();
        echo '<div class="sitemapContainer"><div class="sitemapProgress" style="width:' . ceil($processed * 100 / $total) . '%;">Progress: ' . ceil($processed * 100 / $total) . '%</div></div>';
        exit;
    }
예제 #12
0
 function checkconnections()
 {
     $url = JURI::root();
     $result = rsseoHelper::checkconnections($url);
     if (empty($result->err) && !empty($result->ok)) {
         $ok = implode(',', $result->ok);
         JError::raiseNotice(200, 'Connection with "' . $ok . '" successfully');
     }
     if (empty($result->ok) && !empty($result->err)) {
         JError::raiseWarning(500, 'Your server does not accept loopback connections.Click <a href="http://www.rsjoomla.com/customer-support/documentations/73-troubleshooting/417-how-can-you-use-rsseo-without-loopback-connections.html" target="_blank">here</a> for more informations about this problem.');
     }
     if (!empty($result->err)) {
         $err = implode(',', $result->err);
         $ok = implode(',', $result->ok);
         JError::raiseWarning(500, 'Could not connect using "' . $err . '" but could connect with "' . $ok . '"');
     }
     echo 'Click <a href="index.php?option=com_rsseo">here</a> to go to RSSeo! Control Panel';
 }
 function refreshCompetitor($id = null)
 {
     $db =& JFactory::getDBO();
     $app =& JFactory::getApplication();
     $rsseoConfig = $app->getuserState('rsseoConfig');
     $cid = is_null($id) ? JRequest::getInt('cid', 0) : $id;
     $db->setQuery("SELECT * FROM #__rsseo_competitors WHERE IdCompetitor= '" . $cid . "'");
     $Competitor = $db->loadObject();
     if (isset($Competitor->Competitor) && !is_null($Competitor->Competitor)) {
         $array['page_rank'] = rsseoHelper::getPageRank($Competitor->Competitor);
         $array['alexa_rank'] = rsseoHelper::getAlexaRank($Competitor->Competitor);
         $array['tehnorati_rank'] = rsseoHelper::getTehnoratiRank($Competitor->Competitor);
         $array['google_pages'] = rsseoHelper::getGooglePages($Competitor->Competitor);
         $array['yahoo_pages'] = rsseoHelper::getYahooPages($Competitor->Competitor);
         $array['bing_pages'] = rsseoHelper::getBingPages($Competitor->Competitor);
         $array['google_backlinks'] = rsseoHelper::getGoogleBacklinks($Competitor->Competitor);
         $array['yahoo_backlinks'] = rsseoHelper::getYahooBacklinks($Competitor->Competitor);
         $array['bing_backlinks'] = rsseoHelper::getBingBacklinks($Competitor->Competitor);
         $dmoz = rsseoHelper::getDmoz($Competitor->Competitor);
         $array['date_refreshed'] = time();
         $query = "INSERT INTO #__rsseo_competitors_history SET " . "IdCompetitor='" . $cid . "', " . "PageRank='" . $array['page_rank'] . "', " . "AlexaRank='" . $array['alexa_rank'] . "', " . "TehnoratiRank='" . $array['tehnorati_rank'] . "', " . "GoogleBacklinks='" . $array['google_backlinks'] . "', " . "YahooBacklinks='" . $array['yahoo_backlinks'] . "', " . "BingBacklinks='" . $array['bing_backlinks'] . "', " . "GooglePages='" . $array['google_pages'] . "', " . "YahooPages='" . $array['yahoo_pages'] . "', " . "BingPages='" . $array['bing_pages'] . "', " . "DateRefreshed='" . $array['date_refreshed'] . "'";
         //save to keyword details
         $db->setQuery($query);
         $db->query();
         $query = "UPDATE #__rsseo_competitors SET " . "LastPageRank='" . $array['page_rank'] . "', " . "LastAlexaRank='" . $array['alexa_rank'] . "', " . "LastTehnoratiRank='" . $array['tehnorati_rank'] . "', " . "LastGoogleBacklinks='" . $array['google_backlinks'] . "', " . "LastYahooBacklinks='" . $array['yahoo_backlinks'] . "', " . "LastBingBacklinks='" . $array['bing_backlinks'] . "', " . "LastGooglePages='" . $array['google_pages'] . "', " . "LastYahooPages='" . $array['yahoo_pages'] . "', " . "LastBingPages='" . $array['bing_pages'] . "', " . "Dmoz='" . $dmoz . "', " . "LastDateRefreshed='" . $array['date_refreshed'] . "' " . "WHERE IdCompetitor = '" . $cid . "'";
         //update last keyword
         $db->setQuery($query);
         $db->query();
         $array['date_refreshed'] = date($rsseoConfig['global.dateformat'], $array['date_refreshed']);
         $db->setQuery("SELECT * FROM #__rsseo_competitors_history WHERE IdCompetitor = " . $cid . " ORDER BY DateRefreshed DESC LIMIT 2 ");
         $history = $db->loadObjectList();
         if (isset($history[1])) {
             $compare = $history[0];
         }
         //google page rank
         if ($compare->PageRank > $Competitor->LastPageRank) {
             $color1 = 'colorgreen';
         }
         if ($compare->PageRank < $Competitor->LastPageRank) {
             $color1 = 'colorred';
         }
         if ($compare->PageRank == $Competitor->LastPageRank) {
             $color1 = 'colornone';
         }
         //alexa page rank
         if ($compare->AlexaRank > $Competitor->LastAlexaRank) {
             $color2 = 'colorred';
         }
         if ($compare->AlexaRank < $Competitor->LastAlexaRank) {
             $color2 = 'colorgreen';
         }
         if ($compare->AlexaRank == $Competitor->LastAlexaRank) {
             $color2 = 'colornone';
         }
         //google pages
         if ($compare->GooglePages > $Competitor->LastGooglePages) {
             $color3 = 'colorgreen';
         }
         if ($compare->GooglePages < $Competitor->LastGooglePages) {
             $color3 = 'colorred';
         }
         if ($compare->GooglePages == $Competitor->LastGooglePages) {
             $color3 = 'colornone';
         }
         //yahoo pages
         if ($compare->YahooPages > $Competitor->LastYahooPages) {
             $color4 = 'colorgreen';
         }
         if ($compare->YahooPages < $Competitor->LastYahooPages) {
             $color4 = 'colorred';
         }
         if ($compare->YahooPages == $Competitor->LastYahooPages) {
             $color4 = 'colornone';
         }
         //bing pages
         if ($compare->BingPages > $Competitor->LastBingPages) {
             $color5 = 'colorgreen';
         }
         if ($compare->BingPages < $Competitor->LastBingPages) {
             $color5 = 'colorred';
         }
         if ($compare->BingPages == $Competitor->LastBingPages) {
             $color5 = 'colornone';
         }
         //google backlinks
         if ($compare->GoogleBacklinks > $Competitor->LastGoogleBacklinks) {
             $color6 = 'colorgreen';
         }
         if ($compare->GoogleBacklinks < $Competitor->LastGoogleBacklinks) {
             $color6 = 'colorred';
         }
         if ($compare->GoogleBacklinks == $Competitor->LastGoogleBacklinks) {
             $color6 = 'colornone';
         }
         //yahoo backlinks
         if ($compare->YahooBacklinks > $Competitor->LastYahooBacklinks) {
             $color7 = 'colorgreen';
         }
         if ($compare->YahooBacklinks < $Competitor->LastYahooBacklinks) {
             $color7 = 'colorred';
         }
         if ($compare->YahooBacklinks == $Competitor->LastYahooBacklinks) {
             $color7 = 'colornone';
         }
         //bing backlinks
         if ($compare->BingBacklinks > $Competitor->LastBingBacklinks) {
             $color8 = 'colorgreen';
         }
         if ($compare->BingBacklinks < $Competitor->LastBingBacklinks) {
             $color8 = 'colorred';
         }
         if ($compare->BingBacklinks == $Competitor->LastBingBacklinks) {
             $color8 = 'colornone';
         }
         //tehnorati rank
         if ($compare->TehnoratiRank > $Competitor->LastTehnoratiRank) {
             $color9 = 'colorgreen';
         }
         if ($compare->TehnoratiRank < $Competitor->LastTehnoratiRank) {
             $color9 = 'colorred';
         }
         if ($compare->TehnoratiRank == $Competitor->LastTehnoratiRank) {
             $color9 = 'colornone';
         }
         $array['color1'] = $color1;
         $array['color2'] = $color2;
         $array['color3'] = $color3;
         $array['color4'] = $color4;
         $array['color5'] = $color5;
         $array['color6'] = $color6;
         $array['color7'] = $color7;
         $array['color8'] = $color8;
         $array['color9'] = $color9;
         $array['dmoz'] = $dmoz == 0 ? JText::_('RSSEO_NO') : JText::_('RSSEO_YES');
         echo implode("\n", $array);
     }
     if ($id == null) {
         exit;
     }
 }
예제 #14
0
 function refreshkeyword($IdKeyword = null)
 {
     $app =& JFactory::getApplication();
     $db =& JFactory::getDBO();
     $rsseoConfig = $app->getuserState('rsseoConfig');
     if (!$IdKeyword) {
         $cid = intval(JRequest::getVar('cid'));
     } else {
         $cid = $IdKeyword;
     }
     $db->setQuery("SELECT ActualKeywordPosition FROM #__rsseo_keywords WHERE IdKeyword =" . $cid);
     $currentPosition = $db->loadResult();
     $db->setQuery("SELECT Keyword FROM #__rsseo_keywords WHERE IdKeyword='" . $cid . "'");
     $keyword = $db->loadResult();
     $rsseoConfig['subdomains'] = str_replace("\r", '', $rsseoConfig['subdomains']);
     $domains = array();
     $domains = explode("\n", $rsseoConfig['subdomains']);
     $domains[] = JURI::root();
     $q = str_replace(" ", "+", $keyword);
     $q = str_replace("%26", "&", $q);
     $valid = 0;
     $i = 1;
     for ($google_page = 0; $google_page < 5; $google_page++) {
         $parser = rsseoHelper::file_get_html('http://www.' . $rsseoConfig['google.domain'] . '/search?q=' . $q . '&pws=0&start=' . 10 * $google_page);
         while ($parser->parse()) {
             if (strtolower($parser->iNodeName) == 'a' && @$parser->iNodeAttributes['class'] == 'l' && empty($parser->iNodeAttributes['title']) && empty($parser->iNodeAttributes['style'])) {
                 $href = @$parser->iNodeAttributes['href'];
                 foreach ($domains as $domain) {
                     if (empty($domain)) {
                         continue;
                     }
                     if (strpos($href, $domain) !== false) {
                         $valid = 1;
                         continue;
                     }
                 }
                 if ($valid) {
                     continue;
                 }
                 $i++;
             }
         }
         if ($valid) {
             break;
         }
     }
     $array['position'] = $valid ? $i : 0;
     $array['date_refreshed'] = time();
     if ($array['position'] > $currentPosition) {
         $array['color'] = "colorred";
     }
     if ($array['position'] < $currentPosition) {
         $array['color'] = "colorgreen";
     }
     if ($array['position'] == $currentPosition) {
         $array['color'] = "colornone";
     }
     //update last keyword
     $db->setQuery("UPDATE #__rsseo_keywords SET ActualKeywordPosition ='" . $array['position'] . "' , LastKeywordPosition = " . $currentPosition . " , DateRefreshed='" . $array['date_refreshed'] . "' WHERE IdKeyword = '" . $cid . "'");
     $db->query();
     $array['date_refreshed'] = date($rsseoConfig['global.dateformat'], $array['date_refreshed']);
     if ($IdKeyword == null) {
         echo serialize($array);
         exit;
     }
 }
예제 #15
0
 function display($tpl = null)
 {
     $app =& JFactory::getApplication();
     JSubMenuHelper::addEntry(JText::_('RSSEO_OVERVIEW'), 'index.php?option=com_rsseo');
     JSubMenuHelper::addEntry(JText::_('RSSEO_MENU_COMPETITORS'), 'index.php?option=com_rsseo&task=listcompetitors');
     JSubMenuHelper::addEntry(JText::_('RSSEO_MENU_PAGES'), 'index.php?option=com_rsseo&task=listpages', true);
     JSubMenuHelper::addEntry(JText::_('RSSEO_MENU_REDIRECTS'), 'index.php?option=com_rsseo&task=listredirects');
     JSubMenuHelper::addEntry(JText::_('RSSEO_MENU_SITEMAP'), 'index.php?option=com_rsseo&task=sitemap');
     JSubMenuHelper::addEntry(JText::_('RSSEO_MENU_CRAWLER'), 'index.php?option=com_rsseo&task=crawler');
     JSubMenuHelper::addEntry(JText::_('RSSEO_MENU_KEYWORDS'), 'index.php?option=com_rsseo&task=listkeywords');
     JSubMenuHelper::addEntry(JText::_('RSSEO_MENU_BACKUPRESTORE'), 'index.php?option=com_rsseo&task=backuprestore');
     JSubMenuHelper::addEntry(JText::_('RSSEO_MENU_ANALYTICS'), 'index.php?option=com_rsseo&task=analytics');
     JSubMenuHelper::addEntry(JText::_('RSSEO_MENU_SETTINGS'), 'index.php?option=com_rsseo&task=editsettings');
     JSubMenuHelper::addEntry(JText::_('RSSEO_MENU_UPDATE'), 'index.php?option=com_rsseo&task=update');
     $task = JRequest::getVar('task');
     switch ($task) {
         case 'listpages':
             $db =& JFactory::getDBO();
             JToolBarHelper::title(JText::_('RSSEO_LIST_PAGES'), 'rsseo');
             JToolBarHelper::custom('publish', 'rsseo_ignore', 'rsseo_ignore', JText::_('RSSEO_PAGE_PUBLISHED'));
             JToolBarHelper::custom('unpublish', 'rsseo_unignore', 'rsseo_unignore', JText::_('RSSEO_PAGE_UNPUBLISHED'));
             JToolBarHelper::custom('restore', 'restore', 'restore', JText::_('RSSEO_RESTORE_PAGES'));
             JToolBarHelper::custom('refresh', 'refresh', 'refresh', JText::_('RSSEO_BULK_REFRESH'));
             JToolBarHelper::addNewX('editpage');
             JToolBarHelper::editListX('editpage');
             JToolBarHelper::deleteList("Are you sure you want to delete?", 'remove', "Delete");
             $bar =& JToolBar::getInstance('toolbar');
             $bar->appendButton('Confirm', JText::_('RSSEO_DELETE_ALL_PAGES_MESSAGE', true), 'delete', JText::_('RSSEO_DELETE_ALL_PAGES'), 'removeall', false);
             JToolBarHelper::custom('rsseo', 'preview.png', 'preview_f2.png', JText::_('RSSEO_PRODUCT'), false);
             $filter = $app->getUserStateFromRequest('com_rsseo.pages.rs_filter', 'rs_filter', '');
             $md5_descr = JRequest::getVar('md5_descr');
             $md5_title = JRequest::getVar('md5_title');
             $status_filter = JRequest::getVar('rs_status_filter');
             $page_level_filter = JRequest::getVar('rs_page_level_filter');
             $sortColumn = JRequest::getVar('filter_order', 'PageLevel');
             $sortOrder = JRequest::getVar('filter_order_Dir', 'asc');
             $pagination = $this->get('pagination');
             $page_published[] = JHTML::_('select.option', '', JText::_('RSSEO_PAGE_STATUS'), 'val', 'text');
             $page_published[] = JHTML::_('select.option', '0', JText::_('RSSEO_PAGE_UNPUBLISHED'), 'val', 'text');
             $page_published[] = JHTML::_('select.option', '1', JText::_('RSSEO_PAGE_PUBLISHED'), 'val', 'text');
             $page_level[] = JHTML::_('select.option', '', JText::_('RSSEO_PAGE_LEVEL'), 'val', 'text');
             $page_level[] = JHTML::_('select.option', '0', '0', 'val', 'text');
             $page_level[] = JHTML::_('select.option', '1', '1', 'val', 'text');
             $page_level[] = JHTML::_('select.option', '2', '2', 'val', 'text');
             $page_level[] = JHTML::_('select.option', '3', '3', 'val', 'text');
             $page_level[] = JHTML::_('select.option', '4', '4', 'val', 'text');
             $page_level[] = JHTML::_('select.option', '5', '5', 'val', 'text');
             $page_level[] = JHTML::_('select.option', '127', JText::_('RSSEO_UNDEFINED'), 'val', 'text');
             $lists['page_published'] = JHTML::_('select.genericlist', $page_published, 'rs_status_filter', 'class="inputbox" size="1" onchange="submitbutton(\'listpages\');"', 'val', 'text', $status_filter);
             $lists['page_level'] = JHTML::_('select.genericlist', $page_level, 'rs_page_level_filter', 'class="inputbox" size="1" onchange="submitbutton(\'listpages\');"', 'val', 'text', $page_level_filter);
             $listpages = $this->get('data');
             $this->assignRef('location_filter', $category_filter);
             $this->assignRef('lists', $lists);
             $this->assignRef('filter', $filter);
             $this->assignRef('md5_descr', $md5_descr);
             $this->assignRef('md5_title', $md5_title);
             $this->assignRef('sortColumn', $sortColumn);
             $this->assignRef('sortOrder', $sortOrder);
             $this->assignRef('listpages', $listpages);
             $this->assignRef('pagination', $pagination);
             $this->assignRef('rsseoConfig', $app->getuserState('rsseoConfig'));
             break;
         case 'editpage':
             JHTML::_('behavior.tooltip');
             $db =& JFactory::getDBO();
             $cid = JRequest::getVar('cid', array(0), 'request', 'array');
             if (is_array($cid)) {
                 $cid = intval($cid[0]);
             }
             if ($cid == 0) {
                 JToolBarHelper::title(JText::_('RSSEO_PAGE_NEW'), 'rsseo');
             } else {
                 JToolBarHelper::title(JText::_('RSSEO_PAGE_EDIT'), 'rsseo');
             }
             JToolBarHelper::custom('checkpage', 'html', 'html', JText::_('RSSEO_CHECK'), false);
             JToolBarHelper::save();
             JToolBarHelper::apply();
             JToolBarHelper::cancel();
             JToolBarHelper::custom('rsseo', 'preview.png', 'preview_f2.png', JText::_('RSSEO_PRODUCT'), false);
             $page = $this->get('Page');
             $reg = JRegistry::getInstance('');
             $registry = JRegistry::getInstance('density');
             if (rsseoHelper::is16()) {
                 $reg->loadJSON($page->params);
             } else {
                 $reg->loadINI($page->params);
             }
             if (rsseoHelper::is16()) {
                 $registry->loadJSON($page->densityparams);
             } else {
                 $registry->loadINI($page->densityparams);
             }
             $this->assignRef('cid', $cid);
             $this->assignRef('data', $page);
             $this->assignRef('params', $reg->toObject());
             $this->assignRef('densityparams', $registry->toArray());
             $this->assignRef('rsseoConfig', $app->getuserState('rsseoConfig'));
             break;
         case 'showdetails':
             JToolBarHelper::title(JText::_('RSSEO_PAGE_SIZE_DETAILS'), 'rsseo');
             JToolBarHelper::custom('back', 'back', 'back', JText::_('RSSEO_BACK'), false);
             JToolBarHelper::custom('rsseo', 'preview.png', 'preview_f2.png', JText::_('RSSEO_PRODUCT'), false);
             $cid = JRequest::getVar('cid');
             $layout = $this->get('Details');
             $this->assignRef('layout', $layout);
             $this->assignRef('cid', $cid);
             break;
     }
     parent::display($tpl);
 }