-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix formatting, cleanup weird characters, reorder methods
- Loading branch information
Showing
15 changed files
with
215 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
|
||
/** | ||
* Magento | ||
* | ||
|
@@ -12,26 +13,21 @@ | |
* obtain it through the world-wide-web, please send an email | ||
* to [email protected] so we can send you a copy immediately. | ||
* | ||
* @category Hackathon | ||
* @package Hackathon_HoneySpam | ||
* @author Andreas Emer <[email protected]> | ||
* @category Hackathon | ||
* @package Hackathon_HoneySpam | ||
* @author Andreas Emer <[email protected]> | ||
* @author Fabian Blechschmidt <[email protected]> | ||
* @author Sascha Wohlgemuth <[email protected]> | ||
* @author Bastian Ike <[email protected]> | ||
* @author Peter Ukener <[email protected]> | ||
* @copyright 2012 Magento Hackathon | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
* @link http://www.magento-hackathon.de/ | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
* @link http://www.magento-hackathon.de/ | ||
*/ | ||
class Hackathon_HoneySpam_Block_Honeypot extends Mage_Core_Block_Template | ||
{ | ||
protected $_template = 'hackathon/honeyspam/honeypot.phtml'; | ||
|
||
protected function _construct() | ||
{ | ||
parent::_construct(); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
|
@@ -42,5 +38,10 @@ public function getHoneypotName() | |
return $helper->getHoneypotName(); | ||
} | ||
|
||
protected function _construct() | ||
{ | ||
parent::_construct(); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
|
||
/** | ||
* Magento | ||
* | ||
|
@@ -12,35 +13,27 @@ | |
* obtain it through the world-wide-web, please send an email | ||
* to [email protected] so we can send you a copy immediately. | ||
* | ||
* @category Hackathon | ||
* @package Hackathon_HoneySpam | ||
* @author Andreas Emer <[email protected]> | ||
* @category Hackathon | ||
* @package Hackathon_HoneySpam | ||
* @author Andreas Emer <[email protected]> | ||
* @author Fabian Blechschmidt <[email protected]> | ||
* @author Sascha Wohlgemuth <[email protected]> | ||
* @author Bastian Ike <[email protected]> | ||
* @author Peter Ukener <[email protected]> | ||
* @copyright 2012 Magento Hackathon | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
* @link http://www.magento-hackathon.de/ | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
* @link http://www.magento-hackathon.de/ | ||
*/ | ||
class Hackathon_HoneySpam_Helper_Data extends Mage_Core_Helper_Abstract | ||
{ | ||
const CONFIG_PATH_INPUT_NAME = 'hackathon/honeyspam/honeypotName'; | ||
const CONFIG_PATH_ENABLE_POT = 'hackathon/honeyspam/enableHoneypotName'; | ||
const CONFIG_PATH_ENABLE_TIME = 'hackathon/honeyspam/enableHoneypotAccountCreateTime'; | ||
const CONFIG_PATH_ENABLE_SPAM = 'hackathon/honeyspam/enableSpamIndexing'; | ||
const CONFIG_PATH_INDEX_LEVEL = 'hackathon/honeyspam/spamIndexLevel'; | ||
const CONFIG_PATH_CREATE_TIME = 'hackathon/honeyspam/honeypotAccountCreateTime'; | ||
const CONFIG_PATH_ENABLE_LOG = 'hackathon/honeyspam/enableLogging'; | ||
const CONFIG_PATH_LOG_FILE = 'hackathon/honeyspam/logfile'; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getHoneypotName() | ||
{ | ||
return Mage::getStoreConfig(self::CONFIG_PATH_INPUT_NAME); | ||
} | ||
const CONFIG_PATH_INPUT_NAME = 'hackathon/honeyspam/honeypotName'; | ||
const CONFIG_PATH_ENABLE_POT = 'hackathon/honeyspam/enableHoneypotName'; | ||
const CONFIG_PATH_ENABLE_TIME = 'hackathon/honeyspam/enableHoneypotAccountCreateTime'; | ||
const CONFIG_PATH_ENABLE_SPAM = 'hackathon/honeyspam/enableSpamIndexing'; | ||
const CONFIG_PATH_INDEX_LEVEL = 'hackathon/honeyspam/spamIndexLevel'; | ||
const CONFIG_PATH_CREATE_TIME = 'hackathon/honeyspam/honeypotAccountCreateTime'; | ||
const CONFIG_PATH_ENABLE_LOG = 'hackathon/honeyspam/enableLogging'; | ||
const CONFIG_PATH_LOG_FILE = 'hackathon/honeyspam/logfile'; | ||
|
||
/** | ||
* @return bool | ||
|
@@ -49,27 +42,31 @@ public function isHoneypotNameEnabled() | |
{ | ||
return Mage::getStoreConfigFlag(self::CONFIG_PATH_ENABLE_POT); | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function isSpamIndexingEnabled() | ||
{ | ||
return Mage::getStoreConfigFlag(self::CONFIG_PATH_ENABLE_SPAM); | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function isHoneypotAccountCreateTimeEnabled() | ||
{ | ||
return Mage::getStoreConfigFlag(self::CONFIG_PATH_ENABLE_TIME); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getSpamIndexLevel() | ||
{ | ||
return Mage::getStoreConfig(self::CONFIG_PATH_INDEX_LEVEL); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
|
@@ -78,6 +75,17 @@ public function getHoneypotAccountCreateTime() | |
return Mage::getStoreConfig(self::CONFIG_PATH_CREATE_TIME); | ||
} | ||
|
||
/** | ||
* @param string $message | ||
* @param int $level | ||
*/ | ||
public function log($message, $level = Zend_Log::INFO) | ||
{ | ||
if ($this->isLoggingEnabled()) { | ||
Mage::log($message, $level, $this->getLogFilename()); | ||
} | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
|
@@ -95,22 +103,19 @@ public function getLogFilename() | |
} | ||
|
||
/** | ||
* @param string $message | ||
* @param int $level | ||
* @return bool | ||
*/ | ||
public function log($message, $level = Zend_Log::INFO) | ||
public function isHoneypotFilled() | ||
{ | ||
if ($this->isLoggingEnabled()) { | ||
Mage::log($message, $level, $this->getLogFilename()); | ||
} | ||
return strlen($this->_getRequest()->getParam($this->getHoneypotName())); | ||
} | ||
|
||
/** | ||
* @return bool | ||
* @return string | ||
*/ | ||
public function isHoneypotFilled() | ||
public function getHoneypotName() | ||
{ | ||
return strlen($this->_getRequest()->getParam($this->getHoneypotName())); | ||
return Mage::getStoreConfig(self::CONFIG_PATH_INPUT_NAME); | ||
} | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,16 +12,16 @@ | |
* obtain it through the world-wide-web, please send an email | ||
* to [email protected] so we can send you a copy immediately. | ||
* | ||
* @category Hackathon | ||
* @package Hackathon_HoneySpam | ||
* @author Andreas Emer <[email protected]> | ||
* @category Hackathon | ||
* @package Hackathon_HoneySpam | ||
* @author Andreas Emer <[email protected]> | ||
* @author Fabian Blechschmidt <[email protected]> | ||
* @author Sascha Wohlgemuth <[email protected]> | ||
* @author Bastian Ike <[email protected]> | ||
* @author Peter Ukener <[email protected]> | ||
* @copyright 2012 Magento Hackathon | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
* @link http://www.magento-hackathon.de/ | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
* @link http://www.magento-hackathon.de/ | ||
*/ | ||
|
||
class Hackathon_HoneySpam_Model_Checker extends Mage_Core_Model_Abstract | ||
|
@@ -46,7 +46,7 @@ public function init($params) | |
* @param string $firstname | ||
* @param string $lastname | ||
* @param string $emailprefix | ||
* @param array $params | ||
* @param array $params | ||
* @return int | ||
*/ | ||
public function check($firstname, $lastname, $emailprefix, $params) | ||
|
@@ -110,7 +110,8 @@ public function check($firstname, $lastname, $emailprefix, $params) | |
} | ||
} | ||
|
||
if (preg_match("([A-Z]{2,})", substr($param, -4))) { // At least two CAPITALS at the end of a string == Spam! | ||
if (preg_match("([A-Z]{2,})", | ||
substr($param, -4))) { // At least two CAPITALS at the end of a string == Spam! | ||
$_index += 1; | ||
$helper->log("SPAM: " . $param . " has at least 2 CAPITAL letters at the end"); | ||
} | ||
|
@@ -120,7 +121,8 @@ public function check($firstname, $lastname, $emailprefix, $params) | |
$helper->log("SPAM: " . $param . " contains more than 3 CAPITALS at all"); | ||
} | ||
|
||
if (preg_match("([a-z])", substr($param, 1, 1)) && preg_match("([A-Z])", substr($param, 1, 1))) { // Param starts with a lowercase+uppercase | ||
if (preg_match("([a-z])", substr($param, 1, 1)) | ||
&& preg_match("([A-Z])", substr($param, 1, 1))) { // Param starts with a lowercase+uppercase | ||
$_index += 1; | ||
$helper->log("SPAM: " . $param . " starts with a combination lc/uc. E.g. aJohn, bSmith..."); | ||
} | ||
|
Oops, something went wrong.