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