fixed core plugins db tables, ip column to IPv6 length
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
# $Id: ChangeLog,v 1.27 2007/10/25 13:56:39 brockhaus Exp $
|
||||
Version 2.9:
|
||||
|
||||
* fixed db table karmalog, ip column to IPv6 length
|
||||
|
||||
------------------------------------------------------------------------
|
||||
Version 2.0 (gregman):
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php # $Id:$
|
||||
<?php #
|
||||
// serendipity_event_karma.php 2778 2011-09-23 12:32:28Z garvinhicking $
|
||||
|
||||
@serendipity_plugin_api::load_language(dirname(__FILE__));
|
||||
|
||||
@define('PLUGIN_KARMA_DB_VERSION', '2.0');
|
||||
@define('PLUGIN_KARMA_DB_VERSION', '2.1');
|
||||
|
||||
class serendipity_event_karma extends serendipity_event
|
||||
{
|
||||
@ -14,7 +14,7 @@ class serendipity_event_karma extends serendipity_event
|
||||
/** @var int Minutes until voting will be enabled, if a timeout is in effect */
|
||||
var $karmaTimeOut = '';
|
||||
/** @var int Points for this entry: current vote until voting is recorded,
|
||||
* total points after voting is recorded
|
||||
* total points after voting is recorded
|
||||
*/
|
||||
var $karmaVoting = '';
|
||||
|
||||
@ -44,7 +44,7 @@ class serendipity_event_karma extends serendipity_event
|
||||
$propbag->add('description', PLUGIN_KARMA_BLAHBLAH);
|
||||
$propbag->add('stackable', false);
|
||||
$propbag->add('author', 'Garvin Hicking, Grischa Brockhaus, Judebert, Gregor Voeltz');
|
||||
$propbag->add('version', '2.8');
|
||||
$propbag->add('version', '2.9');
|
||||
$propbag->add('requirements', array(
|
||||
'serendipity' => '0.8',
|
||||
'smarty' => '2.6.7',
|
||||
@ -53,10 +53,10 @@ class serendipity_event_karma extends serendipity_event
|
||||
$propbag->add('event_hooks', array(
|
||||
'external_plugin' => true,
|
||||
'frontend_footer' => true,
|
||||
'frontend_configure' => true,
|
||||
'entry_display' => true,
|
||||
'css' => true,
|
||||
'backend_header' => true,
|
||||
'frontend_configure' => true,
|
||||
'entry_display' => true,
|
||||
'css' => true,
|
||||
'backend_header' => true,
|
||||
'backend_sidebar_entries' => true,
|
||||
'backend_sidebar_entries_event_display_karmalog' => true,
|
||||
'event_additional_statistics' => true
|
||||
@ -191,7 +191,7 @@ class serendipity_event_karma extends serendipity_event
|
||||
$propbag->add('description', PLUGIN_KARMA_MIN_DISPLAYABLE_VOTES_BLAHBLAH);
|
||||
$propbag->add('default', '0');
|
||||
break;
|
||||
|
||||
|
||||
// Is extended article visit tracking allowed?
|
||||
case 'visits_active':
|
||||
$propbag->add('type', 'boolean');
|
||||
@ -216,7 +216,7 @@ class serendipity_event_karma extends serendipity_event
|
||||
$propbag->add('default', '0');
|
||||
break;
|
||||
|
||||
// Are we tracking exits?
|
||||
// Are we tracking exits?
|
||||
case 'exits_active':
|
||||
$propbag->add('type', 'boolean');
|
||||
$propbag->add('name', SHOWS_TOP_EXIT);
|
||||
@ -383,9 +383,13 @@ class serendipity_event_karma extends serendipity_event
|
||||
function checkScheme() {
|
||||
global $serendipity;
|
||||
|
||||
$version = $this->get_config('dbversion', '0');
|
||||
$version = $this->get_config('dbversion', '0');
|
||||
|
||||
if ($version == '1.1') {
|
||||
if ($version == '2.0') {
|
||||
$q = "ALTER TABLE {$serendipity['dbPrefix']}karmalog CHANGE COLUMN ip ip VARCHAR(45)";
|
||||
$sql = serendipity_db_schema_import($q);
|
||||
$this->set_config('dbversion', PLUGIN_KARMA_DB_VERSION);
|
||||
} elseif ($version == '1.1') {
|
||||
$q = "ALTER TABLE {$serendipity['dbPrefix']}karma ADD visits INT(11) default 0";
|
||||
$sql = serendipity_db_schema_import($q);
|
||||
$this->set_config('dbversion', PLUGIN_KARMA_DB_VERSION);
|
||||
@ -396,7 +400,7 @@ class serendipity_event_karma extends serendipity_event
|
||||
$q = "CREATE TABLE {$serendipity['dbPrefix']}karmalog (
|
||||
entryid int(11) default null,
|
||||
points int(4) default null,
|
||||
ip varchar(15),
|
||||
ip varchar(45),
|
||||
user_agent varchar(255),
|
||||
votetime int(11) default null
|
||||
)";
|
||||
@ -415,7 +419,7 @@ class serendipity_event_karma extends serendipity_event
|
||||
$q = "CREATE TABLE {$serendipity['dbPrefix']}karmalog (
|
||||
entryid int(11) default null,
|
||||
points int(4) default null,
|
||||
ip varchar(15),
|
||||
ip varchar(45),
|
||||
user_agent varchar(255),
|
||||
votetime int(11) default null
|
||||
)";
|
||||
@ -433,7 +437,7 @@ class serendipity_event_karma extends serendipity_event
|
||||
}
|
||||
|
||||
/**
|
||||
* Unused; would create sidebar content.
|
||||
* Unused; would create sidebar content.
|
||||
*/
|
||||
function generate_content(&$title)
|
||||
{
|
||||
@ -496,7 +500,7 @@ class serendipity_event_karma extends serendipity_event
|
||||
|
||||
return sprintf($karma_exits, $points);
|
||||
}
|
||||
|
||||
|
||||
function performkarmaVote() {
|
||||
global $serendipity;
|
||||
// Make sure the karmaVote cookie is set, even if empty <a name="#1" />
|
||||
@ -521,7 +525,7 @@ class serendipity_event_karma extends serendipity_event
|
||||
$this->karmaVoting = (int)$serendipity['GET']['karmaVote'];
|
||||
}
|
||||
|
||||
// karmaVote cookie was just set (see name="#1"); this boils down to
|
||||
// karmaVote cookie was just set (see name="#1"); this boils down to
|
||||
// "if check cookie isn't 1, there's no real cookie".
|
||||
// The check cookie gets set when a rater is displayed,
|
||||
// so you've got no business voting if you haven't even
|
||||
@ -557,7 +561,7 @@ class serendipity_event_karma extends serendipity_event
|
||||
}
|
||||
|
||||
// Voting takes place here.
|
||||
//
|
||||
//
|
||||
// Get voting data from the database (keeps all entries,
|
||||
// even if no karma match)
|
||||
$q = 'SELECT *
|
||||
@ -611,7 +615,7 @@ class serendipity_event_karma extends serendipity_event
|
||||
|
||||
serendipity_db_query($q);
|
||||
} else {
|
||||
// Entry was too recently voted upon. Figure out
|
||||
// Entry was too recently voted upon. Figure out
|
||||
// how long until voting will be allowed (in minutes).
|
||||
$this->karmaVote = 'timeout';
|
||||
$this->karmaTimeOut = abs(ceil(($now - ($row['lastvote'] + $max_votetime)) / 60));
|
||||
@ -656,7 +660,7 @@ class serendipity_event_karma extends serendipity_event
|
||||
$this->karmaVote = 'voted';
|
||||
serendipity_setCookie('karmaVote', serialize($karma));
|
||||
}
|
||||
|
||||
|
||||
function karmaVoted($myvote,$points,$votes) {
|
||||
$msg = '<div class="serendipity_karmaSuccess">' . PLUGIN_KARMA_VOTED . '</div>';
|
||||
if ($this->get_config('rate_with_words', false)) {
|
||||
@ -669,7 +673,7 @@ class serendipity_event_karma extends serendipity_event
|
||||
$bar = $this->createRatingBar(null, $points, $votes);
|
||||
return array("myvote" => $myvote, "msg" => $msg, "bar" => $bar);
|
||||
}
|
||||
|
||||
|
||||
function createkarmaBlock($entryid, $textual_msg, $msg, $bar, $enough_votes, $textual_current, $enough_visits, $textual_visits, $points, $votes) {
|
||||
$image_class = '';
|
||||
if ($this->image_name != '0') {
|
||||
@ -717,7 +721,7 @@ class serendipity_event_karma extends serendipity_event
|
||||
// get up to 1.0 unless they're 3 times as wide as they
|
||||
// are tall; full-bar images with square segments will
|
||||
// be 1.666; and full-bar images with tall, narrow
|
||||
// segments will be greater than 1.0 unless they're
|
||||
// segments will be greater than 1.0 unless they're
|
||||
// nearly twice as high as they are wide.
|
||||
$this->image_width = $this->image_width * 5;
|
||||
}
|
||||
@ -752,7 +756,7 @@ function vote(karmaVote,karmaId) {
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
// Hook for ajax calls
|
||||
case 'external_plugin':
|
||||
$theUri = (string)str_replace('&', '&', $eventData);
|
||||
@ -768,7 +772,7 @@ function vote(karmaVote,karmaId) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$parts = explode('_', $uri_parts[0]);
|
||||
|
||||
switch($parts[0]) {
|
||||
@ -800,7 +804,7 @@ function vote(karmaVote,karmaId) {
|
||||
echo sprintf($karma_block, $myvote, $points, $sql[0]['votes'], $sql[0]['visits'], '');
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
break;
|
||||
|
||||
@ -814,16 +818,16 @@ function vote(karmaVote,karmaId) {
|
||||
// CSS generation hooks
|
||||
case 'backend_header':
|
||||
// Generate the CSS for the graphical rating bar selector
|
||||
//
|
||||
// The CSS appears to be generated in a completely
|
||||
//
|
||||
// The CSS appears to be generated in a completely
|
||||
// different instance of Serendipity, as if index.php gets
|
||||
// called separately for the CSS.
|
||||
//
|
||||
// Note that the css_backend hook adds properties to the
|
||||
// serendipity_admin.css, but that file is *always*
|
||||
// Note that the css_backend hook adds properties to the
|
||||
// serendipity_admin.css, but that file is *always*
|
||||
// cached. We use backend_header and add the CSS to the
|
||||
// HEAD styles to make it dynamic.
|
||||
|
||||
|
||||
// Get the CSS, set $this->image_name so we'll output the
|
||||
// standard graphical CSS prologue if any images are found.
|
||||
$this->createRatingSelector();
|
||||
@ -849,7 +853,7 @@ function vote(karmaVote,karmaId) {
|
||||
");
|
||||
case 'css':
|
||||
// Some CSS notes:
|
||||
//
|
||||
//
|
||||
// .serendipity_karmaVoting is the class for the karma wrapper/container,
|
||||
// including the text explanations, messages, and rating bar.
|
||||
// (currently a div)
|
||||
@ -865,11 +869,11 @@ function vote(karmaVote,karmaId) {
|
||||
// the graphical rating bar
|
||||
// .serendipity_karmaVoting_current-rating is the class for the current
|
||||
// rating in the graphical rating bar
|
||||
// a.serendipity_karmaVoting_link1, _link2, etc are the classes applied
|
||||
// a.serendipity_karmaVoting_link1, _link2, etc are the classes applied
|
||||
// to the individual voting links
|
||||
|
||||
// Note that there are two possible template types: early
|
||||
// templates that only handle the text rating bars, and
|
||||
// templates that only handle the text rating bars, and
|
||||
// newer templates that understand the graphical raters.
|
||||
// We check for both types and act appropriately.
|
||||
/*--JAM: Let's just skip this whole hassle
|
||||
@ -916,7 +920,7 @@ function vote(karmaVote,karmaId) {
|
||||
}
|
||||
$pos = strpos($eventData, '.serendipity_karmaVoting', $endpos);
|
||||
}
|
||||
// I should have a valid alignment or 'detect' in $align now.
|
||||
// I should have a valid alignment or 'detect' in $align now.
|
||||
}
|
||||
}
|
||||
// If we couldn't detect the alignment, guess 'right'
|
||||
@ -952,7 +956,7 @@ function vote(karmaVote,karmaId) {
|
||||
EOS;
|
||||
// Only output the image CSS if it's needed
|
||||
if ($this->image_name != '0') {
|
||||
$img = $serendipity['baseURL'] . "plugins/serendipity_event_karma/img/" . $this->image_name;
|
||||
$img = $serendipity['baseURL'] . "plugins/serendipity_event_karma/img/" . $this->image_name;
|
||||
$h = $this->image_height / 3;
|
||||
$w = $this->image_width;
|
||||
switch ($align) {
|
||||
@ -968,12 +972,12 @@ EOS;
|
||||
break;
|
||||
|
||||
}
|
||||
// The CSS here is lifted largely from
|
||||
// The CSS here is lifted largely from
|
||||
// http://komodomedia.com/blog/index.php/2007/01/20/css-star-rating-redux/
|
||||
//
|
||||
// Note, however that margin has been changed for
|
||||
// multiple cases and all unitless measurements have
|
||||
// been specified in pixels. Additionally, measures
|
||||
// multiple cases and all unitless measurements have
|
||||
// been specified in pixels. Additionally, measures
|
||||
// have been taken to align the text.
|
||||
print <<<END_IMG_CSS
|
||||
|
||||
@ -994,11 +998,11 @@ EOS;
|
||||
list-style: none;
|
||||
margin: $margin;
|
||||
padding: 0px;
|
||||
background-position: left top;
|
||||
background-position: left top;
|
||||
text-align: center;
|
||||
}
|
||||
.serendipity_karmaVoting_links li {
|
||||
display: inline;
|
||||
display: inline;
|
||||
}
|
||||
.serendipity_karmaVoting_links a ,
|
||||
.serendipity_karmaVoting_current-rating {
|
||||
@ -1101,11 +1105,11 @@ END_IMG_CSS;
|
||||
|
||||
// Add voting information to entries
|
||||
case 'entry_display':
|
||||
// Update database if necessary
|
||||
// Update database if necessary
|
||||
if ($this->get_config('dbversion', 0) != PLUGIN_KARMA_DB_VERSION) {
|
||||
$this->checkScheme();
|
||||
}
|
||||
|
||||
|
||||
// Find the ID of this entry
|
||||
if (isset($serendipity['GET']['id'])) {
|
||||
$entryid = (int)serendipity_db_escape_string($serendipity['GET']['id']);
|
||||
@ -1134,7 +1138,7 @@ END_IMG_CSS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Set a cookie to look for later, verifying that cookies are enabled
|
||||
serendipity_setCookie('check', '1');
|
||||
|
||||
@ -1195,7 +1199,7 @@ END_IMG_CSS;
|
||||
// Find out what the admin wants
|
||||
$track_clicks = serendipity_db_bool($this->get_config('visits_active', true));
|
||||
$track_karma = serendipity_db_bool($this->get_config('karma_active', true));
|
||||
|
||||
|
||||
if (serendipity_db_bool($this->get_config('karma_active_registered', false))) {
|
||||
if (!serendipity_userLoggedIn()) $track_karma = false;
|
||||
}
|
||||
@ -1221,26 +1225,26 @@ END_IMG_CSS;
|
||||
// Single-entry URLs should be well-defined. They can be permalinks,
|
||||
// of course; otherwise they're of the configured pattern.
|
||||
//
|
||||
// Summary URLs could be a little harder. The summary pages that
|
||||
// include entries are: frontpage, category, author, and archives.
|
||||
// Summary URLs could be a little harder. The summary pages that
|
||||
// include entries are: frontpage, category, author, and archives.
|
||||
// It's possible a plugin would show entries, but if that's the case
|
||||
// we don't need to allow the user to vote on them. Still, that's
|
||||
// a lot of URLs to check for.
|
||||
//
|
||||
// Then there's the problem of the rest of the query. It could
|
||||
// include stuff we really want to keep around, like template
|
||||
// Then there's the problem of the rest of the query. It could
|
||||
// include stuff we really want to keep around, like template
|
||||
// overrides or something. One can even add serendipity variables
|
||||
// to the URL in extreme cases.
|
||||
//
|
||||
// It seems that canonicalizing the URL will be quite difficult.
|
||||
// The only thing we can say for certain is that whatever the
|
||||
// The only thing we can say for certain is that whatever the
|
||||
// current URL is, it got us to this page, and we'd like to return
|
||||
// to this page after we cast our vote.
|
||||
|
||||
|
||||
// Remove any clutter from our previous voting activity
|
||||
$url_parts = parse_url(serendipity_currentURL(true));
|
||||
if (!empty($url_parts['query'])) {
|
||||
$exclude = array('serendipity[karmaVote]', 'serendipity[karmaId]');
|
||||
$exclude = array('serendipity[karmaVote]', 'serendipity[karmaId]');
|
||||
// I tried using parse_str, but it gave me very weird results
|
||||
// with embedded arrays
|
||||
//parse_str($url_parts['query'], $q_parts);
|
||||
@ -1290,8 +1294,8 @@ END_IMG_CSS;
|
||||
if ($sql && is_array($sql)) {
|
||||
foreach($sql AS $row) {
|
||||
$rows[$row['entryid']] = array(
|
||||
'votes' => $row['votes'],
|
||||
'points' => $row['points'],
|
||||
'votes' => $row['votes'],
|
||||
'points' => $row['points'],
|
||||
'visits' => $row['visits']
|
||||
);
|
||||
}
|
||||
@ -1300,7 +1304,7 @@ END_IMG_CSS;
|
||||
$this->prepareExits($entries);
|
||||
|
||||
// Add karma block to the footer of each entry
|
||||
//
|
||||
//
|
||||
// The entries array was populated, above, so its keys match the eventData array,
|
||||
// and overview entries are skipped if "extended only" is enabled
|
||||
foreach (array_keys($entries) as $i) {
|
||||
@ -1322,18 +1326,18 @@ END_IMG_CSS;
|
||||
|
||||
// Where's the footer? Normally it would be
|
||||
// in eventData[n]['add_footer'] but if the
|
||||
// cache plugin is used, it's in
|
||||
// cache plugin is used, it's in
|
||||
// eventData[n]['properties']['ep_cache_add_footer'].
|
||||
// This method retrieves it either way.
|
||||
$footer = &$this->getFieldReference('add_footer', $eventData[$i]);
|
||||
|
||||
// Depending on what existed, $footer could
|
||||
// be referencing the cached version, the
|
||||
// uncached version, or even a new empty
|
||||
// string. In particular, if $eventData[$i]
|
||||
// has no properties, and no 'add_footer' key,
|
||||
// uncached version, or even a new empty
|
||||
// string. In particular, if $eventData[$i]
|
||||
// has no properties, and no 'add_footer' key,
|
||||
// $footer is referencing a new empty string,
|
||||
// so adding a karma bar to $footer would do
|
||||
// so adding a karma bar to $footer would do
|
||||
// nothing.
|
||||
//
|
||||
// We could be referencing an empty uncached
|
||||
@ -1363,15 +1367,13 @@ END_IMG_CSS;
|
||||
$bar = $temp['bar'];
|
||||
} elseif ($eventData[$i]['timestamp'] < ($now - $max_karmatime)) {
|
||||
// Too late to vote for this one
|
||||
$msg =
|
||||
'<div class="serendipity_karmaClosed">' . sprintf(PLUGIN_KARMA_CLOSED, $karmatime) . '</div>';
|
||||
$msg = '<div class="serendipity_karmaClosed">' . sprintf(PLUGIN_KARMA_CLOSED, $karmatime) . '</div>';
|
||||
// Just a current rating bar, if any
|
||||
$bar = $this->createRatingBar(null, $points, $votes);
|
||||
} else {
|
||||
// We can vote for this; make the whole voting block
|
||||
$rate_msg = $this->get_config('rate_msg', PLUGIN_KARMA_VOTETEXT);
|
||||
$msg =
|
||||
'<div class="serendipity_karmaVoting_text">' . $rate_msg . '</div>';
|
||||
$msg = '<div class="serendipity_karmaVoting_text">' . $rate_msg . '</div>';
|
||||
// Full voting bar
|
||||
$bar = $this->createRatingBar($entryid, $points, $votes);
|
||||
}
|
||||
@ -1392,7 +1394,7 @@ END_IMG_CSS;
|
||||
$eventData[$i]['properties']['points'] = $points;
|
||||
$eventData[$i]['properties']['votes'] = $votes;
|
||||
$eventData[$i]['properties']['visits'] = $visits;
|
||||
|
||||
|
||||
$footer .= sprintf($karma_block, $myvote, $points, $votes, $visits, $url);
|
||||
|
||||
} // foreach key in entries
|
||||
@ -1420,7 +1422,7 @@ END_IMG_CSS;
|
||||
&& sizeof($serendipity['POST']['delete']) != 0 && serendipity_checkFormToken()) {
|
||||
foreach($serendipity['POST']['delete'] as $d => $i) {
|
||||
$kdata = $serendipity['POST']['karmalog'.$i];
|
||||
// validate posted variables
|
||||
// validate posted variables
|
||||
// posted points
|
||||
$ppoints = $kdata['points'];
|
||||
if (!is_numeric($ppoints) || ((int)$ppoints < -2) || ((int)$ppoints > 2)) {
|
||||
@ -1509,7 +1511,7 @@ END_IMG_CSS;
|
||||
}
|
||||
}
|
||||
|
||||
// URL; expected to be event_display and karmalog, respectively
|
||||
// URL; expected to be event_display and karmalog, respectively
|
||||
$url = '?serendipity[adminModule]='.htmlspecialchars($serendipity['GET']['adminModule']).'&serendipity[adminAction]='.htmlspecialchars($serendipity['GET']['adminAction']);
|
||||
|
||||
// Filters
|
||||
@ -1772,7 +1774,7 @@ function invertSelection() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check, if visit counting for the actual visitor should be done.
|
||||
*/
|
||||
@ -1833,10 +1835,10 @@ function invertSelection() {
|
||||
";
|
||||
// Retrieve all the *valid* images from the image directory
|
||||
$files = $this->getImageFiles();
|
||||
// Add an <ol> for each rating bar, and add its CSS overrides
|
||||
// Add an <ol> for each rating bar, and add its CSS overrides
|
||||
$n = 0;
|
||||
foreach ($files as $fdata) {
|
||||
// Columnize
|
||||
// Columnize
|
||||
if (($n % 3) == 0) {
|
||||
// Time to start a new row
|
||||
$this->select_html .= "</tr>\n<tr>\n";
|
||||
@ -1874,7 +1876,7 @@ function invertSelection() {
|
||||
$bar_html = sprintf($bar_html, '', '2.5 of 5', '1');
|
||||
$this->select_html .= $bar_html;
|
||||
// Add the necessary CSS to the stylesheet (will be added when css hooks are called)
|
||||
// Sorry to interrupt your regularly scheduled HTML; I need to
|
||||
// Sorry to interrupt your regularly scheduled HTML; I need to
|
||||
// use the $css_class while it's still here.
|
||||
$this->select_css .= "
|
||||
/* Overrides for $css_class */
|
||||
@ -1936,19 +1938,19 @@ function invertSelection() {
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($folder);
|
||||
closedir($folder);
|
||||
ksort($images);
|
||||
return $images;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the HTML snippet for the currently defined rating bar, with
|
||||
* Creates the HTML snippet for the currently defined rating bar, with
|
||||
* appropriate links (and current rating indication for graphical bars).
|
||||
* Automatically detects from $this->image_name whether to create text
|
||||
* links or a graphical bar.
|
||||
*
|
||||
* @param string id optional The ID of the bar we're creating; an empty
|
||||
* id ('' or 0) creates a bar with dummy links; null creates a bar with
|
||||
* id ('' or 0) creates a bar with dummy links; null creates a bar with
|
||||
* no voting links at all (shows only current configuration).
|
||||
* @param int karma optional The current total karma (default: 0 points)
|
||||
* @param int votes optional The total number of votes (default: 0 votes))
|
||||
@ -1975,19 +1977,14 @@ function invertSelection() {
|
||||
$okaystr = $this->get_config('text_okay', PLUGIN_KARMA_VOTETEXT_3);
|
||||
$goodstr = $this->get_config('text_good', PLUGIN_KARMA_VOTETEXT_4);
|
||||
$beststr = $this->get_config('text_best', PLUGIN_KARMA_VOTETEXT_5);
|
||||
|
||||
|
||||
if (empty($id)) {
|
||||
// Create dummy links
|
||||
$link_1 =
|
||||
'<a class="serendipity_karmaVoting_link1" rel="nofollow" href="#" title="' . $vile . '">' . $vilestr . '</a>';
|
||||
$link_2 =
|
||||
'<a class="serendipity_karmaVoting_link2" rel="nofollow" href="#" title="' . $poor . '">' . $poorstr . '</a>';
|
||||
$link_3 =
|
||||
'<a class="serendipity_karmaVoting_link3" rel="nofollow" href="#" title="' . $okay . '">' . $okaystr . '</a>';
|
||||
$link_4 =
|
||||
'<a class="serendipity_karmaVoting_link4" rel="nofollow" href="#" title="' . $good . '">' . $goodstr . '</a>';
|
||||
$link_5 =
|
||||
'<a class="serendipity_karmaVoting_link5" rel="nofollow" href="#" title="' . $best . '">' . $beststr . '</a>';
|
||||
$link_1 = '<a class="serendipity_karmaVoting_link1" rel="nofollow" href="#" title="' . $vile . '">' . $vilestr . '</a>';
|
||||
$link_2 = '<a class="serendipity_karmaVoting_link2" rel="nofollow" href="#" title="' . $poor . '">' . $poorstr . '</a>';
|
||||
$link_3 = '<a class="serendipity_karmaVoting_link3" rel="nofollow" href="#" title="' . $okay . '">' . $okaystr . '</a>';
|
||||
$link_4 = '<a class="serendipity_karmaVoting_link4" rel="nofollow" href="#" title="' . $good . '">' . $goodstr . '</a>';
|
||||
$link_5 = '<a class="serendipity_karmaVoting_link5" rel="nofollow" href="#" title="' . $best . '">' . $beststr . '</a>';
|
||||
// There *are* enough votes for a dummy rating bar
|
||||
$enough_votes = true;
|
||||
} else {
|
||||
@ -2096,7 +2093,7 @@ function invertSelection() {
|
||||
*
|
||||
* @param int points The total karma points
|
||||
* @param int votes The total number of votes
|
||||
*
|
||||
*
|
||||
* @return string A string indicating the number of points "of 5",
|
||||
* or PLUGIN_KARMA_IMAGE_NONE_RATING if no votes have been recorded.
|
||||
*/
|
||||
@ -2119,7 +2116,7 @@ function invertSelection() {
|
||||
}
|
||||
|
||||
/* Compute the equivalent word rating for a karma rating.
|
||||
*
|
||||
*
|
||||
* @param mixed points The total karma points
|
||||
* @param mixed votes The total number of votes
|
||||
*
|
||||
|
@ -28,7 +28,7 @@ var $filter_defaults;
|
||||
'smarty' => '2.6.7',
|
||||
'php' => '4.1.0'
|
||||
));
|
||||
$propbag->add('version', '1.81');
|
||||
$propbag->add('version', '1.82');
|
||||
$propbag->add('event_hooks', array(
|
||||
'frontend_saveComment' => true,
|
||||
'external_plugin' => true,
|
||||
@ -277,7 +277,7 @@ var $filter_defaults;
|
||||
$propbag->add('type', 'radio');
|
||||
$propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_AKISMET_SERVER);
|
||||
$propbag->add('description', PLUGIN_EVENT_SPAMBLOCK_AKISMET_SERVER_DESC);
|
||||
// If the user has an API key, but hasn't set a server, he
|
||||
// If the user has an API key, but hasn't set a server, he
|
||||
// must be using an older version of the plugin; default
|
||||
// to akismet. Otherwise, encourage adoption of the Open
|
||||
// Source alternative, TypePad Antispam.
|
||||
@ -487,7 +487,7 @@ var $filter_defaults;
|
||||
'timeout' => 20,
|
||||
'allowRedirects' => true,
|
||||
'maxRedirects' => 3,
|
||||
'readTimeout' => array(5,0),
|
||||
'readTimeout' => array(5,0),
|
||||
);
|
||||
|
||||
// Default server type to akismet, in case user has an older version of the plugin
|
||||
@ -502,7 +502,7 @@ var $filter_defaults;
|
||||
case 'tpas':
|
||||
$server = 'api.antispam.typepad.com';
|
||||
break;
|
||||
|
||||
|
||||
case 'anon-akismet':
|
||||
$anon = true;
|
||||
case 'akismet':
|
||||
@ -699,7 +699,7 @@ var $filter_defaults;
|
||||
global $serendipity;
|
||||
|
||||
$dbversion = $this->get_config('dbversion', '1');
|
||||
|
||||
|
||||
if ($dbversion == '1') {
|
||||
$q = "CREATE TABLE {$serendipity['dbPrefix']}spamblocklog (
|
||||
timestamp int(10) {UNSIGNED} default null,
|
||||
@ -710,7 +710,7 @@ var $filter_defaults;
|
||||
email varchar(200),
|
||||
url varchar(200),
|
||||
useragent varchar(255),
|
||||
ip varchar(15),
|
||||
ip varchar(45),
|
||||
referer varchar(255),
|
||||
body text)";
|
||||
$sql = serendipity_db_schema_import($q);
|
||||
@ -732,7 +732,17 @@ var $filter_defaults;
|
||||
$q = "CREATE INDEX kshtaidx ON {$serendipity['dbPrefix']}spamblock_htaccess (timestamp);";
|
||||
$sql = serendipity_db_schema_import($q);
|
||||
|
||||
$this->set_config('dbversion', '2');
|
||||
$this->set_config('dbversion', '3');
|
||||
}
|
||||
|
||||
if ($dbversion == '2') {
|
||||
$q = "ALTER TABLE {$serendipity['dbPrefix']}spamblocklog CHANGE COLUMN ip ip VARCHAR(45)";
|
||||
$sql = serendipity_db_schema_import($q);
|
||||
|
||||
$q = "ALTER TABLE {$serendipity['dbPrefix']}spamblock_htaccess CHANGE COLUMN ip ip VARCHAR(45)";
|
||||
$sql = serendipity_db_schema_import($q);
|
||||
|
||||
$this->set_config('dbversion', '3');
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -828,7 +838,7 @@ var $filter_defaults;
|
||||
// Check if the entry is older than the allowed amount of time. Enforce kaptchas if that is true
|
||||
// of if kaptchas are activated for every entry
|
||||
$show_captcha = ($captchas && isset($eventData['timestamp']) && ($captchas_ttl < 1 || ($eventData['timestamp'] < (time() - ($captchas_ttl*60*60*24)))) ? true : false);
|
||||
|
||||
|
||||
// Plugins can override with custom captchas
|
||||
if (isset($serendipity['plugins']['disable_internal_captcha'])) {
|
||||
$show_captcha = false;
|
||||
@ -867,7 +877,7 @@ var $filter_defaults;
|
||||
$fp = fopen('/tmp/spamblock2.log', 'a');
|
||||
fwrite($fp, date('Y-m-d H:i') . "\n" . print_r($eventData, true) . "\n" . print_r($addData, true) . "\n");
|
||||
fclose($fp);
|
||||
*/
|
||||
*/
|
||||
|
||||
if (!is_array($eventData) || serendipity_db_bool($eventData['allow_comments'])) {
|
||||
$this->checkScheme();
|
||||
@ -923,7 +933,7 @@ var $filter_defaults;
|
||||
if (!is_array($auth)) {
|
||||
// Filter authors names, Filter URL, Filter Content, Filter Emails, Check for maximum number of links before rejecting
|
||||
// moderate false
|
||||
if(false === $this->wordfilter($logfile, $eventData, $wordmatch, $addData, true)) {
|
||||
if(false === $this->wordfilter($logfile, $eventData, $wordmatch, $addData, true)) {
|
||||
// already there #$this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_FILTER_WORDS, $addData);
|
||||
// already there #$eventData = array('allow_comments' => false);
|
||||
// already there #$serendipity['messagestack']['emails'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY;
|
||||
@ -933,7 +943,7 @@ var $filter_defaults;
|
||||
$eventData = array('allow_comments' => false);
|
||||
$serendipity['messagestack']['comments'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_KILLSWITCH;
|
||||
return false;
|
||||
} else {
|
||||
} else {
|
||||
$this->log($logfile, $eventData['id'], 'MODERATE', PLUGIN_EVENT_SPAMBLOCK_CHECKMAIL_VERIFICATION_MAIL, $addData);
|
||||
$eventData['moderate_comments'] = true;
|
||||
$eventData['status'] = 'confirm1';
|
||||
@ -987,7 +997,7 @@ var $filter_defaults;
|
||||
$found_exclude_url = false;
|
||||
foreach ($exclude_urls as $exclude_url) {
|
||||
$exclude_url = trim($exclude_url);
|
||||
if (empty($exclude_url)) continue;
|
||||
if (empty($exclude_url)) continue;
|
||||
$found_exclude_url = preg_match('@' . $exclude_url . '@',$addData['url']);
|
||||
if ($found_exclude_url) {
|
||||
break;
|
||||
@ -1078,7 +1088,7 @@ var $filter_defaults;
|
||||
}
|
||||
}
|
||||
|
||||
if(false === $this->wordfilter($logfile, $eventData, $wordmatch, $addData)) {
|
||||
if(false === $this->wordfilter($logfile, $eventData, $wordmatch, $addData)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1228,7 +1238,7 @@ var $filter_defaults;
|
||||
if (serendipity_db_bool($this->get_config('hide_email', false))) {
|
||||
echo '<div class="serendipity_commentDirection serendipity_comment_spamblock">' . PLUGIN_EVENT_SPAMBLOCK_HIDE_EMAIL_NOTICE . '</div>';
|
||||
}
|
||||
|
||||
|
||||
if ((string)$this->get_config('checkmail') === 'verify_always' || (string)$this->get_config('checkmail') === 'verify_once') {
|
||||
echo '<div class="serendipity_commentDirection serendipity_comment_spamblock">' . PLUGIN_EVENT_SPAMBLOCK_CHECKMAIL_VERIFICATION_INFO . '</div>';
|
||||
}
|
||||
@ -1435,7 +1445,7 @@ var $filter_defaults;
|
||||
/**
|
||||
* wordfilter, email and additional link check moved to this function, to allow comment user to opt-in (verify_once), but reject all truly spam comments before.
|
||||
**/
|
||||
function wordfilter($logfile, &$eventData, $wordmatch, $addData, $ftc = false) {
|
||||
function wordfilter($logfile, &$eventData, $wordmatch, $addData, $ftc = false) {
|
||||
global $serendipity;
|
||||
|
||||
// Check for word filtering
|
||||
@ -1541,7 +1551,7 @@ var $filter_defaults;
|
||||
}
|
||||
} // Content filtering end
|
||||
|
||||
if($ftc) {
|
||||
if($ftc) {
|
||||
// Check for maximum number of links before rejecting
|
||||
$link_count = substr_count(strtolower($addData['comment']), 'http://');
|
||||
$links_reject = $this->get_config('links_reject', 20);
|
||||
|
@ -1,3 +1,13 @@
|
||||
1.53:
|
||||
-----
|
||||
- fixed db table vistors, ip column to IPv6 length
|
||||
|
||||
|
||||
1.52:
|
||||
-----
|
||||
- fixed some missing ending strong tags - in 2.0 other markup changes
|
||||
|
||||
|
||||
1.51:
|
||||
-----
|
||||
- bumb event version for serendipity_plugin_statistics sync update to 1.5
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php # $Id$
|
||||
<?php #
|
||||
|
||||
@serendipity_plugin_api::load_language(dirname(__FILE__));
|
||||
|
||||
|
||||
class serendipity_event_statistics extends serendipity_event
|
||||
{
|
||||
var $title = PLUGIN_EVENT_STATISTICS_NAME;
|
||||
@ -14,7 +14,7 @@ class serendipity_event_statistics extends serendipity_event
|
||||
$propbag->add('description', PLUGIN_EVENT_STATISTICS_DESC);
|
||||
$propbag->add('stackable', false);
|
||||
$propbag->add('author', 'Arnan de Gans, Garvin Hicking, Fredrik Sandberg, kalkin');
|
||||
$propbag->add('version', '1.52');
|
||||
$propbag->add('version', '1.53');
|
||||
$propbag->add('requirements', array(
|
||||
'serendipity' => '0.8',
|
||||
'smarty' => '2.6.7',
|
||||
@ -39,11 +39,11 @@ class serendipity_event_statistics extends serendipity_event
|
||||
$propbag->add('description', PLUGIN_EVENT_STATISTICS_MAX_ITEMS_DESC);
|
||||
$propbag->add('default', 20);
|
||||
break;
|
||||
|
||||
|
||||
|
||||
|
||||
case 'ext_vis_stat':
|
||||
$select = array('no' => PLUGIN_EVENT_STATISTICS_EXT_OPT1,
|
||||
'yesBot' => PLUGIN_EVENT_STATISTICS_EXT_OPT2,
|
||||
$select = array('no' => PLUGIN_EVENT_STATISTICS_EXT_OPT1,
|
||||
'yesBot' => PLUGIN_EVENT_STATISTICS_EXT_OPT2,
|
||||
'yesTop' => PLUGIN_EVENT_STATISTICS_EXT_OPT3);
|
||||
|
||||
$propbag->add('type', 'select');
|
||||
@ -53,9 +53,9 @@ class serendipity_event_statistics extends serendipity_event
|
||||
$propbag->add('default', 'no');
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case 'stat_all':
|
||||
$select = array('no' => PLUGIN_EVENT_STATISTICS_EXT_ALL1,
|
||||
$select = array('no' => PLUGIN_EVENT_STATISTICS_EXT_ALL1,
|
||||
'yes' => PLUGIN_EVENT_STATISTICS_EXT_ALL2);
|
||||
|
||||
$propbag->add('type', 'select');
|
||||
@ -65,9 +65,9 @@ class serendipity_event_statistics extends serendipity_event
|
||||
$propbag->add('default', 'yes');
|
||||
|
||||
break;
|
||||
|
||||
case 'banned_bots':
|
||||
$select = array('yes' => PLUGIN_EVENT_STATISTICS_BANNED_HOSTS1,
|
||||
|
||||
case 'banned_bots':
|
||||
$select = array('yes' => PLUGIN_EVENT_STATISTICS_BANNED_HOSTS1,
|
||||
'no' => PLUGIN_EVENT_STATISTICS_BANNED_HOSTS2);
|
||||
|
||||
$propbag->add('type', 'select');
|
||||
@ -93,7 +93,7 @@ class serendipity_event_statistics extends serendipity_event
|
||||
|
||||
if (isset($hooks[$event])) {
|
||||
switch($event) {
|
||||
|
||||
|
||||
case 'frontend_configure':
|
||||
if ($this->get_config('ext_vis_stat') == 'no') {
|
||||
return;
|
||||
@ -108,13 +108,16 @@ class serendipity_event_statistics extends serendipity_event
|
||||
if ((int)$this->get_config('db_indices_created', '0') == 0) {
|
||||
$this->updateTables();
|
||||
}
|
||||
|
||||
if ((int)$this->get_config('db_indices_created', '1') == 1) {
|
||||
$this->updateTables(1);
|
||||
}
|
||||
|
||||
//Unique visitors are beeing registered and counted here. Calling function below.
|
||||
$sessionChecker = serendipity_db_query("SELECT count(sessID) FROM {$serendipity['dbPrefix']}visitors WHERE '".serendipity_db_escape_string(session_id())."' = sessID GROUP BY sessID", true);
|
||||
if (!is_array($sessionChecker) || (is_array($sessionChecker)) && ($sessionChecker[0] == 0)) {
|
||||
|
||||
|
||||
$referer = $useragent = $remoteaddr = 'unknown';
|
||||
|
||||
|
||||
// gathering intel
|
||||
if ($_SERVER['REMOTE_ADDR']) {
|
||||
$remoteaddr = $_SERVER['REMOTE_ADDR'];
|
||||
@ -125,9 +128,9 @@ class serendipity_event_statistics extends serendipity_event
|
||||
if ($_SERVER['HTTP_REFERER']) {
|
||||
$referer = substr($_SERVER['HTTP_REFERER'], 0, 255);
|
||||
}
|
||||
|
||||
|
||||
$found = 0;
|
||||
|
||||
|
||||
// avoiding banned browsers
|
||||
if ($this->get_config('banned_bots') == 'yes') {
|
||||
// excludelist botagents
|
||||
@ -181,23 +184,23 @@ class serendipity_event_statistics extends serendipity_event
|
||||
'48' => "Blogdimension",
|
||||
'49' => "Yahoo"
|
||||
);
|
||||
|
||||
|
||||
foreach($banned_array AS $ban) {
|
||||
if (stristr($useragent, $ban) !== false) {
|
||||
$found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($found == 0){
|
||||
if ($found == 0){
|
||||
$this->countVisitor($useragent, $remoteaddr, $referer);
|
||||
}
|
||||
} else {
|
||||
// Update visitor timestamp
|
||||
$this->updateVisitor();
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case 'backend_sidebar_entries':
|
||||
?>
|
||||
@ -213,12 +216,12 @@ class serendipity_event_statistics extends serendipity_event
|
||||
if (!$max_items || !is_numeric($max_items) || $max_items < 1) {
|
||||
$max_items = 20;
|
||||
}
|
||||
|
||||
|
||||
if ($ext_vis_stat == 'yesTop') {
|
||||
$this->extendedVisitorStatistics($max_items);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($this->get_config('stat_all') == 'yes') {
|
||||
$first_entry = serendipity_db_query("SELECT timestamp FROM {$serendipity['dbPrefix']}entries ORDER BY timestamp ASC limit 1", true);
|
||||
$last_entry = serendipity_db_query("SELECT timestamp FROM {$serendipity['dbPrefix']}entries ORDER BY timestamp DESC limit 1", true);
|
||||
@ -235,10 +238,10 @@ class serendipity_event_statistics extends serendipity_event
|
||||
GROUP BY ec.categoryid, c.category_name
|
||||
ORDER BY postings DESC";
|
||||
$category_rows = serendipity_db_query($cat_sql);
|
||||
|
||||
|
||||
$image_count = serendipity_db_query("SELECT count(id) FROM {$serendipity['dbPrefix']}images", true);
|
||||
$image_rows = serendipity_db_query("SELECT extension, count(id) AS images FROM {$serendipity['dbPrefix']}images GROUP BY extension ORDER BY images DESC");
|
||||
|
||||
|
||||
$subscriber_count = count(serendipity_db_query("SELECT count(id) FROM {$serendipity['dbPrefix']}comments WHERE type = 'NORMAL' AND subscribed = 'true' GROUP BY email"));
|
||||
$subscriber_rows = serendipity_db_query("SELECT e.timestamp, e.id, e.title, count(c.id) as postings
|
||||
FROM {$serendipity['dbPrefix']}comments c,
|
||||
@ -247,7 +250,7 @@ class serendipity_event_statistics extends serendipity_event
|
||||
GROUP BY e.id, c.email, e.title, e.timestamp
|
||||
ORDER BY postings DESC
|
||||
LIMIT $max_items");
|
||||
|
||||
|
||||
$comment_count = serendipity_db_query("SELECT count(id) FROM {$serendipity['dbPrefix']}comments WHERE type = 'NORMAL'", true);
|
||||
$comment_rows = serendipity_db_query("SELECT e.timestamp, e.id, e.title, count(c.id) as postings
|
||||
FROM {$serendipity['dbPrefix']}comments c,
|
||||
@ -256,14 +259,14 @@ class serendipity_event_statistics extends serendipity_event
|
||||
GROUP BY e.id, e.title, e.timestamp
|
||||
ORDER BY postings DESC
|
||||
LIMIT $max_items");
|
||||
|
||||
|
||||
$commentor_rows = serendipity_db_query("SELECT author, max(email) as email, max(url) as url, count(id) as postings
|
||||
FROM {$serendipity['dbPrefix']}comments c
|
||||
WHERE type = 'NORMAL'
|
||||
GROUP BY author
|
||||
ORDER BY postings DESC
|
||||
LIMIT $max_items");
|
||||
|
||||
|
||||
$tb_count = serendipity_db_query("SELECT count(id) FROM {$serendipity['dbPrefix']}comments WHERE type = 'TRACKBACK'", true);
|
||||
$tb_rows = serendipity_db_query("SELECT e.timestamp, e.id, e.title, count(c.id) as postings
|
||||
FROM {$serendipity['dbPrefix']}comments c,
|
||||
@ -272,14 +275,14 @@ class serendipity_event_statistics extends serendipity_event
|
||||
GROUP BY e.timestamp, e.id, e.title
|
||||
ORDER BY postings DESC
|
||||
LIMIT $max_items");
|
||||
|
||||
|
||||
$tbr_rows = serendipity_db_query("SELECT author, max(email) as email, max(url) as url, count(id) as postings
|
||||
FROM {$serendipity['dbPrefix']}comments c
|
||||
WHERE type = 'TRACKBACK'
|
||||
GROUP BY author
|
||||
ORDER BY postings DESC
|
||||
LIMIT $max_items");
|
||||
|
||||
|
||||
$length = serendipity_db_query("SELECT SUM(LENGTH(body) + LENGTH(extended)) FROM {$serendipity['dbPrefix']}entries", true);
|
||||
$length_rows = serendipity_db_query("SELECT id, title, (LENGTH(body) + LENGTH(extended)) as full_length FROM {$serendipity['dbPrefix']}entries ORDER BY full_length DESC LIMIT $max_items");
|
||||
?>
|
||||
@ -409,7 +412,7 @@ class serendipity_event_statistics extends serendipity_event
|
||||
if (substr($com_stat['url'], 0, 7) != 'http://' && substr($com_stat['url'], 0, 8) != 'https://') {
|
||||
$com_stat['url'] = 'http://' . $com_stat['url'];
|
||||
}
|
||||
|
||||
|
||||
$link_url = ' (<a href="' . htmlspecialchars($com_stat['url']) . '">' . PLUGIN_EVENT_STATISTICS_OUT_LINK . '</a>)';
|
||||
}
|
||||
|
||||
@ -557,14 +560,14 @@ class serendipity_event_statistics extends serendipity_event
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Statistics
|
||||
function updatestats($action) {
|
||||
global $serendipity;
|
||||
|
||||
list($year, $month, $day) = explode('-', date('Y-m-d'));
|
||||
|
||||
list($year, $month, $day) = explode('-', date('Y-m-d'));
|
||||
$sql = serendipity_db_query("SELECT COUNT(year) AS result FROM {$serendipity['dbPrefix']}visitors_count WHERE year='$year' AND month='$month' AND day='$day'", true);
|
||||
|
||||
|
||||
$sql_hit_update = "UPDATE {$serendipity['dbPrefix']}visitors_count SET hits = hits+1 WHERE year='$year' AND month='$month' AND day='$day'";
|
||||
$sql_day_new = "INSERT INTO {$serendipity['dbPrefix']}visitors_count (year, month, day, visits, hits) VALUES ('$year','$month','$day',1,1)";
|
||||
$sql_day_update = "UPDATE {$serendipity['dbPrefix']}visitors_count SET visits = visits+1, hits = hits+1 WHERE year='$year' AND month='$month' AND day='$day'";
|
||||
@ -585,12 +588,12 @@ class serendipity_event_statistics extends serendipity_event
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function updateVisitor() {
|
||||
global $serendipity;
|
||||
|
||||
$this->updatestats('update');
|
||||
|
||||
|
||||
$time = date('H:i');
|
||||
$day = date('Y-m-d');
|
||||
return serendipity_db_query("UPDATE {$serendipity['dbPrefix']}visitors SET time = '$time', day = '$day' WHERE sessID = '" . serendipity_db_escape_string(strip_tags(session_id())) . "'");
|
||||
@ -599,10 +602,10 @@ class serendipity_event_statistics extends serendipity_event
|
||||
function countVisitor($useragent, $remoteaddr, $referer){
|
||||
global $serendipity;
|
||||
$thedate = date('Y-m-d');
|
||||
$ip=strip_tags($remoteaddr);
|
||||
$ip=strip_tags($remoteaddr);
|
||||
$ip_how_often = serendipity_db_query("SELECT COUNT(ip) AS result FROM {$serendipity['dbPrefix']}visitors WHERE ip ='$ip' and day='$thedate'", true);
|
||||
|
||||
if($ip_how_often['result'] >=1){
|
||||
|
||||
if($ip_how_often['result'] >=1){
|
||||
$this->updatestats('update');
|
||||
} else {
|
||||
$this->updatestats('new');
|
||||
@ -615,29 +618,29 @@ class serendipity_event_statistics extends serendipity_event
|
||||
'browser'=> strip_tags($useragent),
|
||||
'ip' => strip_tags($remoteaddr)
|
||||
);
|
||||
|
||||
serendipity_db_insert('visitors', $values);
|
||||
|
||||
|
||||
serendipity_db_insert('visitors', $values);
|
||||
|
||||
// updating the referrer-table
|
||||
if (strlen($referer) >= 1) {
|
||||
|
||||
//retrieving the referrer base URL
|
||||
$temp_array = explode('?', $referer);
|
||||
$urlA = $temp_array[0];
|
||||
|
||||
$temp_array = explode('?', $referer);
|
||||
$urlA = $temp_array[0];
|
||||
|
||||
//removing "http://" & trailing subdirectories
|
||||
$temp_array3 = explode('//', $urlA);
|
||||
$urlB = $temp_array3[1];
|
||||
$temp_array4 = explode('/', $urlB);
|
||||
$urlB = $temp_array4[0];
|
||||
|
||||
|
||||
//removing www
|
||||
$urlC = serendipity_db_escape_string(str_replace('www.', '', $urlB));
|
||||
|
||||
|
||||
if(strlen($urlC) < 1) {
|
||||
$urlC = 'unknown';
|
||||
}
|
||||
|
||||
|
||||
//updating db
|
||||
$q = serendipity_db_query("SELECT count(refs) AS referrer FROM {$serendipity['dbPrefix']}refs WHERE refs = '$urlC' GROUP BY refs", true);
|
||||
if ($q['referrer'] >= 1){
|
||||
@ -646,13 +649,13 @@ class serendipity_event_statistics extends serendipity_event
|
||||
serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}refs (refs, count) VALUES ('$urlC', 1)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} //end of function countVisitor
|
||||
|
||||
|
||||
// Calculate daily stats
|
||||
function statistics_getdailystats() {
|
||||
global $serendipity;
|
||||
|
||||
|
||||
list($year, $month) = explode('-', date("Y-m"));
|
||||
$sql = "SELECT SUM(visits) AS dailyvisit FROM {$serendipity['dbPrefix']}visitors_count WHERE day";
|
||||
for ($i=1; $i<32; $i++) {
|
||||
@ -663,12 +666,12 @@ class serendipity_event_statistics extends serendipity_event
|
||||
}
|
||||
return $container;
|
||||
}
|
||||
|
||||
|
||||
// Calculate monthly stats
|
||||
function statistics_getmonthlystats() {
|
||||
function statistics_getmonthlystats() {
|
||||
global $serendipity;
|
||||
|
||||
$year = date("Y");
|
||||
$year = date("Y");
|
||||
$sql = "SELECT SUM(visits) AS monthlyvisit FROM {$serendipity['dbPrefix']}visitors_count WHERE month";
|
||||
for ($i=1; $i<13; $i++) {
|
||||
$myMonth = ($i < 10) ? "0" . $i : $i;
|
||||
@ -677,16 +680,16 @@ class serendipity_event_statistics extends serendipity_event
|
||||
$container[$i] = $res['monthlyvisit'];
|
||||
}
|
||||
return $container;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function extendedVisitorStatistics($max_items){
|
||||
|
||||
|
||||
global $serendipity;
|
||||
|
||||
|
||||
// ---------------QUERIES for Viewing statistics ----------------------------------------------
|
||||
$day = date('Y-m-d');
|
||||
list($year, $month, $day) = explode('-', $day);
|
||||
|
||||
list($year, $month, $day) = explode('-', $day);
|
||||
|
||||
$visitors_count_firstday = serendipity_db_query("SELECT day FROM {$serendipity['dbPrefix']}visitors ORDER BY counter_id ASC LIMIT 1", true);
|
||||
$visitors_count_today = serendipity_db_query("SELECT visits FROM {$serendipity['dbPrefix']}visitors_count WHERE year = '".$year."' AND month = '".$month."' AND day = '".$day."'", true);
|
||||
$visitors_count = serendipity_db_query("SELECT SUM(visits) FROM {$serendipity['dbPrefix']}visitors_count", true);
|
||||
@ -728,7 +731,7 @@ class serendipity_event_statistics extends serendipity_event
|
||||
}
|
||||
echo '</ol>';
|
||||
} else {
|
||||
echo "<span class='msg_notice'><span class='icon-info-circled'></span> ".PLUGIN_EVENT_STATISTICS_EXT_TOPREFS_NONE."</<span>";
|
||||
echo "<span class='msg_notice'><span class='icon-info-circled'></span> ".PLUGIN_EVENT_STATISTICS_EXT_TOPREFS_NONE."</span>";
|
||||
}
|
||||
?>
|
||||
</section>
|
||||
@ -736,7 +739,7 @@ class serendipity_event_statistics extends serendipity_event
|
||||
<section class="wide_box">
|
||||
<h3><?php echo PLUGIN_EVENT_STATISTICS_EXT_MONTHGRAPH;?></h3>
|
||||
|
||||
<?php if ($visitors_count[0] > 0) { ?>
|
||||
<?php if ($visitors_count[0] > 0) { ?>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
@ -878,10 +881,10 @@ class serendipity_event_statistics extends serendipity_event
|
||||
</div>
|
||||
<?php
|
||||
} //end of function extendedVisitorStatistics()
|
||||
|
||||
|
||||
function createTables() {
|
||||
global $serendipity;
|
||||
|
||||
|
||||
//create table xxxx_visitors
|
||||
$q = "CREATE TABLE {$serendipity['dbPrefix']}visitors (
|
||||
counter_id {AUTOINCREMENT} {PRIMARY},
|
||||
@ -890,7 +893,7 @@ class serendipity_event_statistics extends serendipity_event
|
||||
time varchar(5) not null default '',
|
||||
ref varchar(255) default null,
|
||||
browser varchar(255) default null,
|
||||
ip varchar(15) default null
|
||||
ip varchar(45) default null
|
||||
)";
|
||||
|
||||
serendipity_db_schema_import($q);
|
||||
@ -913,35 +916,44 @@ class serendipity_event_statistics extends serendipity_event
|
||||
count int(11) not null default '0'
|
||||
)";
|
||||
serendipity_db_schema_import($q);
|
||||
|
||||
|
||||
$this->updateTables();
|
||||
} //end of function createTables()
|
||||
|
||||
function updateTables() {
|
||||
function updateTables($dbic=0) {
|
||||
global $serendipity;
|
||||
|
||||
//create indices
|
||||
$q = "CREATE INDEX visitorses ON {$serendipity['dbPrefix']}visitors (sessID);";
|
||||
serendipity_db_schema_import($q);
|
||||
$q = "CREATE INDEX visitorday ON {$serendipity['dbPrefix']}visitors (day);";
|
||||
serendipity_db_schema_import($q);
|
||||
$q = "CREATE INDEX visitortime ON {$serendipity['dbPrefix']}visitors (time);";
|
||||
serendipity_db_schema_import($q);
|
||||
$q = "CREATE INDEX visitortimeb ON {$serendipity['dbPrefix']}visitors_count (year, month, day);";
|
||||
serendipity_db_schema_import($q);
|
||||
$q = "CREATE INDEX refsrefs ON {$serendipity['dbPrefix']}refs (refs);";
|
||||
serendipity_db_schema_import($q);
|
||||
$q = "CREATE INDEX refscount ON {$serendipity['dbPrefix']}refs (count);";
|
||||
serendipity_db_schema_import($q);
|
||||
if ($dbic == 0) {
|
||||
//create indices
|
||||
$q = "CREATE INDEX visitorses ON {$serendipity['dbPrefix']}visitors (sessID);";
|
||||
serendipity_db_schema_import($q);
|
||||
$q = "CREATE INDEX visitorday ON {$serendipity['dbPrefix']}visitors (day);";
|
||||
serendipity_db_schema_import($q);
|
||||
$q = "CREATE INDEX visitortime ON {$serendipity['dbPrefix']}visitors (time);";
|
||||
serendipity_db_schema_import($q);
|
||||
$q = "CREATE INDEX visitortimeb ON {$serendipity['dbPrefix']}visitors_count (year, month, day);";
|
||||
serendipity_db_schema_import($q);
|
||||
$q = "CREATE INDEX refsrefs ON {$serendipity['dbPrefix']}refs (refs);";
|
||||
serendipity_db_schema_import($q);
|
||||
$q = "CREATE INDEX refscount ON {$serendipity['dbPrefix']}refs (count);";
|
||||
serendipity_db_schema_import($q);
|
||||
|
||||
$this->set_config('db_indices_created', '1');
|
||||
$this->set_config('db_indices_created', '2');
|
||||
}
|
||||
|
||||
if ($dbic == 1) {
|
||||
$q = "ALTER TABLE {$serendipity['dbPrefix']}visitors CHANGE COLUMN ip ip VARCHAR(45)";
|
||||
serendipity_db_schema_import($q);
|
||||
|
||||
$this->set_config('db_indices_created', '2');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function dropTables() {
|
||||
|
||||
|
||||
global $serendipity;
|
||||
|
||||
|
||||
// Drop tables
|
||||
$q = "DROP TABLE ".$serendipity['dbPrefix']."visitors";
|
||||
$sql = serendipity_db_schema_import($q);
|
||||
@ -949,21 +961,21 @@ class serendipity_event_statistics extends serendipity_event
|
||||
$sql = serendipity_db_schema_import($q);
|
||||
$q = "DROP TABLE ".$serendipity['dbPrefix']."refs";
|
||||
$sql = serendipity_db_schema_import($q);
|
||||
|
||||
|
||||
} //end of function dropTables
|
||||
|
||||
|
||||
function install(){
|
||||
|
||||
|
||||
$this->createTables();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function uninstall(&$propbag){
|
||||
|
||||
|
||||
$this->dropTables();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php # $Id$
|
||||
<?php #
|
||||
|
||||
/* Contributed by Matthias Lange (http://blog.dinnri.de/ml/) */
|
||||
|
||||
@ -16,7 +16,7 @@ class serendipity_plugin_shoutbox extends serendipity_plugin
|
||||
$propbag->add('description', PLUGIN_SHOUTBOX_BLAHBLAH);
|
||||
$propbag->add('stackable', false);
|
||||
$propbag->add('author', 'Matthias Lange');
|
||||
$propbag->add('version', '1.01');
|
||||
$propbag->add('version', '1.02');
|
||||
$propbag->add('requirements', array(
|
||||
'serendipity' => '0.8',
|
||||
'smarty' => '2.6.7',
|
||||
@ -30,7 +30,7 @@ class serendipity_plugin_shoutbox extends serendipity_plugin
|
||||
'dateformat',
|
||||
'box_cols',
|
||||
'box_rows'));
|
||||
|
||||
|
||||
$propbag->add('groups', array('FRONTEND_FEATURES'));
|
||||
}
|
||||
|
||||
@ -98,15 +98,20 @@ class serendipity_plugin_shoutbox extends serendipity_plugin
|
||||
$box_rows = $this->get_config('box_rows');
|
||||
|
||||
// Create table, if not yet existant
|
||||
if ($this->get_config('version') != '1.0') {
|
||||
if (!$this->get_config('version')) {
|
||||
$q = "CREATE TABLE {$serendipity['dbPrefix']}shoutbox (
|
||||
id {AUTOINCREMENT} {PRIMARY},
|
||||
timestamp int(10) {UNSIGNED} NULL,
|
||||
ip varchar(15) default NULL,
|
||||
ip varchar(45) default NULL,
|
||||
body text
|
||||
)";
|
||||
$sql = serendipity_db_schema_import($q);
|
||||
$this->set_config('version', '1.0');
|
||||
$this->set_config('version', '2');
|
||||
}
|
||||
if ($this->get_config('version') == '1.0') {
|
||||
$q = "ALTER TABLE {$serendipity['dbPrefix']}shoutbox CHANGE COLUMN ip ip VARCHAR(45)";
|
||||
$sql = serendipity_db_schema_import($q);
|
||||
$this->set_config('version', '2');
|
||||
}
|
||||
|
||||
//Put new shout into the database if necessary
|
||||
|
Reference in New Issue
Block a user