Commit JeLuF's register_globals fixes, first phase
[lhc/web/wiklou.git] / includes / SpecialRecentchangeslinked.php
1 <?
2 include_once( "SpecialRecentchanges.php" );
3
4 function wfSpecialRecentchangeslinked( $par = NULL )
5 {
6 global $wgUser, $wgOut, $wgLang, $wgTitle;
7 global $days, $target, $hideminor; # From query string
8 $days = $_REQUEST["days"];
9 $hideminor = $_REQUEST["hideminor"];
10 $from = $_REQUEST["from"];
11
12 $fname = "wfSpecialRecentchangeslinked";
13
14 $wgOut->setPagetitle( wfMsg( "recentchanges" ) );
15 $sk = $wgUser->getSkin();
16
17 if( $par ) {
18 $target = $par;
19 }
20 if ( "" == $target ) {
21 $wgOut->errorpage( "notargettitle", "notargettext" );
22 return;
23 }
24 $nt = Title::newFromURL( $target );
25 $wgOut->setSubtitle( wfMsg( "rclsub", $nt->getPrefixedText() ) );
26
27 if ( ! $days ) {
28 $days = $wgUser->getOption( "rcdays" );
29 if ( ! $days ) { $days = 7; }
30 }
31 $days = (int)$days;
32 list( $limit, $offset ) = wfCheckLimits( 100, "rclimit" );
33 $cutoff = wfUnix2Timestamp( time() - ( $days * 86400 ) );
34
35 if ( ! isset( $hideminor ) ) {
36 $hideminor = $wgUser->getOption( "hideminor" );
37 }
38 if ( $hideminor ) {
39 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchangeslinked" ),
40 WfMsg( "show" ), "target=" . wfEscapeHTML( $nt->getPrefixedURL() ) .
41 "&days={$days}&limit={$limit}&hideminor=0" );
42 } else {
43 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchangeslinked" ),
44 WfMsg( "hide" ), "target=" . wfEscapeHTML( $nt->getPrefixedURL() ) .
45 "&days={$days}&limit={$limit}&hideminor=1" );
46 }
47 if ( $hideminor ) {
48 $cmq = "AND cur_minor_edit=0";
49 } else { $cmq = ""; }
50
51 $sql = "SELECT cur_id,cur_namespace,cur_title,cur_user,cur_comment," .
52 "cur_user_text,cur_timestamp,cur_minor_edit,cur_is_new FROM links, cur " .
53 "WHERE cur_timestamp > '{$cutoff}' {$cmq} AND l_to=cur_id AND l_from='" .
54 wfStrencode( $nt->getPrefixedDBkey() ) . "' GROUP BY cur_id " .
55 "ORDER BY inverse_timestamp LIMIT {$limit}";
56 $res = wfQuery( $sql, DB_READ, $fname );
57
58 $note = wfMsg( "rcnote", $limit, $days );
59 $wgOut->addHTML( "<hr>\n{$note}\n<br>" );
60
61 $tu = "target=" . $nt->getPrefixedURL();
62 $note = rcDayLimitlinks( $days, $limit, "Recentchangeslinked", $tu );
63 $wgOut->addHTML( "{$note}\n" );
64
65 $s = $sk->beginRecentChangesList();
66 $count = wfNumRows( $res );
67
68 while ( $limit ) {
69 if ( 0 == $count ) { break; }
70 $obj = wfFetchObject( $res );
71 --$count;
72
73 $ts = $obj->cur_timestamp;
74 $u = $obj->cur_user;
75 $ut = $obj->cur_user_text;
76 $ns = $obj->cur_namespace;
77 $ttl = $obj->cur_title;
78 $com = $obj->cur_comment;
79 $me = ( $obj->cur_minor_edit > 0 );
80 $new = ( $obj->cur_is_new > 0 );
81
82 $s .= $sk->recentChangesLine( $ts, $u, $ut, $ns, $ttl, $com, $me, $new );
83 --$limit;
84 }
85 $s .= $sk->endRecentChangesList();
86
87 wfFreeResult( $res );
88 $wgOut->addHTML( $s );
89 }
90
91 ?>