[pLog-svn] r1172 - in plugins/trunk: . validatetrackbackvalidatetrackback/class validatetrackback/class/actionvalidatetrackback/class/view validatetrackback/localevalidatetrackback/templates

Mark Wu markplace at gmail.com
Sun Feb 27 16:31:20 GMT 2005


Hi Paul:

Well, next time, I will leave this to you... Then you will have chance.
Heehee ..... It is my pleasure to do this, I learn a new idea to anti
spammer from you.

Regards, Mark=20

-----Original Message-----
From: plog-svn-bounces at devel.plogworld.net
[mailto:plog-svn-bounces at devel.plogworld.net] On Behalf Of Paul =
Westbrook
Sent: Sunday, February 27, 2005 7:34 AM
To: plog-svn at devel.plogworld.net
Subject: Re: [pLog-svn] r1172 - in plugins/trunk: .
validatetrackbackvalidatetrackback/class
validatetrackback/class/actionvalidatetrackback/class/view
validatetrackback/localevalidatetrackback/templates

Hello,
    Thank you for doing this.  I hadn't had a chance to get to this.

--Paul


On Feb 23, 2005, at 7:08 AM, mark at devel.plogworld.net wrote:

> Author: mark
> Date: 2005-02-23 15:08:14 +0000 (Wed, 23 Feb 2005) New Revision: 1172
>
> Added:
>    plugins/trunk/validatetrackback/
>    plugins/trunk/validatetrackback/class/
>    plugins/trunk/validatetrackback/class/action/
>    =20
> plugins/trunk/validatetrackback/class/action/
> adminvalidatetrackbackpluginsettingsaction.class.php
>    =20
> plugins/trunk/validatetrackback/class/action/
> adminvalidatetrackbackpluginupdatesettingsaction.class.php
>    plugins/trunk/validatetrackback/class/view/
>    =20
> plugins/trunk/validatetrackback/class/view/
> adminvalidatetrackbackpluginsettingsview.class.php
>    plugins/trunk/validatetrackback/locale/
>    plugins/trunk/validatetrackback/locale/locale_en_UK.php
>    plugins/trunk/validatetrackback/locale/locale_zh_TW.php
>    plugins/trunk/validatetrackback/pluginvalidatetrackback.class.php
>    plugins/trunk/validatetrackback/templates/
>    plugins/trunk/validatetrackback/templates/pluginsettings.template
> Log:
> Update the validatetrackback UI to follow the plog 1.0 UI guideline.
>
> Added: =20
> plugins/trunk/validatetrackback/class/action/
> adminvalidatetrackbackpluginsettingsaction.class.php
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> ---
> plugins/trunk/validatetrackback/class/action/=20
> adminvalidatetrackbackpluginsettingsaction.class.php	2005-02-23 =20
> 13:47:41 UTC (rev 1171)
> +++ =20
> plugins/trunk/validatetrackback/class/action/=20
> adminvalidatetrackbackpluginsettingsaction.class.php	2005-02-23 =20
> 15:08:14 UTC (rev 1172)
> @@ -0,0 +1,31 @@
> +<?php
> +
> +	include_once(
> PLOG_CLASS_PATH."class/action/admin/blogowneradminaction.class.php" );
> +    include_once(
> PLOG_CLASS_PATH."plugins/validatetrackback/class/view/
> adminvalidatetrackbackpluginsettingsview.class.php" );
> +
> +    class AdminValidateTrackbackPluginSettingsAction extends
> BlogOwnerAdminAction
> +	{
> +
> +    	/**
> +         * Constructor. If nothing else, it also has to call the
> constructor of the parent
> +         * class, BlogAction with the same parameters
> +         */
> +        function AdminValidateTrackbackPluginSettingsAction(
> $actionInfo, $request )
> +        {
> +        	$this->BlogOwnerAdminAction( $actionInfo, $request );
> +        }
> +
> +        /**
> +         * Carries out the specified action
> +         */
> +        function perform()
> +        {
> +			$this->_view =3D new
AdminValidateTrackbackPluginSettingsView(
> $this->_blogInfo );
> +
> +            $this->setCommonData();
> +
> +            // better to return true if everything fine
> +            return true;
> +        }
> +    }
> +?>
>
> Added: =20
> plugins/trunk/validatetrackback/class/action/
> adminvalidatetrackbackpluginupdatesettingsaction.class.php
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> ---
> plugins/trunk/validatetrackback/class/action/=20
> adminvalidatetrackbackpluginupdatesettingsaction.class.php	2005-02-23  =

> 13:47:41 UTC (rev 1171)
> +++ =20
> plugins/trunk/validatetrackback/class/action/=20
> adminvalidatetrackbackpluginupdatesettingsaction.class.php	2005-02-23  =

> 15:08:14 UTC (rev 1172)
> @@ -0,0 +1,63 @@
> +<?php
> +
> +	include_once(
> PLOG_CLASS_PATH."class/action/admin/blogowneradminaction.class.php" );
> +    include_once(
> PLOG_CLASS_PATH."plugins/validatetrackback/class/view/
> adminvalidatetrackbackpluginsettingsview.class.php" );
> +
> +    class AdminValidateTrackbackPluginUpdateSettingsAction extends
> BlogOwnerAdminAction
> +	{
> +=09
> +		var $_pluginEnabled;
> +
> +    	/**
> +         * Constructor. If nothing else, it also has to call the
> constructor of the parent
> +         * class, BlogAction with the same parameters
> +         */
> +        function AdminValidateTrackbackPluginUpdateSettingsAction(
> $actionInfo, $request )
> +        {
> +        	$this->BlogOwnerAdminAction( $actionInfo, $request );
> +        }
> +	=09
> +		function validate()
> +		{
> +            $this->_pluginEnabled =3D $this->_request->getValue(
> "pluginEnabled" );
> +            $this->_pluginEnabled =3D ($this->_pluginEnabled !=3D ""
);		=09
> +		=09
> +			return true;
> +		}
> +	=09
> +        /**
> +         * Carries out the specified action
> +         */
> +        function perform()
> +        {
> +            // update the plugin configurations to blog setting
> +			$blogSettings =3D $this->_blogInfo->getSettings();
> +            $blogSettings->setValue(
> "plugin_validatetrackback_enabled", $this->_pluginEnabled );
> +            $this->_blogInfo->setSettings( $blogSettings );
> +	=09
> +			// save the blogs settings
> +			$blogs =3D new Blogs();
> +            if( !$blogs->updateBlog( $this->_blogInfo->getId(),
> $this->_blogInfo )) {
> +                $this->_view =3D new
> AdminValidateTrackbackPluginSettingsView( $this->_blogInfo );
> +                $this->_view->setErrorMessage(
> $this->_locale->tr("error_updating_settings"));
> +                $this->setCommonData();
> +
> +                return false;
> +            }
> +		=09
> +			// if everything went ok...
> +            $this->_blogInfo->setSettings( $blogSettings );
> +            $this->_session->setValue( "blogInfo", $this->_blogInfo =
);
> +            $this->saveSession();
> +		=09
> +			$this->_view =3D new
AdminValidateTrackbackPluginSettingsView(
> $this->_blogInfo );
> +			$this->_view->setSuccessMessage(
>
$this->_locale->tr("validatetrackback_settings_saved_ok"));	=09

> +			$this->setCommonData();
> +		=09
> +			// clear the cache
> +			CacheControl::resetBlogCache(
$this->_blogInfo->getId());				=09
> +
> +            return true;	=09
> +        }
> +    }
> +?>
>
> Added: =20
> plugins/trunk/validatetrackback/class/view/
> adminvalidatetrackbackpluginsettingsview.class.php
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> ---
> plugins/trunk/validatetrackback/class/view/=20
> adminvalidatetrackbackpluginsettingsview.class.php	2005-02-23 13:47:41

> UTC (rev 1171)
> +++ =20
> plugins/trunk/validatetrackback/class/view/=20
> adminvalidatetrackbackpluginsettingsview.class.php	2005-02-23 15:08:14

> UTC (rev 1172)
> @@ -0,0 +1,28 @@
> +<?php
> +=09
> +	include_once(
> PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php"  =

> );
> +
> +	/**
> +	 * implements the main view of the feed reader plugin
> +	 */
> +	class AdminValidateTrackbackPluginSettingsView extends
> AdminPluginTemplatedView
> +	{
> +
> +		function AdminValidateTrackbackPluginSettingsView( $blogInfo
)
> +		{
> +			$this->AdminPluginTemplatedView( $blogInfo,
"validatetrackback",
> "pluginsettings" );
> +		}
> +	=09
> +		function render()
> +		{
> +			// load some configuration settings
> +			$blogSettings =3D $this->_blogInfo->getSettings();
> +			$pluginEnabled =3D $blogSettings->getValue(
> "plugin_validatetrackback_enabled" );
> +		=09
> +			// create a view and export the settings to the
template
> +			$this->setValue( "pluginEnabled", $pluginEnabled );

> +		=09
> +			parent::render();
> +		}
> +	}
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/validatetrackback/locale/locale_en_UK.php
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- plugins/trunk/validatetrackback/locale/locale_en_UK.php	2005-02-23 =
=20
> 13:47:41 UTC (rev 1171)
> +++ plugins/trunk/validatetrackback/locale/locale_en_UK.php	2005-02-23 =
=20
> 15:08:14 UTC (rev 1172)
> @@ -0,0 +1,5 @@
> +<?php
> +
> +$messages["validatetrackbackPluginSettings"] =3D "Validate =
Trackbacks";
> +
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/validatetrackback/locale/locale_zh_TW.php
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- plugins/trunk/validatetrackback/locale/locale_zh_TW.php	2005-02-23 =
=20
> 13:47:41 UTC (rev 1171)
> +++ plugins/trunk/validatetrackback/locale/locale_zh_TW.php	2005-02-23 =
=20
> 15:08:14 UTC (rev 1172)
> @@ -0,0 +1,5 @@
> +<?php
> +
> +$messages["validatetrackbackPluginSettings"] =3D =
"=A4=DE=A5=CE=BA=F4=A7}=C5=E7=C3=D2=B3]=A9w";
> +
> +?>
> \ No newline at end of file
>
> Added: =20
> plugins/trunk/validatetrackback/pluginvalidatetrackback.class.php
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- =20
> plugins/trunk/validatetrackback/pluginvalidatetrackback.class.php	=20
> 2005-02-23 13:47:41 UTC (rev 1171)
> +++ =20
> plugins/trunk/validatetrackback/pluginvalidatetrackback.class.php	=20
> 2005-02-23 15:08:14 UTC (rev 1172)
> @@ -0,0 +1,126 @@
> +<?php
> +
> +	include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
> +    include_once(
> PLOG_CLASS_PATH."class/dao/trackbackclient.class.php" );
> +    include_once( PLOG_CLASS_PATH."class/dao/trackbacks.class.php" );
> +	include_once( PLOG_CLASS_PATH."class/net/http/httpclient.class.php"

> );
> +=09
> +	/**
> +	 * implements moderation of comments
> +	 */
> +	class PluginValidateTrackback extends PluginBase
> +	{
> +	    var $pluginEnabled;
> +=09
> +		function PluginValidateTrackback()
> +		{
> +			$this->PluginBase();
> +		=09
> +			$this->id =3D "validatetrackback";
> +			$this->desc =3D "Provides validation of trackbacks.";
> +			$this->author =3D "Paul Westbrook";
> +			$this->locales =3D Array( "en_UK", "zh_TW" );
> +		=09
> +			$this->init();
> +		}
> +
> +		/**
> +		 * registers all the filters and actions that we're going to
use
> +		 */
> +		function init()
> +		{		=09
> +			// register the events we want
> +			$this->registerNotification(
EVENT_POST_TRACKBACK_ADD );
> +		=09
> +			// register an action that will allow users to see
which comments
> have not been
> +			// accepted yet
> +			$this->registerAdminAction(
"validatetrackbackPluginSettings",
> "AdminValidateTrackbackPluginSettingsAction" );
> +			$this->registerAdminAction(
> "validatetrackbackPluginUpdateSettings",
> "AdminValidateTrackbackPluginUpdateSettingsAction" );
> +		=09
> +			// add a menu entry
> +			$menu =3D& Menu::getMenu();
> +            if( !$menu->entryExists(
> "/menu/controlCenter/manageAntiSpamPlugins" ))
> +                $this->addMenuEntry( "/menu/controlCenter",
> "manageAntiSpamPlugins", "", "", true, false );
> +            $this->addMenuEntry(
> "/menu/controlCenter/manageAntiSpamPlugins",
> "validatetrackbackPluginSettings",
> "admin.php?op=3DvalidatetrackbackPluginSettings", "", true, false );
> +		}
> +
> +		function register()
> +		{
> +		    $blogSettings =3D $this->blogInfo->getSettings();
> +			$this->pluginEnabled =3D $blogSettings->getValue( =20
> "plugin_validatetrackback_enabled" );
> +		}
> +
> +	    function isEnabled()
> +	    {
> +	        return $this->pluginEnabled;
> +	    }	=09
> +	=09
> +		/**
> +		 * process the events that we have registered
> +		 *
> +		 * @see PluginBase::process
> +		 * @see PluginManager
> +		 */
> +		function process( $eventType, $params )
> +		{
> +		    // make sure we're processing the right event!
> +		    if( $eventType !=3D EVENT_POST_TRACKBACK_ADD )
> +		      return true;
> +		=09
> +			// do nothing if the plugin is not enabled!
> +			$blogSettings =3D $this->blogInfo->getSettings();
> +			if( !$blogSettings->getValue(
"plugin_validatetrackback_enabled" ))
> +				return true;
> +		=09
> +			// change the stauts of the comment, as is easy as
it seems...
> +			$trackback =3D $params["trackback"];
> +			$this->Validate( $trackback );
> +	=09
> +			return true;
> +		}
> +	=09
> +	    /**
> +     	* Fetches a page from the given url.
> +	     *
> +	     * @param url The url with the page we would like to fetch.
> +	     * @return Returns a string with the contents of the page or an

> empty string if the page
> +	     * could not be fetched.
> +	     */
> +	    function fetchPage( $url )
> +	    {
> +    		$s =3D new HttpClient();
> +        	$result =3D $s->fetch( $url );
> +
> +        	if( !$result ) {
> +                            if($s->timed_out)
> +                	//print("timed out!!!");
> +        		return "";
> +
> +            }
> +        	else
> +        		return $s->results;
> +    	}
> +	=09
> +		function Validate( $trackback )
> +		{
> +            // Get the page
> +            $page =3D $this->fetchPage( $trackback->_url );
> +
> +            // Get the trackback client
> +            $tbClient =3D new TrackbackClient();
> +
> +            // get the trackback url
> +            $tbLinks =3D $tbClient->getTrackbackLinks( $page, $link =
);
> +            if( empty( $tbLinks)) {
> +                // there were no trackback links in the page
> + //               error_log( "Found no trackback urls" );
> +
> +                // Delete this trackback
> +                $trackbacks =3D new Trackbacks();
> +
> +                $trackbacks->deletePostTrackback( $trackback->_id, =20
> $trackback->_articleId );
> +                //print("Error: trackback unavailable<br/>");
> +            }
> +		}
> +	}
> +?>
> \ No newline at end of file
>
> Added: =20
> plugins/trunk/validatetrackback/templates/pluginsettings.template
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- =20
> plugins/trunk/validatetrackback/templates/pluginsettings.template	=20
> 2005-02-23 13:47:41 UTC (rev 1171)
> +++ =20
> plugins/trunk/validatetrackback/templates/pluginsettings.template	=20
> 2005-02-23 15:08:14 UTC (rev 1172)
> @@ -0,0 +1,24 @@
> +{include file=3D"$admintemplatepath/header.template"}
> +{include file=3D"$admintemplatepath/navigation.template" =20
> showOpt=3DvalidatetrackbackPluginSettings =20
> title=3D$locale->tr("validatetrackbackPluginSettings")}
> +<form name=3D"validatetrackbackPluginSettings" method=3D"post">
> + <fieldset class=3D"inputField">
> + <legend>{$locale->tr("label_configuration")}</legend>
> +  {include file=3D"$admintemplatepath/successmessage.template"}
> +  {include file=3D"$admintemplatepath/errormessage.template"}
> +  <div class=3D"field">
> +   <label for=3D"pluginEnabled">{$locale->tr("label_enable")}</label>
> +   <div class=3D"formHelp">
> +    <input class=3D"checkbox" type=3D"checkbox" =
name=3D"pluginEnabled" =20
> id=3D"pluginEnabled" {if $pluginEnabled} checked=3D"checked" {/if} =20
> value=3D"1" />{$locale->tr("validatetrackback_plugin_enabled")}
> +   </div>
> +  </div>
> +
> + </fieldset>
> +
> + <div class=3D"buttons">
> +  <input type=3D"hidden" name=3D"op" =20
> value=3D"validatetrackbackPluginUpdateSettings" />
> +  <input type=3D"reset" name=3D"{$locale->tr("reset")}" />
> +  <input type=3D"submit" name=3D"{$locale->tr("update_settings")}" =20
> value=3D"{$locale->tr("update")}" />
> + </div>
> +</form>
> +{include file=3D"$admintemplatepath/footernavigation.template"}
> +{include file=3D"$admintemplatepath/footer.template"}
> \ No newline at end of file
>
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.plogworld.net
> http://devel.plogworld.net/mailman/listinfo/plog-svn
>
>
--
Paul Westbrook
paul at westbrooks.org
<http://www.westbrooks.org>





More information about the pLog-svn mailing list