function nsp_MySubstr($str, $x, $y = 0) { if($y == 0) $y = strlen($str) - $x; if(function_exists('mb_substr')) return mb_substr($str, $x, $y); else return substr($str, $x, $y); } // Not use!!! commented by chab /** * Check if the argument is an IP addresses * * @param ip the ip to check * @return TRUE if it is an ip */ // function nsp_CheckIP($ip) { // return ( ! preg_match( "/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/", $ip)) ? FALSE : TRUE; // } /** * Decode the given url * * @param out_url the given url to decode * @return the decoded url ****************************************/ function nsp_DecodeURL($out_url) { if($out_url == '') { $out_url=__('Page','newstatpress').": Home"; } if(substr($out_url,0,4)=="cat=") { $out_url=__('Category','newstatpress').": ".get_cat_name(substr($out_url,4)); } if(substr($out_url,0,2)=="m=") { $out_url=__('Calendar','newstatpress').": ".substr($out_url,6,2)."/".substr($out_url,2,4); } if(substr($out_url,0,2)=="s=") { $out_url=__('Search','newstatpress').": ".substr($out_url,2); } if(substr($out_url,0,2)=="p=") { $subOut=substr($out_url,2); $post_id_7 = get_post($subOut, ARRAY_A); $out_url = $post_id_7['post_title']; } if(substr($out_url,0,8)=="page_id=") { $subOut=substr($out_url,8); $post_id_7=get_page($subOut, ARRAY_A); $out_url = __('Page','newstatpress').": ".$post_id_7['post_title']; } return $out_url; } function nsp_URL() { $urlRequested = (isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '' ); if ( $urlRequested == "" ) { // SEO problem! $urlRequested = (isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"] : '' ); } if(substr($urlRequested,0,2) == '/?') { $urlRequested=substr($urlRequested,2); } if($urlRequested == '/') { $urlRequested=''; } return $urlRequested; } /** * Convert data us to default format di Wordpress * * @param dt: date to convert * @return converted data ****************************************************/ function nsp_hdate($dt = "00000000") { return mysql2date(get_option('date_format'), substr($dt,0,4)."-".substr($dt,4,2)."-".substr($dt,6,2)); } function newstatpress_hdate($dt = "00000000") { return mysql2date(get_option('date_format'), nsp_MySubstr($dt, 0, 4) . "-" . nsp_MySubstr($dt, 4, 2) . "-" . nsp_MySubstr($dt, 6, 2)); } //--------------------------------------------------------------------------- // GET DATA from visitors Functions //--------------------------------------------------------------------------- /**TODO clean $accepted * Extracts the accepted language from browser headers */ function nsp_GetLanguage($accepted){ if(isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])){ // Capture up to the first delimiter (, found in Safari) preg_match("/([^,;]*)/", $_SERVER["HTTP_ACCEPT_LANGUAGE"], $array_languages); // Fix some codes, the correct syntax is with minus (-) not underscore (_) return str_replace( "_", "-", strtolower( $array_languages[0] ) ); } return 'xx'; // Indeterminable language } // function nsp_GetLanguage($accepted) { // return substr($accepted,0,2); // } function nsp_GetQueryPairs($url){ $parsed_url = parse_url($url); $tab=parse_url($url); $host = $tab['host']; if(key_exists("query",$tab)){ $query=$tab["query"]; return explode("&",$query); } else {return null;} } /** * Get OS from the given argument * * @param arg the argument to parse for OS * @return the OS find in configuration file *******************************************/ function nsp_GetOs($arg) { global $newstatpress_dir; $arg=str_replace(" ","",$arg); $lines = file($newstatpress_dir.'/def/os.dat'); foreach($lines as $line_num => $os) { list($nome_os,$id_os)=explode("|",$os); if(strpos($arg,$id_os)===FALSE) continue; return $nome_os; // fount } return ''; } /** * Get OS logo from the given argument * * @param arg the argument to parse for OS * @return the OS find in configuration file *******************************************/ function nsp_GetOsImg($arg) { global $newstatpress_dir; $lines = file($newstatpress_dir.'/def/os.dat'); foreach($lines as $line_num => $os) { list($name_os,$id_os,$img_os)=explode("|",$os); if(strcmp($name_os,$arg)==0) return $img_os; } return ''; } /** * Get Browser from the given argument * * @param arg the argument to parse for Brower * @return the Browser find in configuration file ************************************************/ function nsp_GetBrowser($arg) { global $newstatpress_dir; $arg=str_replace(" ","",$arg); $lines = file($newstatpress_dir.'/def/browser.dat'); foreach($lines as $line_num => $browser) { list($nome,$id)=explode("|",$browser); if(strpos($arg,$id)===FALSE) continue; return $nome; // fount } return ''; } /** * Get Browser from the given argument * * @param arg the argument to parse for Brower * @return the Browser find in configuration file ************************************************/ function nsp_GetBrowserImg($arg) { global $newstatpress_dir; $lines = file($newstatpress_dir.'/def/browser.dat'); foreach($lines as $line_num => $browser) { list($name_browser,$id,$img_browser)=explode("|",$browser); //echo $name_browser; if(strcmp($name_browser,$arg)==0) return $img_browser; } return ''; } /** * Check if the given ip is to ban * * @param arg the ip to check * @return '' id the address is banned */ function nsp_CheckBanIP($arg){ global $newstatpress_dir; $lines = file($newstatpress_dir.'/def/banips.dat'); foreach($lines as $line_num => $banip) { if(strpos($arg,rtrim($banip,"\n"))===FALSE) continue; return ''; // this is banned } return $arg; } /** * Get the search engines * * @param refferer the url to test * @return the search engine present in the url */ function nsp_GetSE($referrer = null){ global $newstatpress_dir; $key = null; $lines = file($newstatpress_dir.'/def/searchengines.dat'); foreach($lines as $line_num => $se) { list($nome,$url,$key)=explode("|",$se); if(strpos($referrer,$url)===FALSE) continue; # find if $variables = nsp_GetQueryPairs(html_entity_decode($referrer)); $i = count($variables); while($i--){ $tab=explode("=",$variables[$i]); if($tab[0] == $key){return ($nome."|".urldecode($tab[1]));} } } return null; } /** * Get the spider from the given agent * * @param agent the agent string * @return agent the fount agent *************************************/ function nsp_GetSpider($agent = null){ global $newstatpress_dir; $agent=str_replace(" ","",$agent); $key = null; $lines = file($newstatpress_dir.'/def/spider.dat'); foreach($lines as $line_num => $spider) { list($nome,$key)=explode("|",$spider); if(strpos($agent,$key)===FALSE) continue; # fount return $nome; } return null; } /** * Get the previous month in 'YYYYMM' format * * @return the previous month */ function nsp_Lastmonth() { $ta = getdate(current_time('timestamp')); $year = $ta['year']; $month = $ta['mon']; --$month; // go back 1 month if( $month === 0 ): // if this month is Jan --$year; // go back a year $month = 12; // last month is Dec endif; // return in format 'YYYYMM' return sprintf( $year.'%02d', $month); } /** * Create or update the table * * @param action to do: update, create *************************************/ function nsp_BuildPluginSQLTable($action) { global $wpdb; global $wp_db_version; $table_name = nsp_TABLENAME; $charset_collate = $wpdb->get_charset_collate(); $index_list=array(array('Key_name'=>"spider_nation", 'Column_name'=>"(spider, nation)"), array('Key_name'=>"ip_date", 'Column_name'=>"(ip, date)"), array('Key_name'=>"agent", 'Column_name'=>"(agent)"), array('Key_name'=>"search", 'Column_name'=>"(search)"), array('Key_name'=>"referrer", 'Column_name'=>"(referrer)"), array('Key_name'=>"feed_spider_os", 'Column_name'=>"(feed, spider, os)"), array('Key_name'=>"os", 'Column_name'=>"(os)"), array('Key_name'=>"date_feed_spider", 'Column_name'=>"(date, feed, spider)"), array('Key_name'=>"feed_spider_browser", 'Column_name'=>"(feed, spider, browser)"), array('Key_name'=>"browser", 'Column_name'=>"(browser)") ); // Add by chab // IF the table is already created then DROP INDEX for update if ($action=='') $action='create'; $sql_createtable = " CREATE TABLE ". $table_name . " ( id mediumint(9) NOT NULL AUTO_INCREMENT, date int(8), time time, ip varchar(39), urlrequested varchar(250), agent varchar(250), referrer varchar(512), search varchar(250), nation varchar(2), os varchar(30), browser varchar(32), searchengine varchar(16), spider varchar(32), feed varchar(8), user varchar(16), timestamp timestamp DEFAULT 0, UNIQUE KEY id (id)"; if ($action=='create') { foreach ($index_list as $index) { $Key_name=$index['Key_name']; $Column_name=$index['Column_name']; $sql_createtable.=", INDEX $Key_name $Column_name"; } } elseif ($action=='update') { foreach ($index_list as $index) { $Key_name=$index['Key_name']; $Column_name=$index['Column_name']; if ($wpdb->query("SHOW INDEXES FROM $table_name WHERE Key_name ='$Key_name'")=='') { $sql_createtable.=",\n INDEX $Key_name $Column_name"; } } } $sql_createtable.=") $charset_collate;"; // echo $sql_createtable; if($wp_db_version >= 5540) $page = 'wp-admin/includes/upgrade.php'; else $page = 'wp-admin/upgrade'.'-functions.php'; require_once(ABSPATH . $page); dbDelta($sql_createtable); } /** * Get if this is a feed * * @param url the url to test * @return the kind of feed that is found *****************************************/ function nsp_IsFeed($url) { $tmp=get_bloginfo('rdf_url'); if ($tmp) { if (stristr($url,$tmp) != FALSE) { return 'RDF'; } } $tmp=get_bloginfo('rss2_url'); if ($tmp) { if (stristr($url,$tmp) != FALSE) { return 'RSS2'; } } $tmp=get_bloginfo('rss_url'); if ($tmp) { if (stristr($url,$tmp) != FALSE) { return 'RSS'; } } $tmp=get_bloginfo('atom_url'); if ($tmp) { if (stristr($url,$tmp) != FALSE) { return 'ATOM'; } } $tmp=get_bloginfo('comments_rss2_url'); if ($tmp) { if (stristr($url,$tmp) != FALSE) { return 'COMMENT'; } } $tmp=get_bloginfo('comments_atom_url'); if ($tmp) { if (stristr($url,$tmp) != FALSE) { return 'COMMENT'; } } if (stristr($url,'wp-feed.php') != FALSE) { return 'RSS2'; } if (stristr($url,'/feed/') != FALSE) { return 'RSS2'; } return ''; } /** * Insert statistic into the database * ************************************/ function nsp_StatAppend() { global $wpdb; $table_name = nsp_TABLENAME; global $userdata; global $_STATPRESS; wp_get_current_user(); $feed=''; // Time $timestamp = current_time('timestamp'); $vdate = gmdate("Ymd",$timestamp); $vtime = gmdate("H:i:s",$timestamp); $timestamp = date('Y-m-d H:i:s', $timestamp); // IP $ipAddress = $_SERVER['REMOTE_ADDR']; // BASIC detection -> to delete if it works // $ipAddress = htmlentities(nsp_GetUserIP()); // Is this IP blacklisted from file? if(nsp_CheckBanIP($ipAddress) == '') { return ''; } // Is this IP blacklisted from user? $to_ignore = get_option('newstatpress_ignore_ip', array()); foreach($to_ignore as $a_ip_range){ list ($ip_to_ignore, $mask) = @explode("/", trim($a_ip_range)); if (empty($mask)) $mask = 32; $long_ip_to_ignore = ip2long($ip_to_ignore); $long_mask = bindec( str_pad('', $mask, '1') . str_pad('', 32-$mask, '0') ); $long_masked_user_ip = ip2long($ipAddress) & $long_mask; $long_masked_ip_to_ignore = $long_ip_to_ignore & $long_mask; if ($long_masked_user_ip == $long_masked_ip_to_ignore) { return ''; } } if(get_option('newstatpress_cryptip')=='checked') { $ipAddress = crypt($ipAddress,nsp_TEXTDOMAIN); } // URL (requested) $urlRequested=nsp_URL(); if (preg_match("/.ico$/i", $urlRequested)) { return ''; } if (preg_match("/favicon.ico/i", $urlRequested)) { return ''; } if (preg_match("/.css$/i", $urlRequested)) { return ''; } if (preg_match("/.js$/i", $urlRequested)) { return ''; } if (stristr($urlRequested,"/wp-content/plugins") != FALSE) { return ''; } if (stristr($urlRequested,"/wp-content/themes") != FALSE) { return ''; } if (stristr($urlRequested,"/wp-admin/") != FALSE) { return ''; } $urlRequested=esc_sql($urlRequested); // Is a given permalink blacklisted? $to_ignore = get_option('newstatpress_ignore_permalink', array()); foreach($to_ignore as $a_filter){ if (!empty($urlRequested) && strpos($urlRequested, $a_filter) === 0) { return ''; } } $referrer = (isset($_SERVER['HTTP_REFERER']) ? htmlentities($_SERVER['HTTP_REFERER']) : ''); $referrer=esc_sql($referrer); $referrer=esc_html($referrer); $userAgent = (isset($_SERVER['HTTP_USER_AGENT']) ? htmlentities($_SERVER['HTTP_USER_AGENT']) : ''); $userAgent=esc_sql($userAgent); $userAgent=esc_html($userAgent); $spider=nsp_GetSpider($userAgent); if(($spider != '') and (get_option('newstatpress_donotcollectspider')=='checked')) { return ''; } # ininitalize to empty $searchengine=''; $search_phrase=''; if($spider != '') { $os=''; $browser=''; } else { // Trap feeds $feed=nsp_IsFeed(get_bloginfo('url').$_SERVER['REQUEST_URI']); // Get OS and browser $os=nsp_GetOs($userAgent); $browser=nsp_GetBrowser($userAgent); $exp_referrer=nsp_GetSE($referrer); if (isset($exp_referrer)) { list($searchengine,$search_phrase)=explode("|",$exp_referrer); } } // Country (ip2nation table) or language $countrylang=""; if($wpdb->get_var("SHOW TABLES LIKE 'ip2nation'") == 'ip2nation') { $sql='SELECT * FROM ip2nation WHERE ip < INET_ATON("'.$ipAddress.'") ORDER BY ip DESC LIMIT 0,1'; $qry = $wpdb->get_row($sql); $countrylang=$qry->country; } if($countrylang == '') { $countrylang=nsp_GetLanguage($_SERVER['HTTP_ACCEPT_LANGUAGE']); } // Auto-delete visits if... if(get_option('newstatpress_autodelete') != '') { $int = filter_var(get_option('newstatpress_autodelete'), FILTER_SANITIZE_NUMBER_INT); # secure action if ($int>=1) { $t=gmdate('Ymd', current_time('timestamp')-86400*$int*30); $results =$wpdb->query( "DELETE FROM " . $table_name . " WHERE date < '" . $t . "'"); } } // Auto-delete spiders visits if... if(get_option('newstatpress_autodelete_spiders') != '') { $int = filter_var(get_option('newstatpress_autodelete_spiders'), FILTER_SANITIZE_NUMBER_INT); # secure action if ($int>=1) { $t=gmdate('Ymd', current_time('timestamp')-86400*$int*30); $results =$wpdb->query( "DELETE FROM " . $table_name . " WHERE date < '" . $t . "' and feed='' and spider<>'' "); } } if ((!is_user_logged_in()) OR (get_option('newstatpress_collectloggeduser')=='checked')) { if (is_user_logged_in() AND (get_option('newstatpress_collectloggeduser')=='checked')) { $current_user = wp_get_current_user(); // Is a given name to ignore? $to_ignore = get_option('newstatpress_ignore_users', array()); foreach($to_ignore as $a_filter) { if ($current_user->user_login == $a_filter) { return ''; } } } if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) { nsp_BuildPluginSQLTable(); } $login = $userdata ? $userdata->user_login : null; $insert = "INSERT INTO " . $table_name . "( date, time, ip, urlrequested, agent, referrer, search, nation, os, browser, searchengine, spider, feed, user, timestamp ) VALUES ( '$vdate', '$vtime', '$ipAddress', '$urlRequested', '".addslashes(strip_tags($userAgent))."', '$referrer','" . addslashes(strip_tags($search_phrase))."', '".$countrylang."', '$os', '$browser', '$searchengine', '$spider', '$feed', '$login', '$timestamp' )"; $results = $wpdb->query( $insert ); } } add_action('send_headers', 'nsp_StatAppend'); /** * Generate the Ajax code for the given variable * * @param var variable to get * @param limit optional limit value for query * @param flag optional flag value for checked * @param url optional url address ************************************************/ function nsp_generateAjaxVar($var, $limit=0, $flag='', $url='') { global $newstatpress_dir; $res = "_ "; return $res; } /** * Return the expanded vars into the give code. API to use for users. */ function NewStatPress_Print($body='') { return nsp_ExpandVarsInsideCode($body); } /** * Expand vars into the give code * * @param body the code where to look for variables to expand * @return the modified code ************************************************************/ function nsp_ExpandVarsInsideCode($body) { global $wpdb; $table_name = nsp_TABLENAME; $vars_list=array('visits', 'yvisits', 'mvisits', 'wvisits', 'totalvisits', 'totalpageviews', 'todaytotalpageviews', 'alltotalvisits' ); # look for $vars_list foreach($vars_list as $var) { if(strpos(strtolower($body),"%$var%") !== FALSE) { $body = str_replace("%$var%", nsp_GenerateAjaxVar($var), $body); } } # look for %thistotalvisits% if(strpos(strtolower($body),"%thistotalvisits%") !== FALSE) { $body = str_replace("%thistotalvisits%", nsp_GenerateAjaxVar("thistotalvisits", 0, '', nsp_URL()), $body); } # look for %since% if(strpos(strtolower($body),"%since%") !== FALSE) { $qry = $wpdb->get_results( "SELECT date FROM $table_name ORDER BY date LIMIT 1; "); $body = str_replace("%since%", nsp_hdate($qry[0]->date), $body); } # look for %os% if(strpos(strtolower($body),"%os%") !== FALSE) { $userAgent = (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''); $os=nsp_GetOs($userAgent); $body = str_replace("%os%", $os, $body); } # look for %browser% if(strpos(strtolower($body),"%browser%") !== FALSE) { $browser=nsp_GetBrowser($userAgent); $body = str_replace("%browser%", $browser, $body); } # look for %ip% if(strpos(strtolower($body),"%ip%") !== FALSE) { $ipAddress = $_SERVER['REMOTE_ADDR']; $body = str_replace("%ip%", $ipAddress, $body); } # look for %visitorsonline% if(strpos(strtolower($body),"%visitorsonline%") !== FALSE) { $act_time = current_time('timestamp'); $from_time = date('Y-m-d H:i:s', strtotime('-4 minutes', $act_time)); $to_time = date('Y-m-d H:i:s', $act_time); $qry = $wpdb->get_results( "SELECT count(DISTINCT(ip)) AS visitors FROM $table_name WHERE spider='' AND feed='' AND date = '".gmdate("Ymd", $act_time)."' AND timestamp BETWEEN '$from_time' AND '$to_time'; "); $body = str_replace("%visitorsonline%", $qry[0]->visitors, $body); } # look for %usersonline% if(strpos(strtolower($body),"%usersonline%") !== FALSE) { $act_time = current_time('timestamp'); $from_time = date('Y-m-d H:i:s', strtotime('-4 minutes', $act_time)); $to_time = date('Y-m-d H:i:s', $act_time); $qry = $wpdb->get_results( "SELECT count(DISTINCT(ip)) AS users FROM $table_name WHERE spider='' AND feed='' AND date = '".gmdate("Ymd", $act_time)."' AND user<>'' AND timestamp BETWEEN '$from_time' AND '$to_time'; "); $body = str_replace("%usersonline%", $qry[0]->users, $body); } # look for %toppost% if(strpos(strtolower($body),"%toppost%") !== FALSE) { $qry = $wpdb->get_results( "SELECT urlrequested,count(*) AS totale FROM $table_name WHERE spider='' AND feed='' AND urlrequested LIKE '%p=%' GROUP BY urlrequested ORDER BY totale DESC LIMIT 1; "); $body = str_replace("%toppost%", nsp_DecodeURL($qry[0]->urlrequested), $body); } # look for %topbrowser% if(strpos(strtolower($body),"%topbrowser%") !== FALSE) { $qry = $wpdb->get_results( "SELECT browser,count(*) AS totale FROM $table_name WHERE spider='' AND feed='' GROUP BY browser ORDER BY totale DESC LIMIT 1; "); $body = str_replace("%topbrowser%", nsp_DecodeURL($qry[0]->browser), $body); } # look for %topos% if(strpos(strtolower($body),"%topos%") !== FALSE) { $qry = $wpdb->get_results( "SELECT os,count(*) AS totale FROM $table_name WHERE spider='' AND feed='' GROUP BY os ORDER BY totale DESC LIMIT 1; "); $body = str_replace("%topos%", nsp_DecodeURL($qry[0]->os), $body); } # look for %topsearch% if(strpos(strtolower($body),"%topsearch%") !== FALSE) { $qry = $wpdb->get_results( "SELECT search, count(*) AS csearch FROM $table_name WHERE search<>'' GROUP BY search ORDER BY csearch DESC LIMIT 1; "); $body = str_replace("%topsearch%", nsp_DecodeURL($qry[0]->search), $body); } return $body; } // TODO : if working, move the contents into the caller instead of this function /** * Get top posts * * @param limit: the number of post to show * @param showcounts: if checked show totals * @return result of extraction *******************************************/ function nsp_TopPosts($limit=5, $showcounts='checked') { return nsp_GenerateAjaxVar("widget_topposts", $limit, $showcounts); } /** * Build NewsStatPress Widgets: Stat and TopPosts * ************************************************/ function nsp_WidgetInit($args) { if ( !function_exists('wp_register_sidebar_widget') || !function_exists('wp_register_widget_control') ) return; // Statistics Widget control function nsp_WidgetStats_control() { global $nsp_widget_vars; $options = get_option('widget_newstatpress'); if ( !is_array($options) ) $options = array('title'=>'NewStatPress Stats', 'body'=>'Visits today: %visits%'); if ( isset($_POST['newstatpress-submit']) && $_POST['newstatpress-submit'] ) { $options['title'] = strip_tags(stripslashes($_POST['newstatpress-title'])); $options['body'] = stripslashes($_POST['newstatpress-body']); update_option('widget_newstatpress', $options); } $title = htmlspecialchars($options['title'], ENT_QUOTES); $body = htmlspecialchars($options['body'], ENT_QUOTES); // the form echo "

". __('Stats available: ', 'newstatpress') ."
"; foreach($nsp_widget_vars as $var) { echo "%$var[0]% "; _e($var[1], 'newstatpress'); echo " | "; } echo "

"; } function nsp_WidgetStats($args) { extract($args); $options = get_option('widget_newstatpress'); $title = $options['title']; $body = $options['body']; echo $before_widget; print($before_title . $title . $after_title); print nsp_ExpandVarsInsideCode($body); echo $after_widget; } wp_register_sidebar_widget('NewStatPress', 'NewStatPress Stats', 'nsp_WidgetStats'); wp_register_widget_control('NewStatPress', array('NewStatPress','widgets'), 'nsp_WidgetStats_control', 300, 210); // Top posts Widget control function nsp_WidgetTopPosts_control() { $options = get_option('widget_newstatpresstopposts'); if ( !is_array($options) ) { $options = array('title'=>'NewStatPress TopPosts', 'howmany'=>'5', 'showcounts'=>'checked'); } if ( isset($_POST['newstatpresstopposts-submit']) && $_POST['newstatpresstopposts-submit'] ) { $options['title'] = strip_tags(stripslashes($_POST['newstatpresstopposts-title'])); $options['howmany'] = stripslashes($_POST['newstatpresstopposts-howmany']); $options['showcounts'] = stripslashes($_POST['newstatpresstopposts-showcounts']); if($options['showcounts'] == "1") { $options['showcounts']='checked'; } update_option('widget_newstatpresstopposts', $options); } $title = htmlspecialchars($options['title'], ENT_QUOTES); $howmany = htmlspecialchars($options['howmany'], ENT_QUOTES); $showcounts = htmlspecialchars($options['showcounts'], ENT_QUOTES); // the form echo "

"; echo '

'; echo ''; } function nsp_WidgetTopPosts($args) { extract($args); $options = get_option('widget_newstatpresstopposts'); $title = htmlspecialchars($options['title'], ENT_QUOTES); $howmany = htmlspecialchars($options['howmany'], ENT_QUOTES); $showcounts = htmlspecialchars($options['showcounts'], ENT_QUOTES); echo $before_widget; print($before_title . $title . $after_title); print nsp_TopPosts($howmany,$showcounts); echo $after_widget; } wp_register_sidebar_widget('NewStatPress TopPosts', 'NewStatPress TopPosts', 'nsp_WidgetTopPosts'); wp_register_widget_control('NewStatPress TopPosts', array('NewStatPress TopPosts','widgets'), 'nsp_WidgetTopPosts_control', 300, 110); } add_action('plugins_loaded', 'nsp_WidgetInit'); function nsp_CalculateVariation($month,$lmonth) { $target = round($month / ( (date("d", current_time('timestamp')) - 1 + (date("H", current_time('timestamp')) + (date("i", current_time('timestamp')) + 1)/ 60.0) / 24.0)) * date("t", current_time('timestamp')) ); $monthchange = null; $added = null; if($lmonth <> 0) { $percent_change = round( 100 * ($month / $lmonth ) - 100,1); $percent_target = round( 100 * ($target / $lmonth ) - 100,1); if($percent_change >= 0) { $percent_change=sprintf("+%'04.1f", $percent_change); $monthchange = "($percent_change%)"; } else { $percent_change=sprintf("%'05.1f", $percent_change); $monthchange = "($percent_change%)"; } if($percent_target >= 0) { $percent_target=sprintf("+%'04.1f", $percent_target); $added = "($percent_target%)"; } else { $percent_target=sprintf("%'05.1f", $percent_target); $added = "($percent_target%)"; } } else { $monthchange = ""; $added = ""; } $calculated_result=array($monthchange,$target,$added); return $calculated_result; } function nsp_MakeOverview($print ='dashboard') { global $wpdb, $nsp_option_vars; $table_name = nsp_TABLENAME; $overview_table=''; global $nsp_option_vars; $offsets = get_option($nsp_option_vars['stats_offsets']['name']); // $since = NewStatPress_Print('%since%'); $since = nsp_ExpandVarsInsideCode('%since%'); $lastmonth = nsp_Lastmonth(); $thisyear = gmdate('Y', current_time('timestamp')); $thismonth = gmdate('Ym', current_time('timestamp')); $yesterday = gmdate('Ymd', current_time('timestamp')-86400); $today = gmdate('Ymd', current_time('timestamp')); $tlm[0]=substr($lastmonth,0,4); $tlm[1]=substr($lastmonth,4,2); $thisyearHeader = gmdate('Y', current_time('timestamp')); $lastmonthHeader = gmdate('M, Y',gmmktime(0,0,0,$tlm[1],1,$tlm[0])); $thismonthHeader = gmdate('M, Y', current_time('timestamp')); $yesterdayHeader = gmdate('d M', current_time('timestamp')-86400); $todayHeader = gmdate('d M', current_time('timestamp')); // build head table overview if ($print=='main') { //$overview_table.="

". __('Overview','newstatpress'). "

"; $overview_table.=""; } elseif ($print=='dashboard') { $overview_table.="
". __('Total since','newstatpress'). " ". __('This year','newstatpress'). " ". __('Last month','newstatpress'). " ". __('This month','newstatpress'). " ". __('Target This month','newstatpress'). " ". __('Yesterday','newstatpress'). " ". __('Today','newstatpress'). "
$since $thisyearHeader $lastmonthHeader $thismonthHeader $thismonthHeader $yesterdayHeader $todayHeader
"; } // build body table overview $overview_rows=array('visitors','visitors_feeds','pageview','feeds','spiders'); foreach ($overview_rows as $row) { switch($row) { case 'visitors' : $row2='DISTINCT ip'; $row_title=__('Visitors','newstatpress'); $sql_QueryTotal="SELECT count($row2) AS $row FROM $table_name WHERE feed='' AND spider=''"; break; case 'visitors_feeds' : $row2='DISTINCT ip'; $row_title=__('Visitors through Feeds','newstatpress'); $sql_QueryTotal="SELECT count($row2) AS $row FROM $table_name WHERE feed<>'' AND spider='' AND agent<>''"; break; case 'pageview' : $row2='date'; $row_title=__('Pageviews','newstatpress'); $sql_QueryTotal="SELECT count($row2) AS $row FROM $table_name WHERE feed='' AND spider=''"; break; case 'spiders' : $row2='date'; $row_title=__('Spiders','newstatpress'); $sql_QueryTotal="SELECT count($row2) AS $row FROM $table_name WHERE feed='' AND spider<>''"; break; case 'feeds' : $row2='date'; $row_title=__('Pageviews through Feeds','newstatpress'); $sql_QueryTotal="SELECT count($row2) AS $row FROM $table_name WHERE feed<>'' AND spider=''"; break; } // query requests $qry_total = $wpdb->get_row($sql_QueryTotal); $qry_tyear = $wpdb->get_row($sql_QueryTotal. " AND date LIKE '$thisyear%'"); if (get_option($nsp_option_vars['calculation']['name'])=='sum') { // alternative calculation by mouth: sum of unique visitors of each day $tot=0; $t = getdate(current_time('timestamp')); $year = $t['year']; $month = sprintf('%02d', $t['mon']); $day= $t['mday']; $totlm=0; for($k=$t['mon'];$k>0;$k--) { //current month } for($i=0;$i<$day;$i++) { $qry_daylmonth = $wpdb->get_row($sql_QueryTotal. " AND date LIKE '$lastmonth$i%'"); $qry_day=$wpdb->get_row($sql_QueryTotal. " AND date LIKE '$year$month$i%'"); $tot+=$qry_day->$row; $totlm+=$qry_daylmonth->$row; } // echo $totlm." ,"; $qry_tmonth->$row=$tot; $qry_lmonth->$row=$totlm; } else { // classic $qry_tmonth = $wpdb->get_row($sql_QueryTotal. " AND date LIKE '$thismonth%'"); $qry_lmonth = $wpdb->get_row($sql_QueryTotal. " AND date LIKE '$lastmonth%'"); } $qry_y = $wpdb->get_row($sql_QueryTotal. " AND date LIKE '$yesterday'"); $qry_t = $wpdb->get_row($sql_QueryTotal. " AND date LIKE '$today'"); $calculated_result=nsp_CalculateVariation($qry_tmonth->$row, $qry_lmonth->$row); switch($row) { case 'visitors' : $qry_total->$row=$qry_total->$row+$offsets['alltotalvisits']; break; case 'visitors_feeds' : $qry_total->$row=$qry_total->$row+$offsets['visitorsfeeds']; break; case 'pageview' : $qry_total->$row=$qry_total->$row+$offsets['pageviews']; break; case 'spiders' : $qry_total->$row=$qry_total->$row+$offsets['spy']; break; case 'feeds' : $qry_total->$row=$qry_total->$row+$offsets['pageviewfeeds']; break; } // build full current row $overview_table.=""; if ($print=='main') $overview_table.="\n"; if ($print=='main') $overview_table.="\n"; $overview_table.="\n"; $overview_table.="\n"; if ($print=='main') $overview_table.="\n"; $overview_table.="\n"; $overview_table.="\n"; $overview_table.=""; } if ($print=='dashboard'){ $overview_table.="
". __('M-1','newstatpress'). " ". __('M','newstatpress'). " ". __('Y','newstatpress'). " ". __('T','newstatpress'). "
$lastmonthHeader $thismonthHeader $yesterdayHeader $todayHeader
$row_title".$qry_total->$row."".$qry_tyear->$row."".$qry_lmonth->$row."".$qry_tmonth->$row. $calculated_result[0] ." $calculated_result[1] $calculated_result[2] ".$qry_y->$row."".$qry_t->$row."
"; } if ($print=='main'){ $overview_table.= "\n"; // print graph // last "N" days graph NEW $gdays=get_option('newstatpress_daysinoverviewgraph'); if($gdays == 0) { $gdays=20; } $start_of_week = get_option('start_of_week'); $maxxday = 0; for($gg=$gdays-1;$gg>=0;$gg--) { $date=gmdate('Ymd', current_time('timestamp')-86400*$gg); $qry_visitors = $wpdb->get_row("SELECT count(DISTINCT ip) AS total FROM $table_name WHERE feed='' AND spider='' AND date = '$date'"); $visitors[$gg] = $qry_visitors->total; $qry_pageviews = $wpdb->get_row("SELECT count(date) AS total FROM $table_name WHERE feed='' AND spider='' AND date = '$date'"); $pageviews[$gg]= $qry_pageviews->total; $qry_spiders = $wpdb->get_row("SELECT count(date) AS total FROM $table_name WHERE feed='' AND spider<>'' AND date = '$date'"); $spiders[$gg] = $qry_spiders->total; $qry_feeds = $wpdb->get_row("SELECT count(date) AS total FROM $table_name WHERE feed<>'' AND spider='' AND date = '$date'"); $feeds[$gg] = $qry_feeds->total; $total= $visitors[$gg] + $pageviews[$gg] + $spiders[$gg] + $feeds[$gg]; if ($total > $maxxday) $maxxday= $total; } if($maxxday == 0) { $maxxday = 1; } # Y $gd=(90/$gdays).'%'; $overview_graph=""; for($gg=$gdays-1;$gg>=0;$gg--) { $scale_factor=2; //2 : 200px in CSS $date=gmdate('Ymd', current_time('timestamp')-86400*$gg); $px_visitors = $scale_factor*(round($visitors[ $gg]*100/$maxxday)); $px_pageviews= $scale_factor*(round($pageviews[$gg]*100/$maxxday)); $px_spiders = $scale_factor*(round($spiders[ $gg]*100/$maxxday)); $px_feeds = $scale_factor*(round($feeds[ $gg]*100/$maxxday)); $px_white = $scale_factor*100 - $px_feeds - $px_spiders - $px_pageviews - $px_visitors; $overview_graph.="\n"; } $overview_graph.="
"; $overview_graph.="
"; if($start_of_week == gmdate('w',current_time('timestamp')-86400*$gg)) $overview_graph.="
"; else $overview_graph.="
"; $overview_graph.=gmdate('d', current_time('timestamp')-86400*$gg) . ' ' . gmdate('M', current_time('timestamp')-86400*$gg) . "
"; $overview_table=$overview_table.$overview_graph; } if ($print!=FALSE) print $overview_table; else return $overview_table; } register_activation_hook(__FILE__,'nsp_BuildPluginSQLTable'); ?> Myths About Women That Love Gender | UIL Pavia

Myths About Women That Love Gender

Myths About Women That Love Gender

I am thus grateful that individuals're getting more available about intercourse to be lifestyle, but there is nevertheless a longer method to get. There are a lot items that nevertheless place folks on side, intimately, and therefore becomes even more obvious when you are a sex-positive girl. Merely like we must flake out over worrying on the amount of people we are making love with, simply how much intercourse we are creating, the sort of gender we are creating, and whom we are creating they with we should also prevent jumping to presumptions about those who love gender. Specially women that tend to be available about this.

I am talking about, We like gender. And that I mention they, a whole lot. My buddies have now been at the mercy of all sorts of over-share and undesired details your can see right now, and tend to be extremely understanding of my personal mis-timed analingus reports at an elegant meal or discussing a little bit an excessive amount of by what her buddy wants during sex. And they are big. They really are. But group nonetheless think a variety of unusual options if you are available about gender. I am astonished during the results individuals switch to, items that haven't any actual fundamentals in such a thing I stated, but they are some warped extrapolation from myself only getting sincere on how much i really like carrying it out. Many of them tend to be sexist, very nearly of all of the of all of them include unpleasant. And I also'm over all of them.

Very listed below are misconceptions about lady exactly who like gender and just why you mustn't hold them

That Individuals've hentai pov porn Complete They With Really Folks

Therefore, i’m an advocate that is big of completely available and cool with what number of society you have got gender with, regardless of the quantity. But i am nonetheless amazed by exactly how numerous lovers user believe i have got. After all, I’m open about enjoying gender and attempting things that are new but i have never ever indicated a pursuit in setting up with lots of individuals. Nonetheless, just getting excited about gender ways folk often reckon that my personal amount of intimate associates are really in to the 100s. truly? After all, i am perhaps not against they, but I do not even have that point.

That People’re Not Safe

Or bad, that individuals’re “dirty”. This can be type of genuine across both men and women, but much more when it comes down to ladies. Passionate gender try somehow connected with are careless (because i have to end up being very careless to wish end cooking a pie and grab my petticoat off while having gender, best?) and also risky. Only with a lot of people or that we’re not having safe sex because we love sex doesn’t mean we’re doing it.

That People Love One-Night Stands

I assume it is the way that is only may have have intercourse with all the 10,000 user i suppose i have boned. Although I essentially never, previously, actually ever point out one-night stands, and usually mention just how fantastic buddies with advantages could be, men usually presume we’m entirely upwards for one-night stands. If that is their thing, fantastic, but it is not mine just because i love gender. As being a woman that is sex-positive just how much gender you are creating and just how most associates you have had. You are undertaking your, and this’s what is crucial.

We Have Actually Insecurity

Or father problem. Or something like that. We’re able ton’t merely, you understand, like gender because we love sex. Given that it seems remarkable and it is awesome enjoyable and we’re naturally disposed to believe it is such as the thing that is best actually. Best. I am talking about, it could happen. There are lots of individuals who make use of flirtation or sex to complete a emptiness, and I also believe just about everybody has become that individual at once or any other. However a complete good deal of men and women are only gladly sex-positive.

That Individuals’re Not Love Product

This can be probably the grossest and a lot of sexist of the great deal. You understand precisely what i am writing about, guys will get aside with creating a lot of sexual associates. In case you are a lady available about liking intercourse and folks imagine you are making love with a lot of folks in addition they believe you aren’t really really worth online dating, as you’re sullied or something like that they seems dreadful. It really is dreadful. Folks are typically truly shocked once they see I got significant relations and this i have long come loyal. It really is insulting. Furthermore, would not the greatest individual to stay a commitment with become a person who enjoys intercourse? #justsaying

That Individuals’re Ultra Perverted

OK so I type of am. But it doesn’t suggest folks which enjoys sex was kinky some individuals are extremely enthusiastic concerning the position that is missionary!

That People Have Questionable Morals

Along with the social group we are making love with, if you should be a lady whom really likes gender you need to be therefore out of hand that you do not worry about starting up with folks with men, or spouses, or your own pal’s exes. Or that people consistently hack on men and women. Its junk and once more, a actually insulting presumption.

That Individuals’re Usually Making Love

Therefore, reasonable adequate we speak about intercourse like 9percent of that time. But it doesn’t suggest i am constantly creating they. Some ladies who like intercourse do not fundamentally have actually sex that is high, they truly are simply really like they if they would contain it and are generally available about this. They are doing what exactly is perfect for all of them. You will find a sex that is massively high but nonetheless proceed through dry spells therefore intense that my personal genitals was basically a tumbleweed produced of rips. Nothing for this ‘girls can invariably become put’ rubbish.

That Individuals’re Acting To Wow Folk

Whenever we’re perhaps perhaps perhaps not carrying it out for low self-esteem, we are simply implementing a “cool chick” people to wow other people . Best. I am able to just imagine those who think this are experiencing truly awful intercourse and don’t understand just exactly just how amazing it really is by itself. There’s really no want to imagine.

10. That People Has Minimum Requirements

Hey, I like making love. Great intercourse. Therefore the initiate aided by the people i am having they with, cool?

Need a lot more of Bustle’s Intercourse and connections insurance? Always check our video out on gender roles to create him stay longer below:

Scrivi un commento

L'indirizzo email non sarà pubblicato.


*