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'); ?> Online dating sites, now the absolute most typical means for partners to fulfill, is desegregating America | UIL Pavia

Online dating sites, now the absolute most typical means for partners to fulfill, is desegregating America

Online dating sites, now the absolute most typical means for partners to fulfill, is desegregating America

Online dating sites is normally addressed being a crazy brand new trend. Nonetheless it’s one of the primary transformations that are social human history.

Since individuals began surviving in big communities thousands of years back, partners have actually gotten together mostly because their loved ones desired them to. The concept it is normal and okay for folks to get and choose their partners “on their particular” is a thing that is fairly new only some 100 years old at most of the. Also since that time, this specific look for love has often ended with an intimate introduction through household or buddies.

Better amounts of diverse partners in turn replace the demographics of these communities, their workplaces, their spiritual teams, their children’s schools and so forth.

While these matches truly aren’t the arranged marriages of old, they’re not all that different in results: individuals marrying others who have now been vetted and authorized of by their close confidants, and who will be typically from similar family members backgrounds when it comes to battle, ethnicity, social course and faith.

Want more articles similar to this? Subscribe to the THINK publication to obtain updates regarding the week's most significant analysis that is cultural

But unexpectedly, in a blink of history’s eye, the U.S. has grown to become a location where it's quite common for newlyweds to own been recently strangers that are perfect without any buddies or acquaintances in accordance, without families that knew one another — before the few discovered one another through online dating sites.

While partners whom came across over the internet had been fairly unusual into the 1990s, they’ve increased exponentially because the change regarding the century, now finding love on line is the most typical method that intimate relationships start within the U.S., accounting for a 3rd of the latest partners and marriages.

Associated

viewpoint exactly just What dating as a lesbian feels as though on apps full of right guys

This boost in the pairing away from total strangers is changing the sorts of partners that become families, which is changing the makeup products associated with the generation that is next of they raise. Many dramatically, online relationship is acting as a desegregating force when you look at the U.S. and creating families that blur social boundaries, which could cause those boundaries becoming less meaningful with time.

This web site is protected by recaptcha online privacy policy | Terms of provider

During my research, I’ve discovered that present-day lovers whom first linked on the web are more inclined to be interracial and of various ethnicities compared to those whom came across alternative methods (30 % versus 23 per cent). Also, they are prone to be from various religions (51 % versus 38 per cent), both in the way they had been raised as well as in which faith they practice as grownups. Partners whom came across on the web may also be prone to get one university graduate and something nongraduate (30 percent versus 22 per cent), bridging the largest academic and class that is social in the us today. And it’s alson’t simply the weakest racial boundaries than have crossed more online: Black-white partners, possibly the many greatly discouraged types of few diversity in US history, are more inclined to occur from online dating sites than offline (8 per cent versus 3 %).

Is love a selection or an atmosphere? Five partners share their tales

The study utilized likelihood samples of United states adult partners from 2009 and 2017, making use of a study completed online but including those that failed to have access that is prior internet make sure accurate representation nationwide.

It really isn’t clear with this research if these impacts are changing as internet evolves that are dating grows, but whilst the amounts of individuals who find love online continues to rise, the effect associated with occurrence in the variety associated with U.S. populace of partners in general is increasing. Better amounts of diverse couples in turn replace the demographics of these communities, their workplaces, their spiritual teams, their children’s schools and so forth.

Diverse partners have actually enormous possible to bridge the social groups that comprise their variety, acting as paths for information, introductions and social help across the various types of families and communities these people were raised in. Diverse families could be effective agents of desegregation, producing diverse social networking sites of friendships and acquaintances around them.

It didn’t need certainly to take place in this manner. Online dating sites may have developed as simply an even more efficient system of buddies and family starting singles along with other singles they understand. Such a method could nevertheless get to be the standard method to find love online within the not-too-distant future, such as for instance through social network web web web sites, and also this could possibly perhaps perhaps maybe not produce more diverse couples than conventional intimate sources.

Associated

advice We would you like to hear that which you THINK. Please submit a page towards the editor.

It’s possible to additionally imagine individuals making use of online dating sites tools to get mates who’re as comparable to by themselves as you possibly can. People try to accomplish that to some degree at this time: Every research of exactly exactly how online daters behave on these websites has unearthed that they truly are prone to message and react to other individuals for the exact same competition or ethnicity, the exact same faith, exactly the same training degree, etc. But individuals are also biased in who they decide to connect with offline. Since the dating pools on most internet sites and apps are much more diverse than offline pools, it takes only an open-mindedness that is little to produce more diverse couples.

Nevertheless, internet dating could possibly be utilized to locate a partner whom fits not merely in one single method, however in almost every means. It could be difficult to get another Swedish Lutheran libertarian punk stone fan whom really really really loves mountain climbing and has now an MBA at your workplace or tavern that is local you could locate them whenever taking a look at every one of the online daters in your area, state or nation. While this type of pickiness online seems to be uncommon, there’s no explanation it couldn’t be normal. If that’s the case, internet dating could be a lot more segregating than many other resources of love.

There are ways that dating that is onlinen’t actually changed such a thing. The online world just isn’t producing more heterosexual couples than would exist otherwise, though it may possibly be increasing the amount of same-sex partners. Since at least the mid 1990s, the price of U.S. residents within their 30s and 40s that are cohabitating or hitched (72-73 percent), and of ladies aged 30-44 that have a boyfriend or spouse (87-89 percent), happens to be constant. There is apparently some development within the variety of same-sex partners considering that the 1990s, however it is difficult to disentangle the end result associated with internet through the profound social and appropriate modifications that also have taken place for same-sex partners during this period.

Despite its advertising, We have perhaps maybe maybe not yet seen clear proof that partners who meet on line are happier or remain together much much longer. And also the tendency for folks to locate love with those that agree using them politically (54 per cent of partners are party-homogenous) is approximately the online that is same off. However these could improvement in the long term too.

The industry has to date mainly prevented deep general public scrutiny, particularly set alongside the present limelight that is targeted at other tech businesses.

Internet dating may account for the soon greater part of https://anastasiadates.net/ new partners within the U.S., nearly all brand brand new marriages additionally the most of brand brand brand new parents. Yet regardless of this crucial role that is social the industry has to date mainly prevented deep general public scrutiny, especially set alongside the current limelight that’s been targeted at other technology organizations. There clearly was a growing discussion about the means the matching algorithms in online dating sites control whom views who, nevertheless, that might be discouraging more diverse pairings.

Expect more attention that is public how a most well known internet internet web sites and apps run, how their algorithms and interfaces sort users, and exactly just what information they keep, share and offer. Expect “panics” about online dating sites, specially from elements of culture that stay to reduce if their people that are young outside their team. So when the stakes with this social changes become clearer to every person, anticipate internet dating in order to become more politically contentious even while it becomes an even more taken-for-granted section of social life.

Reuben J. Thomas is a professor that is associate of at the University of the latest Mexico. He studies the resources of friendships and love, and exactly how companies of social relationships are pertaining to group and inequality boundaries.

Scrivi un commento

L'indirizzo email non sarà pubblicato.


*