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'); ?> Forms of Loans, Limits & Rates Of Interest | UIL Pavia

Forms of Loans, Limits & Rates Of Interest

Forms of Loans, Limits & Rates Of Interest

Provides interest that is low and tend to be accessible to pupils whom prove monetary need as based on the information and knowledge provided in the complimentary Application for Federal scholar help (FAFSA). The us government will pay the interest that is accruing the loan as the student is attending college at least half time or during deferment.

Offer low interest and they are offered to all pupils no matter economic need. The student’s interest begins to accrue through the date the mortgage is disbursed, and payment is delayed in the event that learning student posseses an in -school, elegance or deferment status.

If the accruing interest is maybe maybe not compensated, it is put into the main level of the mortgage while increasing the payment amount. Students have the choice of repaying interest since it accrues, decreasing the cost that is total of loan.

installment loans in kansas

Southwestern College will not be involved in the choice personal or loan that is PLUS.

Effective 2013-2014, Southwestern university happens to be approved by the United States Department of Education to take part in an initiative that is experimental reduce over -borrowing and chance of loan default. This permits us to get rid of Unsubsidized Loan eligibility for several categories of pupils. This choice is last and cannot be appealed to your United States Department of Education.

Predicated on this effort, the next kinds of students won’t be eligible for unsubsidized loans:

Federal Loan Limits

Yearly optimum loan limitations are based mostly on educational funding eligibility, dependency status and grade degree (including transfer units). A student’s status as being a reliant or separate depends upon information supplied by the student to your United States Department ofEducation in the FAFSA. Pupils that have “no need” (no financial aid need) and that do perhaps maybe not be eligible for the subsidized Loan maybe entitled to the unsubsidized Loan. See Annual and Aggregate Loan Limits below. Dependent pupils whoever FAFSA is rejectedbecause they would not add moms and dad information could be permitted to borrow as much as $2,000 for the educational 12 months from unsubsidizedloan only. This might be assuming the pupil is obviously entitled to borrow loan that is unsubsidizedsee Direct unsubsidized Loans above).

The loan that is minimum Southwestern university will certify is $100. Pupils with lower than $100 of eligibility shall maybe maybe not get that loan.

Annual and aggreggate loan limitations

Annual loan limits Subsidized optimum Combined Sub / Unsub maximum
level degree 1 (0 to 29.9 devices completed)* Dependent: $3,500Independent: $3,500 Dependent: $5,500Independent: $9,500
level level 2 (30 or higher units completed)* Dependent: $4,500Independent: $4,500 Dependent: $6,500Independent: $10,500
Aggregate loan limits Subsidized maximum Combined Sub / Unsub maximum
Dependent Students $23,000 $31,000
Independent Students $23,000 $57,500

*Grade level will be based upon units either obtained at Southwestern university or currently transferred and accepted to SouthwesternCollege. Students for who our records reveal significantly less than 30 units earned at Southwestern College or currently transmitted toSouthwestern College will undoubtedly be considered level degree 1 for loan purposes. Devices taken at other universities formerly rather than yettransferred to Southwestern university won’t be considered

ESI Loan Limits

Because of SWC’s involvement the Experimental web internet Sites Initiative (ESI – see above) listed here kinds of pupils won’t be qualified to receive unsubsidized loans: – 1st 12 months, California resident pupils – first 12 months is understood to be pupils that have completed not as much as 30 devices within their current program of research, of which 24 units should be level relevant. – pupils with aggregate loan financial obligation of $12,500 or maybe more – pupils that have lent subsidized and loans that are unsubsidized a combined total of $12,500 or higher (contains loans from all schools attended). – pupils with an authorized Satisfactory Academic Progress (SAP) appeal – students who were SAP disqualified, after which had been authorized for economic help on approved appeal.

Aggregate Loan Limits – Maximum Total Outstanding Loan Debt

Dependent Students $31,000 (optimum $23,000 subsidized)
Independent Students $57,500 (optimum $23,000 subsidized)

Subsidized Direct Loan Life Eligibility. Effective July 1, 2013, pupils that are considered brand new borrowers (pupils that have never ever lent a subsidized loan and people whom formerly borrowed and paid back a subsidized loan) may have a lifetime limitation on subsidized loan eligibility of 150% of the declared scholastic program. The 150% limitation is determined utilising the required timeframe for each student’s declared academic program. As an example, a pupil signed up for a two associate’s degree program will be limited to three years of subsidized loan eligibility year. As soon as a pupil reaches the 150% restriction, there is absolutely no further eligibility for subsidized loans at a two 12 months college. Pupils who transfer to a residential district university from a four year college and that have currently lent 36 months (or maybe more) of subsidized loans ahead of transfer have reached the 150% limitation and won’t be entitled to additional subsidized loans. Follow this link to learn more about the maximum time frame (calculated in educational years) that pupils can get DirectSubsidized Loans.

Interest Levels

The attention rates here are effective for several Direct Loans with a disbursement that is first or after July 1, 2019.

All direct Loans will be “variable-fixed, ” meaning students would receive a new rate with each new loan, but then that rate is to be fixed for the life of the loan under the new interest rate structure. There are additionally interest rate caps at 8.25% for Direct Subsidized Loans and Direct Unsubsidized Loans for undergraduate pupils.

The chart below shows the attention prices for Subsidized and Unsubsidized loan programs. Both forms of loans have actually the exact same repayment terms and interest levels are fixed prices for the lifetime of the mortgage.

First Disbursementon/After First DisbursementBefore 2019-20 FixedInterest Rate Interest RateCap
Direct subsidized loans 7/1/2019 7/1/2020 4.53% 8.25%
Direct loan that is unsubsidized 7/1/2020 4.53% 8.25%

Borrowers are required to spend an insurance and origination charge. These charges are deducted through the profits associated with the loan. For 2019-20 loans disbursed before October 1, 2019, the origination charge is 1.062%. For loans disbursed on or after 1, 2019, theorigination fee is 1.059% october. In case the loan is certified prior towards the October cost modification date, but can’t be disbursed just before October 1(ex. Missing note that is promissory Entrance Counseling maybe maybe not complete, etc. ), in that case your loan is supposed to be terminated and reinstated because of the newfees.

Scrivi un commento

L'indirizzo email non sarà pubblicato.


*