From 4f3bce79bfb5851cef9e7bc655c91bb3093cc401 Mon Sep 17 00:00:00 2001 From: donncha Date: Tue, 12 Jul 2005 11:27:54 +0000 Subject: Initial Import git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1 7be80a69-a1ef-0310-a953-fb0f7c49ff36 --- .../smarty-plugins/function.popularposts.php | 80 ++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 wp-inst/wp-content/smarty-plugins/function.popularposts.php (limited to 'wp-inst/wp-content/smarty-plugins/function.popularposts.php') diff --git a/wp-inst/wp-content/smarty-plugins/function.popularposts.php b/wp-inst/wp-content/smarty-plugins/function.popularposts.php new file mode 100644 index 0000000..4a66e32 --- /dev/null +++ b/wp-inst/wp-content/smarty-plugins/function.popularposts.php @@ -0,0 +1,80 @@ +get_results($sql); + if( $results ) + { + reset( $results ); + while( list( $key, $t ) = each( $results ) ) + { + if( substr( $t->visitURL, -9 ) == 'index.php' ) + $t->visitURL = substr( $t->visitURL, 0, -9 ); + $hits[ $t->visitURL ] += $t->c; + } + arsort( $hits ); + $hits = array_flip( $hits ); + reset( $hits ); + while( list( $key, $val ) = each( $hits ) ) + { + if( substr( $val, -1 ) == '/' ) + { + $post_name = substr( $val, 0, -1 ); + $post_name = substr( $post_name, strrpos( $post_name, '/' ) + 1 ); + $sql = "SELECT post_title + FROM ".$wpdb->posts." + WHERE post_name = '".$post_name."'"; + $results = $wpdb->get_results($sql); + if( $results ) + { + $links[ $key ] = array( "url" => $val, "title" => stripslashes( $results[0]->post_title ) ); + } + } + } + } + else + { + $links = false; + } + + return $links; +} + +function smarty_function_popularposts($params, &$smarty) +{ + global $wpblog; + extract( $params ); + + if( @include_once( "Cache/Function.php" ) ) + { + $cache = new Cache_Function( 'file', array('cache_dir' => ABSPATH . "/wp-content/smarty-cache", 'filename_prefix' => 'popularposts_cache_' ), 3600 ); + $links = $cache->call( "getlinks", $wpblog ); + } + else + { + $links = getlinks( $wpblog, $site ); + } + + $smarty->assign( "pposts", $links ); +} +?> -- cgit