[pLog-svn] r4930 - plugins/branches/lifetype-1.2/unported/blogstatistics

Matt Wood matt at woodzy.com
Fri Mar 2 12:39:54 EST 2007


InjectSQL eh? Thats a scary function name, threw off my gmail labeling
scheme ;)

On 3/2/07, jondaley at devel.lifetype.net <jondaley at devel.lifetype.net> wrote:
>
> Author: jondaley
> Date: 2007-03-02 12:20:04 -0500 (Fri, 02 Mar 2007)
> New Revision: 4930
>
> Modified:
>    plugins/branches/lifetype-1.2
> /unported/blogstatistics/pluginblogstatistics.class.php
> Log:
> updated some of this plugin for 1.1. moved some includes for 1.2.  fixed
> some typos
>
> Modified: plugins/branches/lifetype-1.2
> /unported/blogstatistics/pluginblogstatistics.class.php
> ===================================================================
> --- plugins/branches/lifetype-1.2/unported/blogstatistics/pluginblogstatistics.class.php        2007-03-02
> 17:14:06 UTC (rev 4929)
> +++ plugins/branches/lifetype-1.2/unported/blogstatistics/pluginblogstatistics.class.php        2007-03-02
> 17:20:04 UTC (rev 4930)
> @@ -1,6 +1,6 @@
> <?php
> //
> -// blogstatistics - pLog Blog Statistics and Traffic Statistics
> +// blogstatistics - LifeType Blog Statistics and Traffic Statistics
> //
> // Copyright 2004 by Minstrel Chiu. All rights reserved.
> //
> @@ -18,27 +18,27 @@
> // limitations under the License.
> //
>
> -include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
> -include_once( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
> -include_once( PLOG_CLASS_PATH."class/dao/model.class.php" );
> -include_once( PLOG_CLASS_PATH."class/data/Date.class.php" );
> -include_once( PLOG_CLASS_PATH."class/net/client.class.php" );
> -include_once( PLOG_CLASS_PATH."class/net/url.class.php" );
> -include_once( PLOG_CLASS_PATH."class/net/httpvars.class.php" );
> -include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
> +       lt_include( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
> +       lt_include( PLOG_CLASS_PATH."class/dao/model.class.php" );
> +       lt_include( PLOG_CLASS_PATH."class/data/Date.class.php" );
> +//     lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
>
> -class PluginBlogStatistics extends PluginBase
> -{
> -    var $_prefix;
> -    var $_now;
> -    var $_date;
> -    var $_prevdate;
> -    var $_weekdate;
> -    var $_month;
> -    var $_onlinestamp;
> +       class PluginBlogStatistics extends PluginBase
> +       {
> +               var $_prefix;
> +               var $_now;
> +               var $_date;
> +               var $_prevdate;
> +               var $_weekdate;
> +               var $_month;
> +               var $_onlinestamp;
>
> -    function PluginBlogStatistics()
> +               function PluginBlogStatistics($source = "")
>                 {
> +                       $this->PluginBase();
> +            $this->version = '20070302';
> +                       $this->id = "blogstatistics";
> +
>                         $this->author = "Minstrel Chiu";
>                         $this->desc = "
>                         <p>This plugin offers a statistics of plog. Part
> of code is originally written by Mark Wu. And also thanks to Reic Wang.<br>
> @@ -46,10 +46,10 @@
>                         <b>{\$blogstatistics->logStatistics()}</b><br>
>                         <br>
>                         Several functions are available:<br>
> -                        1. <b>Totoal Read Number</b>:
> <b><i>getTotalReadNumber()</i></b><br>
> -                        2. <b>Totoal Post Number</b>:
> <b><i>getTotalPostNumber()</i></b><br>
> -                        3. <b>Totoal Comment Number</b>:
> <b><i>getTotalCommentNumber()</i></b><br>
> -                        4. <b>Totoal Trackback Number</b>:
> <b><i>getTotalTrackbackNumber()</i></b><br>
> +                        1. <b>Total Read Number</b>:
> <b><i>getTotalReadNumber()</i></b><br>
> +                        2. <b>Total Post Number</b>:
> <b><i>getTotalPostNumber()</i></b><br>
> +                        3. <b>Total Comment Number</b>:
> <b><i>getTotalCommentNumber()</i></b><br>
> +                        4. <b>Total Trackback Number</b>:
> <b><i>getTotalTrackbackNumber()</i></b><br>
>                          5. <b>Total Referer Number</b>:
> <b><i>getTotalRefererNumber()</i></b><br>
>                          6. <b>Today Visitor</b>:
> <b><i>getTodayVisitor()</i></b><br>
>                          7. <b>Today Distinct Visitor</b>:
> <b><i>getTodayDistinctVisitor()</i></b><br>
> @@ -84,7 +84,8 @@
>                         </b></p>
>                         </p>";
>
> -                       $config = new Config();
> +
> +                       $config =& Config::getConfig();
>                         $this->_prefix = $config->getValue('db_prefix');
>
>                         $this->_now = new Date();
> @@ -107,19 +108,18 @@
>                         $online->subtractSeconds(360);
>
>                         $this->_onlinestamp =
> $online->getDate(DATE_FORMAT_TIMESTAMP);
> -
> -                       $this->PluginBase();
>                 }
>
> -    function register()
> -               {
> -                       $this->connectDb();
> -                       $stat = new BlogStatistics();
> -                       $stat->createTable();
> +               function register(){
> +                   $this->db =& Db::getDb();
> +            $stat = new BlogStatistics();
> +            $stat->createTable();
>                 }
>
> -    function logStatistics()
> -               {
> +               function logStatistics(){
> +            lt_include( PLOG_CLASS_PATH."class/net/url.class.php" );
> +            lt_include( PLOG_CLASS_PATH."class/net/client.class.php" );
> +
>                         $blog = $this->blogInfo->getId();
>                         $timestamp =
> $this->_now->getDate(DATE_FORMAT_TIMESTAMP);
>                         $clientip = Client::getIp();
> @@ -137,13 +137,13 @@
>                         $params = HttpVars::getRequest();
>                         $articleId = $params["articleId"];
>
> -                       if($articleId == "")
> +            if((preg_match("/[^0-9]/", $articleId) != 0) || $articleId ==
> "")
>                                 $articleId = 0;
>
>                         $this->injectSql("(`blog_id`, `article_id`,
> `time`, `ip`,  `refer`, `agent`) VALUES ('$blog', '$articleId',
> '$timestamp', '$clientip', '$refer', '$agent');");
>                 }
>
> -    function injectSql($dbqry)
> +               function injectSql($dbqry)
>                 {
>                         $query = "INSERT INTO ".$this->_prefix."statistics
> $dbqry";
>                         $result = $this->db->Execute( $query );
> @@ -157,9 +157,9 @@
>                 //
>
>                 ////////////////////////////////////////////////////////////////////////////////////////////
>
> -    function getTotalPostNumber($blogId = -1)
> +               function getTotalPostNumber($blogId = -1)
>                 {
> -                       $query = "SELECT * FROM ".$this->_prefix."articles
> WHERE status='published'";
> +                       $query = "SELECT * FROM ".$this->_prefix."articles
> WHERE status=1";
>
>                         if( $blogId != -1 )
>                                 $query .= " AND blog_id = ".$blogId;
> @@ -174,9 +174,9 @@
>                         return $count;
>                 }
>
> -    function getTotalCommentNumber($blogId = -1)
> +               function getTotalCommentNumber($blogId = -1)
>                 {
> -                       $query = "SELECT * FROM
> ".$this->_prefix."articles_comments,".$this->_prefix."articles WHERE
> ".$this->_prefix."articles_comments.article_id=".$this->_prefix."
> articles.id AND ".$this->_prefix."articles.status='published'";
> +                       $query = "SELECT * FROM
> ".$this->_prefix."articles_comments,".$this->_prefix."articles WHERE
> ".$this->_prefix."articles_comments.article_id=".$this->_prefix."
> articles.id AND ".$this->_prefix."articles.status=1";
>
>                         if( $blogId != -1 )
>                                 $query .= " AND ".$this->_prefix."
> articles.blog_id=".$blogId;
> @@ -191,9 +191,9 @@
>                         return $count;
>                 }
>
> -    function getTotalReadNumber($blogId = -1)
> +               function getTotalReadNumber($blogId = -1)
>                 {
> -                       $query = "SELECT SUM(num_reads) AS readNumber FROM
> ".$this->_prefix."articles WHERE status='published'";
> +                       $query = "SELECT SUM(num_reads) AS readNumber FROM
> ".$this->_prefix."articles WHERE status=1";
>
>                         if( $blogId != -1 )
>                                 $query .= " AND blog_id = ".$blogId;
> @@ -209,7 +209,7 @@
>                         return $row["readNumber"];
>                 }
>
> -    function getTotalRefererNumber($blogId = -1)
> +               function getTotalRefererNumber($blogId = -1)
>                 {
>                         $query = "SELECT * FROM
> ".$this->_prefix."referers";
>
> @@ -226,9 +226,9 @@
>                         return $count;
>                 }
>
> -    function getTotalTrackbackNumber($blogId = -1)
> +               function getTotalTrackbackNumber($blogId = -1)
>                 {
> -                       $query = "SELECT * FROM
> ".$this->_prefix."trackbacks,".$this->_prefix."articles WHERE
> ".$this->_prefix."trackbacks.article_id=".$this->_prefix."articles.id AND
> ".$this->_prefix."articles.status='published'";
> +                       $query = "SELECT * FROM
> ".$this->_prefix."trackbacks,".$this->_prefix."articles WHERE
> ".$this->_prefix."trackbacks.article_id=".$this->_prefix."articles.id AND
> ".$this->_prefix."articles.status=1";
>
>                         if( $blogId != -1 )
>                                 $query .= " AND ".$this->_prefix."
> articles.blog_id=".$blogId;
> @@ -251,7 +251,7 @@
>                 //
>
>                 ////////////////////////////////////////////////////////////////////////////////////////////
>
> -    function getOnlineVisitor($blogId = -1)
> +               function getOnlineVisitor($blogId = -1)
>                 {
>                         $query = "SELECT DISTINCT ip FROM
> ".$this->_prefix."statistics WHERE date_format(time, '%Y%m%d%H%i%S') >=
> ".$this->_onlinestamp;
>
> @@ -268,7 +268,7 @@
>                         return $count;
>                 }
>
> -    function getTotalVisitor($blogId = -1)
> +               function getTotalVisitor($blogId = -1)
>                 {
>                         $query = "SELECT * FROM
> ".$this->_prefix."statistics";
>
> @@ -285,7 +285,7 @@
>                         return $count;
>                 }
>
> -    function getTotalDistinctVisitor($blogId = -1)
> +               function getTotalDistinctVisitor($blogId = -1)
>                 {
>                         $query = "SELECT DISTINCT ip FROM
> ".$this->_prefix."statistics";
>
> @@ -302,7 +302,7 @@
>                         return $count;
>                 }
>
> -    function getTodayVisitor($blogId = -1)
> +               function getTodayVisitor($blogId = -1)
>                 {
>                         $query = "SELECT * FROM
> ".$this->_prefix."statistics WHERE date_format(time, '%Y%m%d') =
> ".$this->_date;
>
> @@ -319,7 +319,7 @@
>                         return $count;
>                 }
>
> -    function getTodayDistinctVisitor($blogId = -1)
> +               function getTodayDistinctVisitor($blogId = -1)
>                 {
>                         $query = "SELECT DISTINCT ip FROM
> ".$this->_prefix."statistics WHERE date_format(time, '%Y%m%d') =
> ".$this->_date;
>
> @@ -336,7 +336,7 @@
>                         return $count;
>                 }
>
> -    function getYesterdayVisitor($blogId = -1)
> +               function getYesterdayVisitor($blogId = -1)
>                 {
>                         $query = "SELECT * FROM
> ".$this->_prefix."statistics WHERE date_format(`time`, '%Y%m%d' ) =
> ".$this->_prevdate;
>                         if( $blogId != -1 )
> @@ -352,7 +352,7 @@
>                         return $count;
>                 }
>
> -    function getYesterdayDistinctVisitor($blogId = -1)
> +               function getYesterdayDistinctVisitor($blogId = -1)
>                 {
>                         $query = "SELECT DISTINCT ip FROM
> ".$this->_prefix."statistics WHERE date_format(`time`, '%Y%m%d' )
> =".$this->_prevdate;
>
> @@ -369,7 +369,7 @@
>                         return $count;
>                 }
>
> -    function getThisWeekVisitor($blogId = -1)
> +               function getThisWeekVisitor($blogId = -1)
>                 {
>                         $query = "SELECT * FROM
> ".$this->_prefix."statistics WHERE (date_format(`time`, '%Y%m%d')) >=
> ".$this->_weekdate;
>
> @@ -386,7 +386,7 @@
>                         return $count;
>                 }
>
> -    function getThisWeekDistinctVisitor($blogId = -1)
> +               function getThisWeekDistinctVisitor($blogId = -1)
>                 {
>                         $query = "SELECT DISTINCT ip FROM
> ".$this->_prefix."statistics WHERE (date_format(`time`, '%Y%m%d')) >=
> ".$this->_weekdate;
>
> @@ -403,7 +403,7 @@
>                         return $count;
>                 }
>
> -    function getThisMonthVisitor($blogId = -1)
> +               function getThisMonthVisitor($blogId = -1)
>                 {
>                         $query = "SELECT * FROM
> ".$this->_prefix."statistics WHERE date_format(`time`, '%Y%m') =
> ".$this->_month;
>
> @@ -420,7 +420,7 @@
>                         return $count;
>                 }
>
> -    function getThisMonthDistinctVisitor($blogId = -1)
> +               function getThisMonthDistinctVisitor($blogId = -1)
>                 {
>                         $query = "SELECT DISTINCT ip FROM
> ".$this->_prefix."statistics WHERE date_format(`time`, '%Y%m') =
> ".$this->_month;
>
> @@ -436,22 +436,22 @@
>
>                         return $count;
>                 }
> -}
> +       }
>
> -class BlogStatistics extends Model
> -{
> -    function BlogStatistics()
> +       class BlogStatistics extends Model
> +       {
> +               function BlogStatistics()
>                 {
>                         $this->Model();
>                 }
>
> -    function checkTable($table, $field)
> +               function checkTable($table, $field)
>                 {
>                         $dbPrefix = $this->getPrefix();
>                         $tableName = $dbPrefix.$table;
>
> -                // create the data dictionary and create the table if
> necessary
> -                       $dict = NewPDbDataDictionary( $this->_db );
> +                       // create the data dictionary and create the table
> if necessary
> +                       $dict = NewDataDictionary( $this->_db );
>                         $sqlArray = $dict->ChangeTableSQL( $tableName,
> $field );
>                         $result = $dict->ExecuteSQLArray( $sqlArray );
>
> @@ -459,7 +459,7 @@
>                                 $this->_desc = "There was an error
> initializing the tables.";
>                 }
>
> -    function createTable()
> +               function createTable()
>                 {
>                         $table = "statistics";
>                         $field = "blog_id I(10) NOT NULL default '-1',
> @@ -473,7 +473,6 @@
>
>                         return true;
>                 }
> -}
> +       }
>
> -PluginManager::registerPlugin( "blogstatistics", "PluginBlogStatistics"
> );
> ?>
>
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.lifetype.net
> http://limedaley.com/mailman/listinfo/plog-svn
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://limedaley.com/pipermail/plog-svn/attachments/20070302/7a73957a/attachment-0001.htm 


More information about the pLog-svn mailing list