root/releases/0.8/allpostssummary.php

Revision 1024, 0.9 kB (checked in by ben, 2 years ago)

All posts summary, for people who don't want to use RSS.

Line 
1 <?php
2
3 //let's include the basic stuff
4 require_once("includes.php");
5 global $CFG;
6
7 if (!$CFG->walledgarden) {
8
9     $limit = optional_param('limit',3,PARAM_INT);
10     
11 // query the database directly:
12 $posts = get_records_sql('SELECT wp.ident, u.name, u.username, wp.body, wp.title, wp.ident as postid, wp.posted
13 FROM '.$CFG->prefix.'weblog_posts wp
14 LEFT JOIN '.$CFG->prefix.'users u ON u.ident = wp.weblog
15 WHERE wp.access = "PUBLIC"
16 ORDER BY wp.posted DESC LIMIT ' . $limit);
17
18 foreach ($posts as $post) {
19     
20     $body = strip_tags($post->body);
21     $body = preg_replace( "|\w{3,10}://[\w\.\-_]+(:\d+)?[^\s\"\'<>\(\)\{\}]*|", "", $body);
22     $date = date("D, d M Y",$post->posted);
23     $output .= <<< END
24     
25     <p><b><a href="{$CFG->wwwroot}{$post->username}/weblog/{$post->postid}.html">{$post->title}</a></b><br />{$date}</p>
26     
27 END;
28
29 }
30 }   
31
32
33 echo $output;
34 ?>
Note: See TracBrowser for help on using the browser.