diff --git a/README.md b/README.md index 0a421ab..fd6fd1d 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,8 @@ Contributors: michelem, helened Donate link: [donate](https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=michele%40befree%2eit&item_name=WassUp&no_shipping=0&no_note=1&tax=0¤cy_code=EUR&lc=IT&bn=PP%2dDonationsBF&charset=UTF%2d8) Tags: analytics, counter, online, seo, statistics, stats, tracker, traffic, trends, user, visitor, web Requires at least: WordPress 2.2 -Tested up to: 4.8 -Stable tag: 1.9.4.2 +Tested up to: 4.8 +Stable tag: 1.9.4.3 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -154,14 +154,21 @@ When you activate this plugin (as described in "Installation"), it works "as is" * WassUp is incompatible with the following static page caching plugins: WP Super Cache, WP Cache, WP Fastest Cache, and WP Hyper Cache. ## Upgrade Notice -### 1.9.4.2: Security bugfix -* Important security bugfix. +### 1.9.4.3 +* Important PHP7 compatibility upgrade. * DO NOT UPGRADE when your site busy! * Read [installation instructions](http://wordpress.org/plugins/wassup/installation/) for safe upgrade instructions. ## Changelog -### 1.9.4.1 -* Important feature & bugfix upgrade. +### v1.9.4.3 +* merged PHP7 compatibility update (from v1.9.4.1) into master +* minor text changes + +### v1.9.4.2 +* Important security bugfix. Thanks to Dimopoulos Elias for finding this bug. + +### v1.9.4.1 +* updated classes for PHP7-compatible class constructors (not released) ### v1.9.4: Important feature & bugfix upgrade * new option to whitelist referrers that are mislabeled as spam in WassUp (ex: Rx or sexy words in domain name) @@ -177,7 +184,7 @@ When you activate this plugin (as described in "Installation"), it works "as is" * fixed a bug in "stringShortener" function that caused empty results * fixed a bug in Top Stats widget that caused blank lines to display * fixed some Top Stats widget translations -* removed Google!maps API key from Wassup source due to Google TOS limitations +* removed Google!maps API key from Wassup source due to Google's TOS limitations * miscellaneous minor bugfixes ### v1.9.3.1: Important bugfix upgrade @@ -303,4 +310,3 @@ When you activate this plugin (as described in "Installation"), it works "as is" * [Jquery](http://www.jquery.com) for the amazing Ajax framework * [FAMFAMFAM](http://www.famfamfam.com/) for the flags icons * Thanks to [@AlexandreFiori](http://twitter.com/alexandrefiori) for access to his GeoIP API at [freegeoip.net](http://freegeoip.net) -* A big thanks to [Helene D.](http://helenesit.com/) for her help to improve WassUp! diff --git a/lib/akismet.class.php b/lib/akismet.class.php index d4b817e..a0415a7 100644 --- a/lib/akismet.class.php +++ b/lib/akismet.class.php @@ -88,12 +88,16 @@ class wassup_AkismetHttpClient extends wassup_AkismetObject { var $errors=array(); /** Constructor */ - function wassup_AkismetHttpClient($host,$blogUrl,$apiKey,$port=80){ + function __construct($host,$blogUrl,$apiKey,$port=80){ $this->host=$host; $this->port=$port; $this->blogUrl=$blogUrl; $this->apiKey=$apiKey; } + /** PHP4 constructor for backward compatibility */ + function wassup_AkismetHttpClient($host,$blogUrl,$apiKey,$port=80){ + $this->__construct($host,$blogUrl,$apiKey,$port); + } /** Use the connection active in $con to get a response from the server and return that response */ function getResponse($request,$path,$type="post",$responseLength=1160){ $this->_connect(); @@ -173,7 +177,7 @@ class wassup_Akismet extends wassup_AkismetObject { * @param String[] $comment - A formatted comment array to be examined by the Akismet service * @return Akismet */ - function wassup_Akismet($blogUrl,$apiKey,$comment=array()) { + function __construct($blogUrl,$apiKey,$comment=array()) { $this->blogUrl=$blogUrl; $this->apiKey =$apiKey; $this->setComment($comment); @@ -187,6 +191,10 @@ function wassup_Akismet($blogUrl,$apiKey,$comment=array()) { $this->setError(WASSUP_AKISMET_INVALID_KEY,__("Your Akismet API key is not valid.","wassup")); } } + /** PHP4 constructor for backward compatibility */ + function wassup_Akismet($blogUrl,$apiKey,$comment=array()) { + $this->__construct($blogUrl,$apiKey,$comment); + } /** Query Akismet server to check if comment is spam or not */ function isSpam() { $response=$this->http->getResponse($this->_getQueryString(), 'comment-check'); diff --git a/lib/compat-lib/compat_wassup.class.php b/lib/compat-lib/compat_wassup.class.php index 8abbe25..e1735e4 100644 --- a/lib/compat-lib/compat_wassup.class.php +++ b/lib/compat-lib/compat_wassup.class.php @@ -65,7 +65,7 @@ class wassupOptions { var $wassup_refspam = "1"; var $wassup_attack = "1"; var $wassup_hack = "1"; - var $refspam_whitelist=""; //new in v1.9.4: for incorrectly labeled referrer spam + var $refspam_whitelist=""; //for incorrectly labeled referrer spam @since v1.9.4 /* table/file management settings */ var $wassup_table; @@ -94,17 +94,18 @@ class wassupOptions { var $wassup_upgraded = 0; //upgrade timestamp @since v1.9 /** - * PHP4 constructor. - * + * constructor. * optional argument to set default values for new/empty class vars @since v1.9 * @param boolean $add_defaults - * @return void - * */ - function wassupoptions($add_defaults=false){ + function __construct($add_defaults=false){ if($add_defaults)$this->_initSettings(); else $this->loadSettings(); } + /** PHP4 constructor. */ + function wassupoptions($add_defaults=false){ + $this->__construct($add_defaults); + } /** loads current settings/initializes empty class vars. */ function _initSettings(){ $settings=$this->getSettings(true); @@ -641,7 +642,7 @@ function cleanFormText($input){ else $text=strip_tags(html_entity_decode(wp_kses($input,array()))); //only alphanumeric chars allowed with few exceptions //since v1.9.3 allow '@' char for email searches - //v1.9.4 bugfix: allow '/?&=' chars for url searches + //since v1.9.4 allow '/?&=' chars for url searches $cleantext=preg_replace('#([^0-9a-z\-_\.,\:\*\#/&\?=@\'" ]+)#i','',$text); return $cleantext; } @@ -2083,11 +2084,11 @@ function export_records($table,$start_id,$wherecondition,$dtype="sql"){ if(empty($result[0][1]) || is_wp_error($result)){ $err_msg=sprintf(__('Error with "SHOW CREATE TABLE" for %s.','wassup'), esc_attr($table)); wassup_log_message($err_msg); - break; + } else { + $table_create=$result[0][1]; + $sql_header="#\n# " . sprintf(__('Table structure of table %s','wassup'),esc_attr($table))."\n#\n"; + $sql_header .= preg_replace(array('/^CREATE\sTABLE\s(IF\sNOT\sEXISTS\s)?/i', '/AUTO_INCREMENT\=\d+\s/i'),array('CREATE TABLE IF NOT EXISTS ',''),$table_create).' ;'; } - $table_create=$result[0][1]; - $sql_header="#\n# " . sprintf(__('Table structure of table %s','wassup'),esc_attr($table))."\n#\n"; - $sql_header .= preg_replace(array('/^CREATE\sTABLE\s(IF\sNOT\sEXISTS\s)?/i', '/AUTO_INCREMENT\=\d+\s/i'),array('CREATE TABLE IF NOT EXISTS ',''),$table_create).' ;'; $sql_header .= "\n#\n# ".sprintf(__('Data contents of table %s','wassup'),esc_attr($table))."\n#\n"; } //set starting rec id of export query @@ -2162,7 +2163,7 @@ function export_records($table,$start_id,$wherecondition,$dtype="sql"){ //write sql header fwrite($output,$sql_header); $i=0; - //field list for sql-insert + //make a field list for sql-insert statement in output below $sql_fields="INSERT INTO `".esc_attr($table).'` ('; foreach($fields AS $col){ if(empty($wassup_options->export_omit_recid) || $col != 'id'){ @@ -2535,7 +2536,7 @@ function get_menu_arg(){ if(isset($_GET['page'])) $menuarg=$_GET['page']; if(stristr($menuarg,"wassup")!==false){ if(isset($_GET['ml'])){ - $menuarg=$_GET['ml']; + $menuarg=htmlspecialchars($_GET['ml']); //security fix @since v1.9.4.2 - thanks to Dimopoulos Elias for finding this bug }else{ $wassupfolder=basename(WASSUPDIR); if($menuarg=="wassup-stats"){ diff --git a/lib/compat-lib/compat_widget.php b/lib/compat-lib/compat_widget.php index 09b3c25..5c285c2 100644 --- a/lib/compat-lib/compat_widget.php +++ b/lib/compat-lib/compat_widget.php @@ -1,6 +1,7 @@ =')){ +if(version_compare($GLOBALS['wp_version'],'2.8','>=') && version_compare($php_vers,'5.2','>=')){ return; } -if(!class_exists('Wassup_Widget')){ +if(version_compare($GLOBALS['wp_version'],'2.8','<')){ /** * Base class for building Wassup aside widgets for Wordpress 2.2 - 2.7 * - based on 'WP_Widget' class in Wordpress 2.8 @@ -55,8 +57,8 @@ class Wassup_Widget{ var $id; var $updated = false; var $number = false; - /** PHP4 constructor */ - function wassup_widget($id_base="wassup_widget",$name="Wassup Widget",$widget_opts=array(),$control_opts=array()){ + /** constructor */ + function __construct($id_base="wassup_widget",$name="Wassup Widget",$widget_opts=array(),$control_opts=array()){ if(empty($id_base)) $this->id_base=preg_replace( '/(Widget$)/','',strtolower(get_class($this))); else $this->id_base=strtolower($id_base); $this->name=$name; @@ -85,6 +87,10 @@ function wassup_widget($id_base="wassup_widget",$name="Wassup Widget",$widget_op $this->number=1; $this->wassup_add_css(); } + /** PHP4 constructor */ + function wassup_widget($id_base="wassup_widget",$name="Wassup Widget",$widget_opts=array(),$control_opts=array()){ + $this->__construct($id_base,$name,$widget_opts,$control_opts); + } /** Widget control form - for widget options */ function form($old_instance=array()){ $defaults=array( @@ -255,5 +261,425 @@ function wassup_compat_register_widget($widget_class){ wp_register_widget_control($wassup_widgets[$widget_class]->id,$wassup_widgets[$widget_class]->name,array(&$wassup_widgets[$widget_class],'form'),$wassup_widgets[$widget_class]->control_options); } } -} //end if Wassup_Widget +} //end if wpversion < 2.8 +if(version_compare($php_vers,'5.2','<')){ +/** + * Current Visitors Online widget + * - Show counts of visitors currently browsing your site. + */ +class wassup_onlineWidget extends Wassup_Widget{ + function __construct(){ + $widget_id="wassup_online"; + $widget_name='WassUp '.__("Online","wassup"); + $widget_description= __("Show counts of your site's visitors who are currently online.","wassup"); + $widget_opts=array('description'=>$widget_description,'classname'=>"wassup-widget"); + $control_opts=array('description'=>$widget_description); + //instantiate parent + parent::__construct($widget_id,$widget_name,$widget_opts,$control_opts); + } + /** PHP4-compatible constructor */ + function wassup_onlinewidget(){ + $this->__construct(); + } + /** Widget control form - for widget options */ + function form($old_instance=array()){ + $defaults=array( + 'online_title'=>__("Online Now","wassup"), + 'online_total'=>1, + 'online_loggedin'=>0, + 'online_comauth'=>0, + 'online_anonymous'=>0, + 'online_other'=>0, + 'show_usernames'=>0, + 'show_flags'=>0, + 'refresh'=>60, + ); + $instance=$this->wassup_parse_args($old_instance,$defaults); + $checked='checked="checked"'; + $disabled='disabled="disabled"'; + echo "\n";?> +
cleanFormText($new_instance['online_title']):""); + $instance['online_total']=(isset($new_instance['online_total'])?(int)$new_instance['online_total']:"0"); + $instance['online_loggedin']=(isset($new_instance['online_loggedin'])?(int)$new_instance['online_loggedin']:"0"); + $instance['online_comauth']=(isset($new_instance['online_comauth'])?(int)$new_instance['online_comauth']:"0"); + $instance['online_anonymous']=(isset($new_instance['online_anonymous'])?(int)$new_instance['online_anonymous']:"0"); + $instance['online_others']=(isset($new_instance['online_others'])?(int)$new_instance['online_others']:"0"); + $instance['show_usernames']=(isset($new_instance['show_usernames'])?(int)$new_instance['show_usernames']:0); + $instance['show_flags']=(isset($new_instance['show_flags'])?(int)$new_instance['show_flags']:0); + $instance['chars']=(int)$new_instance['chars']; + $instance['ulclass']=$wassup_options->cleanFormText($new_instance['ulclass']); + $instance['wassup_widget_id']=$new_instance['wassup_widget_id']; + //purge widget cache to apply new settings + wassup_widget_clear_cache($instance['wassup_widget_id']); + } + return $instance; + } //end update + + /** displays widget content on web site */ + function widget($wargs,$instance=array()){ + global $wp_version,$wassup_options,$wdebug_mode; + $widget_opt=$wargs; + if(empty($instance['wassup_widget_id'])) $instance=$this->wassup_get_widget_id($instance); + $wassup_widget_id=$instance['wassup_widget_id']; + //get widget head and foot content + $title=((!empty($instance['online_title']))?trim($instance['online_title']):""); + $ulclass=""; + $widget_title=""; + if(!empty($title)) $widget_title=$widget_opt['before_title'].esc_attr($title).$widget_opt['after_title']; + if(!empty($instance['ulclass'])) $ulclass=' class="'.$instance['ulclass'].'"'; + $widget_head=' + '.$widget_title; + $widget_foot=wassup_widget_foot_meta(); + $html=""; + //get widget main content + //...1st check for cached widget content + if(!empty($instance['show_usernames']) && is_user_logged_in()){ + $cache_key="_online_users"; + }else{ + //don't show usernames to regular visitors + $cache_key="_online"; + $instance['show_usernames']=0; + } + if($wdebug_mode){ + echo "\n"; + echo "\n"; + } + $refresh=(isset($instance['refresh']) && is_numeric($instance['refresh'])?(int)$instance['refresh']:60); + if($refresh >0) $html=wassup_widget_get_cache($wassup_widget_id,$cache_key); + //...get new widget content + if(empty($html)){ + if($wassup_options->is_recording_active()){ + $html=wassup_widget_get_online_counts($instance); + //cache the new widget content + if($refresh >0){ + $cacheid=wassup_widget_save_cache($html,$wassup_widget_id,$cache_key,$refresh); + } + }else{ + $html=' +network_activated_plugin()){ + echo __("Enables visitor tracking on all subsites in network.","wassup"); + }else{ + echo __("Enables visitor tracking on the network subsites where plugin is activated.","wassup"); + } + echo " ".__("Do NOT disable unless upgrading plugin.","wassup"); + ?>
/>
diff --git a/lib/uadetector.class.php b/lib/uadetector.class.php
index e419809..b3f4929 100644
--- a/lib/uadetector.class.php
+++ b/lib/uadetector.class.php
@@ -1,12 +1,12 @@
is_browser=false;
$this->is_mobile=false;
$this->is_robot=false;
@@ -116,6 +116,8 @@ function uadetector($ua=""){
unset($this->_done_browsers,$this->_done_spiders,$this->is_active_agent);
return;
} //end function __construct
+/** PHP4-compatible constructor */
+function uadetector($ua=""){$this->__construct($ua);}
/**
* Check user agent against a known list of top user agents
diff --git a/lib/upgrade.php b/lib/upgrade.php
index ac39cf1..3b83597 100644
--- a/lib/upgrade.php
+++ b/lib/upgrade.php
@@ -697,7 +697,7 @@ function wassup_updateTable($wtable=""){
} //end if 1.9
//For all upgrades:
- // New in v1.9.4: get a new api key
+ // get a new api key @since v1.9.4
if(empty($wassup_options->wassup_googlemaps_key)){
if(!empty($low_priority)){
wp_schedule_single_event(time()+600,'wassup_scheduled_api_upg');
diff --git a/lib/wassup.class.php b/lib/wassup.class.php
index fbd6391..54ce007 100644
--- a/lib/wassup.class.php
+++ b/lib/wassup.class.php
@@ -63,7 +63,7 @@ class wassupOptions {
var $wassup_refspam = "1";
var $wassup_attack = "1";
var $wassup_hack = "1";
- var $refspam_whitelist=""; //new in v1.9.4: for incorrectly labeled referrer spam
+ var $refspam_whitelist=""; //for incorrectly labeled referrer spam @since v1.9.4
/* table/file management settings */
var $wassup_table;
@@ -92,17 +92,17 @@ class wassupOptions {
var $wassup_upgraded = 0; //upgrade timestamp @since v1.9
/**
- * PHP4 constructor.
- *
+ * constructor.
* optional argument to set default values for new/empty class vars @since v1.9
* @param boolean $add_defaults
- * @return void
- *
*/
- public function wassupoptions($add_defaults=false){
+ public function __construct($add_defaults=false){
if($add_defaults)$this->_initSettings();
else $this->loadSettings();
}
+ public function wassupoptions($add_defaults=false){
+ self::__construct($add_defaults);
+ }
/** loads current settings/initializes empty class vars. */
private function _initSettings(){
$settings=$this->getSettings(true);
@@ -639,7 +639,7 @@ public function cleanFormText($input){
else $text=strip_tags(html_entity_decode(wp_kses($input,array())));
//only alphanumeric chars allowed with few exceptions
//since v1.9.3 allow '@' char for email searches
- //v1.9.4 bugfix: allow '/?&=' chars for url searches
+ //since v1.9.4 allow '/?&=' chars for url searches
$cleantext=preg_replace('#([^0-9a-z\-_\.,\:\*\#/&\?=@\'" ]+)#i','',$text);
return $cleantext;
}
@@ -2088,8 +2088,8 @@ static function export_records($table,$start_id,$wherecondition,$dtype="sql"){
$table_create=$result[0][1];
$sql_header="#\n# " . sprintf(__('Table structure of table %s','wassup'),esc_attr($table))."\n#\n";
$sql_header .= preg_replace(array('/^CREATE\sTABLE\s(IF\sNOT\sEXISTS\s)?/i', '/AUTO_INCREMENT\=\d+\s/i'),array('CREATE TABLE IF NOT EXISTS ',''),$table_create).' ;';
- $sql_header .= "\n#\n# ".sprintf(__('Data contents of table %s','wassup'),esc_attr($table))."\n#\n";
}
+ $sql_header .= "\n#\n# ".sprintf(__('Data contents of table %s','wassup'),esc_attr($table))."\n#\n";
}
//set starting rec id of export query
if(empty($start_id) || !is_numeric($start_id)){
@@ -2163,7 +2163,7 @@ static function export_records($table,$start_id,$wherecondition,$dtype="sql"){
//write sql header
fwrite($output,$sql_header);
$i=0;
- //field list for sql-insert
+ //make a field list for sql-insert statement in output below
$sql_fields="INSERT INTO `".esc_attr($table).'` (';
foreach($fields AS $col){
if(empty($wassup_options->export_omit_recid) || $col != 'id'){
diff --git a/lib/wassupadmin.php b/lib/wassupadmin.php
index a9850ce..373252d 100644
--- a/lib/wassupadmin.php
+++ b/lib/wassupadmin.php
@@ -259,7 +259,7 @@ function wSelfRefresh(){location.reload(true)}