From: <wis...@us...> - 2012-04-29 15:35:17
|
Revision: 9401 http://xoops.svn.sourceforge.net/xoops/?rev=9401&view=rev Author: wishcraft Date: 2012-04-29 15:35:11 +0000 (Sun, 29 Apr 2012) Log Message: ----------- Anti keyword Stuffing for XOOPS 2.6.0 A2 - Find Preloader Attached. Added Paths: ----------- XoopsCore/branches/tasks/2.6.0-wishcraft/modules/system/preloads/ XoopsCore/branches/tasks/2.6.0-wishcraft/modules/system/preloads/antistuffing.php Added: XoopsCore/branches/tasks/2.6.0-wishcraft/modules/system/preloads/antistuffing.php =================================================================== --- XoopsCore/branches/tasks/2.6.0-wishcraft/modules/system/preloads/antistuffing.php (rev 0) +++ XoopsCore/branches/tasks/2.6.0-wishcraft/modules/system/preloads/antistuffing.php 2012-04-29 15:35:11 UTC (rev 9401) @@ -0,0 +1,72 @@ +<?php + +defined('XOOPS_ROOT_PATH') or die('Restricted access'); + +class SystemAntistuffingPreload extends XoopsPreloadItem +{ + function eventCoreHeaderCheckcache($args) + { + global $xoopsTpl, $xoTheme; + + $search = array(' and ', ' the ', ' there ', ' their ', ' they\'re ', ' are ', ' to ', ' when ', ' on ', ' by ', ' is ', ' too ', ' you ',' ','.','<','>','"',';',':','}','{','[',']','|','\\','/','=','+','-','_',')','(','*','&','^','%','$','\#','@','!','~','`'); + $minimumwordlen = 4; + + // Gets Meta Data + $path = str_replace($search, ',', str_replace(basename($_SERVER['REQUEST_URI']), '', $_SERVER['REQUEST_URI'])); + $sitename = $xoTheme->template->_tpl_vars['xoops_sitename']; + $slogon = $xoTheme->template->_tpl_vars['xoops_slogan']; + $pagetitle = $xoTheme->template->_tpl_vars['xoops_pagetitle']; + $keywords = $xoTheme->metas['meta']['keywords']; + //$description = $xoTheme->metas['meta']['description']; + $sitename .= ','.$xoopsTpl->currentTheme->template->_tpl_vars['xoops_sitename']; + $slogon .= ','.$xoopsTpl->currentTheme->template->_tpl_vars['xoops_slogan']; + $pagetitle .= ','.$xoopsTpl->currentTheme->template->_tpl_vars['xoops_pagetitle']; + $keywords .= ','.$xoopsTpl->currentTheme->metas['meta']['keywords']; + //$description .= ','.$xoopsTpl->currentTheme->metas['meta']['description']; + + // Makes Unique Keyword Sentence with NO KEYPHRASES - A KEY PHRASE IS AN INCORRECT USE OF THE META TAG 'KEYWORDS' + $nophrase = str_replace($search, ',', $path.str_replace($search, ',', $sitename).','.str_replace($search, ',', $slogon).','.str_replace($search, ',', $pagetitle).','.str_replace($search, ',', $keywords)/*.','.str_replace($search, ',', $description)*/); + $keywords = array_unique(explode(',', $nophrase)); + foreach($keywords as $id => $word) { + if (strlen($word)<$minimumwordlen) { + unset($keywords[$id]); + } + } + $xoopsTpl->currentTheme->metas['meta']['keywords'] = implode(',', $keywords); + $xoTheme->metas['meta']['keywords'] = implode(',', $keywords); + } + + function eventCoreFooterStart($args) + { + global $xoopsTpl, $xoTheme; + + $search = array(' and ', ' the ', ' there ', ' their ', ' they\'re ', ' are ', ' to ', ' when ', ' on ', ' by ', ' is ', ' too ', ' you ',' ','.','<','>','"',';',':','}','{','[',']','|','\\','/','=','+','-','_',')','(','*','&','^','%','$','\#','@','!','~','`'); + $minimumwordlen = 4; + + // Gets Meta Data + $path = str_replace($search, ',', str_replace(basename($_SERVER['REQUEST_URI']), '', $_SERVER['REQUEST_URI'])); + $sitename = $xoTheme->template->_tpl_vars['xoops_sitename']; + $slogon = $xoTheme->template->_tpl_vars['xoops_slogan']; + $pagetitle = $xoTheme->template->_tpl_vars['xoops_pagetitle']; + $keywords = $xoTheme->metas['meta']['keywords']; + //$description = $xoTheme->metas['meta']['description']; + $sitename .= ','.$xoopsTpl->currentTheme->template->_tpl_vars['xoops_sitename']; + $slogon .= ','.$xoopsTpl->currentTheme->template->_tpl_vars['xoops_slogan']; + $pagetitle .= ','.$xoopsTpl->currentTheme->template->_tpl_vars['xoops_pagetitle']; + $keywords .= ','.$xoopsTpl->currentTheme->metas['meta']['keywords']; + //$description .= ','.$xoopsTpl->currentTheme->metas['meta']['description']; + + // Makes Unique Keyword Sentence with NO KEYPHRASES - A KEY PHRASE IS AN INCORRECT USE OF THE META TAG 'KEYWORDS' + $nophrase = str_replace($search, ',', $path.str_replace($search, ',', $sitename).','.str_replace($search, ',', $slogon).','.str_replace($search, ',', $pagetitle).','.str_replace($search, ',', $keywords)/*.','.str_replace($search, ',', $description)*/); + $keywords = array_unique(explode(',', $nophrase)); + foreach($keywords as $id => $word) { + if (strlen($word)<$minimumwordlen) { + unset($keywords[$id]); + } + } + $xoopsTpl->currentTheme->metas['meta']['keywords'] = implode(',', $keywords); + $xoTheme->metas['meta']['keywords'] = implode(',', $keywords); + } +} + +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |