1
0
Fork 0

some doc and cleanup stuff

Dieser Commit ist enthalten in:
oldperl 2011-12-17 15:26:24 +00:00
Ursprung e400b059d8
Commit b90587fef1
3 geänderte Dateien mit 271 neuen und 225 gelöschten Zeilen

Datei anzeigen

@ -10,189 +10,188 @@ Plugin URI: https://github.com/meglio/wp-upgrademe
if (!class_exists('Upgrademe')) {
class Upgrademe
{
/**
* Stores parsed and validated data returned by unofficial APIs.
* @var array
*/
private static $data;
class Upgrademe {
/**
* Stores parsed and validated data returned by unofficial APIs.
* @var array
*/
private static $data;
private static $WP_FILTER_PREFIX = 'wpFilter_';
private static $WP_FILTER_PREFIX = 'wpFilter_';
public static function register()
{
$r = new ReflectionClass(__CLASS__);
$methods = $r->getMethods(ReflectionMethod::IS_PUBLIC);
foreach($methods as $m)
{
/** @var ReflectionMethod $m */
if ($m->isStatic() && strpos($m->getName(), self::$WP_FILTER_PREFIX) === 0) {
add_filter(substr($m->getName(), strlen(self::$WP_FILTER_PREFIX)), array(get_class(), $m->getName()),
10, $m->getNumberOfParameters());
}
}
}
public static function register()
{
$r = new ReflectionClass(__CLASS__);
$methods = $r->getMethods(ReflectionMethod::IS_PUBLIC);
foreach($methods as $m)
{
/** @var ReflectionMethod $m */
if ($m->isStatic() && strpos($m->getName(), self::$WP_FILTER_PREFIX) === 0) {
add_filter(substr($m->getName(), strlen(self::$WP_FILTER_PREFIX)), array(get_class(), $m->getName()),
10, $m->getNumberOfParameters());
}
}
}
public static function wpFilter_http_response($response, $args, $url)
{
# Control recursion
static $recursion = false;
if ($recursion)
return $response;
public static function wpFilter_http_response($response, $args, $url)
{
# Control recursion
static $recursion = false;
if ($recursion)
return $response;
if (empty($response) || !is_array($response) || !isset($response['body']))
return $response;
if (empty($response) || !is_array($response) || !isset($response['body']))
return $response;
# Guess if it's time to take action
if ($url == 'http://api.wordpress.org/plugins/update-check/1.0/')
$showTime = true;
# Prevent failures if WordPress changes url for updates; we will detect if it still contains "update-check" token
# and called from withing wp_update_plugins() function
elseif (stripos($url, 'update-check') !== false)
{
$showTime = false;
$trace = debug_backtrace(false);
foreach($trace as $t)
# http request made from within wp_update_plugins
if (isset($t['function']) && $t['function'] == 'wp_update_plugins')
{
$showTime = true;
break;
}
unset($trace, $t);
}
else
$showTime = false;
if (!$showTime)
return $response;
# Guess if it's time to take action
if ($url == 'http://api.wordpress.org/plugins/update-check/1.0/')
$showTime = true;
# Prevent failures if WordPress changes url for updates; we will detect if it still contains "update-check" token
# and called from withing wp_update_plugins() function
elseif (stripos($url, 'update-check') !== false)
{
$showTime = false;
$trace = debug_backtrace(false);
foreach($trace as $t)
# http request made from within wp_update_plugins
if (isset($t['function']) && $t['function'] == 'wp_update_plugins')
{
$showTime = true;
break;
}
unset($trace, $t);
}
else
$showTime = false;
if (!$showTime)
return $response;
# Loop over plugins who provided <pluginName>_upgrademe() function and use returned url to request for up-to-date version signature.
# Collect retrieved (only valid) data into $upgrademe
$plugins = get_plugins();
$upgrademe = array();
foreach($plugins as $file => $info)
{
# Get url if function exists
$slugName = str_replace('-', '_', basename($file, '.php'));
# Loop over plugins who provided <pluginName>_upgrademe() function and use returned url to request for up-to-date version signature.
# Collect retrieved (only valid) data into $upgrademe
$plugins = get_plugins();
$upgrademe = array();
foreach($plugins as $file => $info)
{
# Get url if function exists
$slugName = str_replace('-', '_', basename($file, '.php'));
# Request latest version signature from custom url (non-WP plugins repository api) && validate response variables
$recursion = true;
$vars = self::loadPluginData($slugName);
$recursion = false;
if (empty($vars))
continue;
# Request latest version signature from custom url (non-WP plugins repository api) && validate response variables
$recursion = true;
$vars = self::loadPluginData($slugName);
$recursion = false;
if (empty($vars))
continue;
$upgrademe[$file] = $vars;
}
if (!count($upgrademe))
return $response;
$upgrademe[$file] = $vars;
}
if (!count($upgrademe))
return $response;
$body = $response['body'];
if (!empty($body))
$body = unserialize($body);
if (empty($body))
$body = array();
foreach($upgrademe as $file => $upgradeVars)
{
# Do not override data returned by official WP plugins repository API
if (isset($body[$file]))
continue;
$body = $response['body'];
if (!empty($body))
$body = unserialize($body);
if (empty($body))
$body = array();
foreach($upgrademe as $file => $upgradeVars)
{
# Do not override data returned by official WP plugins repository API
if (isset($body[$file]))
continue;
# If new version is different then current one, only then add info
if (!isset($plugins[$file]['Version']) || $plugins[$file]['Version'] == $upgradeVars['new_version'])
continue;
# If new version is different then current one, only then add info
if (!isset($plugins[$file]['Version']) || $plugins[$file]['Version'] == $upgradeVars['new_version'])
continue;
$upgradeInfo = new stdClass();
$upgradeInfo->id = $upgradeVars['id'];
$upgradeInfo->slug = $upgradeVars['slug'];
$upgradeInfo->new_version = $upgradeVars['new_version'];
$upgradeInfo->url = $upgradeVars['url'];
$upgradeInfo->package = $upgradeVars['package'];
$body[$file] = $upgradeInfo;
}
$response['body'] = serialize($body);
return $response;
}
$upgradeInfo = new stdClass();
$upgradeInfo->id = $upgradeVars['id'];
$upgradeInfo->slug = $upgradeVars['slug'];
$upgradeInfo->new_version = $upgradeVars['new_version'];
$upgradeInfo->url = $upgradeVars['url'];
$upgradeInfo->package = $upgradeVars['package'];
$body[$file] = $upgradeInfo;
}
$response['body'] = serialize($body);
return $response;
}
public static function wpFilter_plugins_api($value, $action, $args)
{
// If for some reason value available already, do not change it
if (!empty($value))
return $value;
public static function wpFilter_plugins_api($value, $action, $args)
{
// If for some reason value available already, do not change it
if (!empty($value))
return $value;
if ($action != 'plugin_information' || !is_object($args) || !isset($args->slug) || empty($args->slug))
return $value;
if ($action != 'plugin_information' || !is_object($args) || !isset($args->slug) || empty($args->slug))
return $value;
$vars = self::loadPluginData($args->slug);
if (empty($vars))
return $value;
$vars = self::loadPluginData($args->slug);
if (empty($vars))
return $value;
return (object)$vars['info'];
}
return (object)$vars['info'];
}
public static function wpFilter_http_request_args($args, $url)
{
if (strpos($url, 'wp-upgrademe') === false || !is_array($args))
return $args;
public static function wpFilter_http_request_args($args, $url)
{
if (strpos($url, 'wp-upgrademe') === false || !is_array($args))
return $args;
$args['sslverify'] = false;
return $args;
}
$args['sslverify'] = false;
return $args;
}
private static function loadPluginData($slug)
{
if (isset(self::$data[$slug]))
return self::$data[$slug];
private static function loadPluginData($slug)
{
if (isset(self::$data[$slug]))
return self::$data[$slug];
$funcName = $slug.'_upgrademe';
if (!function_exists($funcName))
return self::$data[$slug] = null;
$funcName = $slug.'_upgrademe';
if (!function_exists($funcName))
return self::$data[$slug] = null;
$upgradeUrl = filter_var(call_user_func($funcName), FILTER_VALIDATE_URL);
if (empty($upgradeUrl))
return self::$data[$slug] = null;
$upgradeUrl = filter_var(call_user_func($funcName), FILTER_VALIDATE_URL);
if (empty($upgradeUrl))
return self::$data[$slug] = null;
# Request latest version signature from custom url (non-WP plugins repository api) && validate response variables
$r = wp_remote_post($upgradeUrl, array('method' => 'POST', 'timeout' => 4, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => true,
'headers' => array(), 'body' => null, 'cookies' => array(), 'sslverify' => false));
# Request latest version signature from custom url (non-WP plugins repository api) && validate response variables
$r = wp_remote_post($upgradeUrl, array('method' => 'POST', 'timeout' => 4, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => true,
'headers' => array(), 'body' => null, 'cookies' => array(), 'sslverify' => false));
if( is_wp_error($r) || !isset($r['body']) || empty($r['body']))
return self::$data[$slug] = null;
if( is_wp_error($r) || !isset($r['body']) || empty($r['body']))
return self::$data[$slug] = null;
$vars = json_decode($r['body'], true);
if (empty($vars) || !is_array($vars) || count($vars) > 4
|| !isset($vars['new_version']) || !isset($vars['url']) || !isset($vars['package']) || !isset($vars['info']))
return self::$data[$slug] = null;
$vars = json_decode($r['body'], true);
if (empty($vars) || !is_array($vars) || count($vars) > 4
|| !isset($vars['new_version']) || !isset($vars['url']) || !isset($vars['package']) || !isset($vars['info']))
return self::$data[$slug] = null;
# 2 147 483 648 - max int32
# 16 777 215 - ffffff = max possible value of 6-letters hex
# 50 000 000 - reasonable offset
# Finally generate ID between 50 000 000 and 66 777 215
$vars['id'] = 50000000 + hexdec(substr(md5($slug), 1, 6));
# 2 147 483 648 - max int32
# 16 777 215 - ffffff = max possible value of 6-letters hex
# 50 000 000 - reasonable offset
# Finally generate ID between 50 000 000 and 66 777 215
$vars['id'] = 50000000 + hexdec(substr(md5($slug), 1, 6));
$vars['slug'] = $slug;
$vars['slug'] = $slug;
# Sanitize variables of "info"
if (!is_array($vars['info']))
$vars['info'] = array();
# Sanitize variables of "info"
if (!is_array($vars['info']))
$vars['info'] = array();
$info = array();
foreach($vars['info'] as $key => $val)
{
if (!in_array($key, array('name','slug','version','author','author_profile','contributors','requires','tested',
'compatibility','rating','rating','num_ratings','downloaded','last_updated','added','homepage',
'sections','download_link','tags')))
continue;
$info[$key] = $val;
}
$info['slug'] = $slug;
$info['version'] = $vars['new_version'];
$info['download_link'] = $vars['url'];
$vars['info'] = $info;
$info = array();
foreach($vars['info'] as $key => $val)
{
if (!in_array($key, array('name','slug','version','author','author_profile','contributors','requires','tested',
'compatibility','rating','rating','num_ratings','downloaded','last_updated','added','homepage',
'sections','download_link','tags')))
continue;
$info[$key] = $val;
}
$info['slug'] = $slug;
$info['version'] = $vars['new_version'];
$info['download_link'] = $vars['url'];
$vars['info'] = $info;
return self::$data[$slug] = $vars;
}
return self::$data[$slug] = $vars;
}
}
Upgrademe::register();
} # class_exists()

Datei anzeigen

@ -4,7 +4,7 @@
*
* @package SemmelstatzR
* @version $Rev$
* @since 1.0.0 Beta
* @since 1.0.0
* @author SEM-Team
* @copyright (c)2011 SEM-Team
* @link http://sourceforge.net/projects/semmelstatz/
@ -69,7 +69,7 @@
}
}
### Auslesen der höchsten Post-ID
### Auslesen der h<EFBFBD>chsten Post-ID
function sem_getMaxPostID() {
global $wpdb;
$maxpostid = $wpdb->get_var("SELECT MAX(ID) FROM ".$wpdb->posts." LIMIT 0,1");
@ -117,7 +117,12 @@ function sem_AreYouBot($user_agent) {
return $oCheckAgent->isBot();
}
### Referer nach Suchmaschinen-Queries und interner Suche prüfen und Suchstring extrahieren
/**
* Referer nach Suchmaschinen-Queries und interner Suche prüfen und Suchstring extrahieren
*
* @param string $referer
* @return string name of searchengine and keywords
*/
function sem_getKeyword($referer) {
if(empty($referer)) return false;
$homehost = '%'.(substr($_SERVER['SERVER_NAME'],0,4) == 'www.')?
@ -221,14 +226,14 @@ function sem_getKeyword($referer) {
elseif (preg_match("/".$homehost."/i", $keyword["host"])) {
parse_str($keyword["query"],$q);
$keyword = $q["s"];
if($keyword == "") return; return "Interne Suche: ".$keyword;
if($keyword == "") return; return semr_i18n("Internal search: ").$keyword;
}
else {
return;
}
}
### Anzahl der Datensätze in der statz-Tabelle
### Anzahl der Datens<EFBFBD>tze in der statz-Tabelle
function sem_showNumStatzEntries() {
global $wpdb;
$numstatzentries = $wpdb->get_var("SELECT COUNT(id) FROM ".$wpdb->statz);
@ -259,27 +264,41 @@ function sem_getKeyword($referer) {
}
}
### Zeigt Copyright-Notiz an
function sem_showCopyright() {
print "<p class='copyright'>semmelstatzR ". SEMMELSTATZR_VERSION . " happily coded by <a target='_blank' href='http://semmelstatz.sourceforge.net/'>SEM-Team<br />
<a target='_blank' style='border:none;' href='http://sourceforge.net/projects/semmelstatz/'>
<img src='".get_option('siteurl')."/wp-content/plugins/semmelstatzR/img/statzR.png' /></a></p>";
}
### statz-Tabelle leeren (NICHT LÖSCHEN!!!)
function sem_truncateStatzTable() {
global $wpdb, $userip;
$wpdb->query('TRUNCATE TABLE '.$wpdb->statz);
sem_optStatzTable();
return $wpdb->query("INSERT INTO `$wpdb->statz`(ip, time, referer, page, username) VALUES('127.0.0.1', NOW(),NULL,0,'statz-Tabelle geleert')");
/**
* prints a copyright notiz
*/
function sem_showCopyright() {
print "<p class='copyright'>semmelstatzR ". SEMMELSTATZR_VERSION .
" happily coded by <a target='_blank' href='http://semmelstatz.sourceforge.net/'>SEM-Team<br />
<a target='_blank' style='border:none;' href='http://sourceforge.net/projects/semmelstatz/'>
<img src='".get_option('siteurl')."/wp-content/plugins/semmelstatzR/img/statzR.png' /></a></p>";
}
### Obsolet, bleibt aber aus Kompatibilitätsgründen zu SEMMELSTATZ_DELETE
function sem_delOldRecords($days) {
return true;
}
/**
* empty statz table
*
* @global type $wpdb
* @return bool
*/
function sem_truncateStatzTable() {
global $wpdb;
$wpdb->query('TRUNCATE TABLE '.$wpdb->statz);
sem_optStatzTable();
return ($wpdb->query("INSERT INTO `$wpdb->statz`(ip, time, referer, page, username) VALUES('127.0.0.1', NOW(),NULL,0,'statz-Tabelle geleert')"))?true:false;
}
### simpleEncoding für die GoogleChartAPI
/**
*
* @deprecated no need to hold unused functions in semR
* @todo remove in next major release
* @param int $days
* @return boolean
*/
function sem_delOldRecords($days) {
return true;
}
### simpleEncoding f<>r die GoogleChartAPI
function sem_encodeChartData($values) {
$maxValue = max($values);
@ -298,7 +317,7 @@ function sem_truncateStatzTable() {
return $chartData;
}
### Datensätze älter als statz_recdays_limit-Tage löschen
### Datens<EFBFBD>tze <20>lter als statz_recdays_limit-Tage l<>schen
function sem_delOutOfLimit() {
global $wpdb;
$sem_options = get_option('semmelstatzR_options'); ### optionsarray auslesen
@ -309,7 +328,7 @@ function sem_truncateStatzTable() {
sem_optStatzTable();
}
### Wenn AUTOMATISCHES LIMIT aktiviert, dann LIMITIERE und erhöhe NEXT_CRON
### Wenn AUTOMATISCHES LIMIT aktiviert, dann LIMITIERE und erh<EFBFBD>he NEXT_CRON
function sem_doCronStatzLimit() {
sem_delOutOfLimit();
$sem_options = get_option('semmelstatzR_options'); ### optionsarray auslesen
@ -330,32 +349,36 @@ function sem_truncateStatzTable() {
}
### Unter bestimmten Voraussetzungen den Vortag in die statzhist-Tabelle schreiben
function sem_writeYesterdayToHist() {
global $wpdb;
if(!$wpdb->get_var("SELECT date FROM ".$wpdb->statzhist." WHERE substring(date,1,10) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)")) {
/**
* @todo add action cache so we don't need to do it with every call
* @global type $wpdb
*/
function sem_writeYesterdayToHist() {
global $wpdb;
if(!$wpdb->get_var("SELECT date FROM ".$wpdb->statzhist." WHERE substring(date,1,10) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)")) {
if($wpdb->get_var("SELECT COUNT(ip) FROM ".$wpdb->statz." WHERE substring(time,1,10) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)")) {
if($wpdb->get_var("SELECT COUNT(ip) FROM ".$wpdb->statz." WHERE substring(time,1,10) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)")) {
$yesterdays = $wpdb->get_results("SELECT COUNT(ip) AS hits, COUNT(DISTINCT ip) AS visitors, COUNT(DISTINCT referer)
AS referers, substring(time,1,10) AS date FROM ".$wpdb->statz." WHERE substring(time,1,10) = DATE_SUB(CURDATE(),
INTERVAL 1 DAY) GROUP BY date");
$yesterdays = $wpdb->get_results("SELECT COUNT(ip) AS hits, COUNT(DISTINCT ip) AS visitors, COUNT(DISTINCT referer)
AS referers, substring(time,1,10) AS date FROM ".$wpdb->statz." WHERE substring(time,1,10) = DATE_SUB(CURDATE(),
INTERVAL 1 DAY) GROUP BY date");
foreach ($yesterdays as $yesterday) {
$date = $yesterday->date;
$visitors = $yesterday->visitors;
$hits = $yesterday->hits;
$referers = $yesterday->referers;
}
$sql = $wpdb->query("INSERT INTO ".$wpdb->statzhist." (date, referers, visitors, hits)
VALUES('$date', $referers, $visitors, $hits)");
}
else {
$date = $wpdb->get_var("SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY)");
$sql = $wpdb->query("INSERT INTO ".$wpdb->statzhist." (date, referers, visitors, hits) VALUES('$date', 0, 0, 0)");
foreach ($yesterdays as $yesterday) {
$date = $yesterday->date;
$visitors = $yesterday->visitors;
$hits = $yesterday->hits;
$referers = $yesterday->referers;
}
$sql = $wpdb->query("INSERT INTO ".$wpdb->statzhist." (date, referers, visitors, hits)
VALUES('$date', $referers, $visitors, $hits)");
}
else {
$date = $wpdb->get_var("SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY)");
$sql = $wpdb->query("INSERT INTO ".$wpdb->statzhist." (date, referers, visitors, hits) VALUES('$date', 0, 0, 0)");
}
}
}
/* Summen der vergangenen Tage in die statzhist schreiben */
function sem_writeOldDaysToHist() {
@ -378,8 +401,11 @@ function sem_truncateStatzTable() {
}
/**
* translate and return a string
* translate and return a string
*
* @uses wp-function __() and prefilled plugin gettextdomain
* @author Ortwin Pinke
* @since 1.0.0
*
* @param string $sValue string to translate
* @param string $sDomain gettextdomain
@ -391,7 +417,10 @@ function semr_i18n($sValue, $sDomain = "semmelstatzR") {
/**
* translate and echo a string
*
* @uses wp-function _e() and prefilled plugin gettextdomain
* @author Ortwin Pinke
* @since 1.0.0
*
* @param string $sValue
* @param string $sDomain
@ -403,7 +432,10 @@ function semr_i18ne($sValue, $sDomain = "semmelstatzR") {
/**
* translate and return a plural or singular string based on an amount
*
* @uses wp-function _n() and prefilled plugin gettextdomain
* @author Ortwin Pinke
* @since 1.0.0
*
* @param string $sSingular
* @param string $sPlural
@ -418,8 +450,9 @@ function semr_i18np($sSingular, $sPlural, $iNumber, $sDomain = "semmelstatzR") {
/**
*
* @author anyexample.com
* @license http://www.anyexample.com/license/
* @license modified MIT see http://www.anyexample.com/license/
* @link http://www.anyexample.com/programming/php/php_convert_rgb_from_to_html_hex_color.xml
* @since 1.0.0
*
* @param string $color
* @return array
@ -445,8 +478,9 @@ function semr_hex2rgb($color) {
/**
*
* @author anyexample.com
* @license http://www.anyexample.com/license/
* @license modified MIT see http://www.anyexample.com/license/
* @link http://www.anyexample.com/programming/php/php_convert_rgb_from_to_html_hex_color.xml
* @since 1.0.0
*
* @param int $r
* @param int $g

Datei anzeigen

@ -3,7 +3,7 @@
Plugin Name: semmelstatzR
Plugin URI: http://sourceforge.net/projects/semmelstatz/
Description: Visitorstatistic for Wordpress, based upon the original wp-plugin semmelstatz by Andreas 'Redunzl' Mueller (http://www.kopfhoch-studio.de)
Version: 1.0.0 Beta
Version: 1.0 RC
Author: SEM-Team
Author URI: http://semmelstatz.sf.net
License: GPLv3
@ -16,7 +16,7 @@ License URI: http://www.gnu.org/licenses/gpl-3.0.html
* @version $Rev$
* @since 1.0.0 Beta
* @author SEM-Team
* @copyright (c)2011 SEM-Team
* @copyright (c)2011-2012 SEM-Team
* @link http://sourceforge.net/projects/semmelstatz/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*
@ -128,7 +128,7 @@ if(is_admin() == true) {
global $wpdb;
if(get_option('statz_options')) {
$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE 'statz%';"); // Löschen der alten Optionen
$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE 'statz%';"); // L<EFBFBD>schen der alten Optionen
}
if(!get_option('semmelstatzR_options')) {
@ -156,7 +156,7 @@ if(is_admin() == true) {
"statz_topreads_limit" => 10,
"statz_write_admins" => false,
"statz_write_users" => false,
"statz_use_img" => true
"statz_use_img" => false
);
add_option( 'semmelstatzR_options', $sem_options );
}
@ -175,7 +175,7 @@ function sem_statzsetup() {
} elseif(@is_file(ABSPATH.'/wp-admin/includes/upgrade.php')) {
include_once(ABSPATH.'/wp-admin/includes/upgrade.php');
} else {
die('Kann <i>wp-admin/upgrade-functions.php</i> und <i>wp-admin/includes/upgrade.php</i> nicht finden!');
die(semr_i18n('Cannot find <i>wp-admin/upgrade-functions.php</i> and <i>wp-admin/includes/upgrade.php</i>!'));
}
$create_table = array();
@ -228,9 +228,9 @@ function sem_writeStatz() {
// true === $sem_options['statz_use_img'] &&
if(true == $sem_options['statz_use_img'] && !defined('SEMMELSTATZR_STATZIMG')) {
print '<img src="'.SEMMELSTATZR_HTML_RELPATH.'semr_image.php" alt="" />';
return; ### nothing todo if stat image is used
return; ### nothing else todo if stat image is used
}
sem_writeYesterdayToHist();
$useragent = $wpdb->escape($_SERVER['HTTP_USER_AGENT']);
$isBot = sem_AreYouBot($useragent);
@ -244,17 +244,16 @@ function sem_writeStatz() {
$userip = $wpdb->escape($_SERVER['REMOTE_ADDR']);
if($sem_options['statz_encode_ip'] == true) $userip = sem_encodeIP($userip);
$referer = $wpdb->escape(urldecode($_SERVER['HTTP_REFERER']));
$referer = $wpdb->escape(urldecode($_SERVER['HTTP_REFERER']));
$blogtime = gmdate('Y-m-d H:i:s', current_time('timestamp'));
if (!empty($referer)) {
if(get_option('blog_charset') == 'iso-8859-1') $referer = utf8_decode($referer);
$referer = "'".$referer."'";
$referer = "'".$referer."'";
} else {
$referer = 'NULL';
}
else {
$referer = 'NULL';
}
$readingnow = wp_title('', false);
if(empty($readingnow)) {
@ -262,9 +261,9 @@ $referer = 'NULL';
} else {
$page = $wp_query->post->ID;
}
$wpdb->query("INSERT INTO $wpdb->statz (ip, time, referer, page, username)
VALUES('$userip', '$blogtime', $referer, $page, '$username')");
$wpdb->query("INSERT INTO $wpdb->statz (ip, time, referer, page, username)
VALUES('$userip', '$blogtime', $referer, $page, '$username')");
if($wpdb->query("SELECT COUNT(hits) FROM $wpdb->posts")) {
$wpdb->query("UPDATE $wpdb->posts SET hits = hits + 1 WHERE ID = $page"); // neu ab 3.2
@ -272,13 +271,19 @@ $wpdb->query("INSERT INTO $wpdb->statz (ip, time, referer, page, username)
}
### Zeitgesteuertes Limitieren der statz-Tabelle
// Wenn semmelKron JA UND statz_next_cron älter JETZT, dann...
$sem_options = get_option('semmelstatzR_options'); ### optionsarray auslesen
if($sem_options['statz_do_cron'] == true && $sem_options['statz_next_cron'] < time()) {
add_action('shutdown', 'sem_doCronStatzLimit'); // ...limitiere statz-Tabelle auf vorgegebenen Wert
}
// @todo add action cache
// Wenn semmelKron JA UND statz_next_cron älter JETZT, dann...
$sem_options = get_option('semmelstatzR_options'); ### optionsarray auslesen
if($sem_options['statz_do_cron'] == true && $sem_options['statz_next_cron'] < time()) {
add_action('shutdown', 'sem_doCronStatzLimit'); // ...limitiere statz-Tabelle auf vorgegebenen Wert
}
### Rendert eine Mini-STATZ. Idee: René Tauchnitz
/**
* renders a ministatz for dashboard
* Idee: René Tauchnitz
*
* @return void
*/
function sem_dashboardStatz_show() {
$widget_options = get_option( 'dashboard_widget_options' );
@ -299,6 +304,14 @@ function sem_dashboardStatz_show() {
echo '</p>';
}
/**
* dashboard-control for ministatz
*
* @author Ortwin Pinke
* @since semR 1.0
*
* @return void
*/
function sem_dashboardStatz_control() {
if (!$widget_options = get_option('dashboard_widget_options'))
$widget_options = array();