Ver código fonte

Anonym statt IP anzeigen

master
root 2 anos atrás
pai
commit
11d9457338
2 arquivos alterados com 181 adições e 177 exclusões
  1. BIN
      resources/images/default_s.gif
  2. 181
    177
      znilListAllComments.php

BIN
resources/images/default_s.gif Ver arquivo


+ 181
- 177
znilListAllComments.php Ver arquivo

@@ -1,177 +1,181 @@
1
-<?php
2
-/**
3
- * Comments of the Day parser hook -- shows the five newest comments that have
4
- * been sent within the last 24 hours.
5
- *
6
- * @file
7
- * @ingroup Extensions
8
- * @date 5 August 2011
9
- */
10
-if ( !defined( 'MEDIAWIKI' ) ) {
11
-	die();
12
-}
13
-
14
-$wgHooks['ParserFirstCallInit'][] = 'wfCommentsListAll';
15
-
16
-/**
17
- * Register the new <commentsAll /> parser hook with the Parser.
18
- *
19
- * @param $parser Parser: instance of Parser (not necessarily $wgParser)
20
- * @return Boolean: true
21
- */
22
-function wfCommentsListAll( &$parser ) {
23
-	$parser->setHook( 'commentsAll', 'getcommentsAll' );
24
-	return true;
25
-}
26
-
27
-/**
28
- * Get comments all -- 
29
- *
30
- * @return String: HTML
31
- */
32
-function getcommentsAll( $input, $args, $parser ) {
33
-	global $wgMemc, $wgUploadPath;
34
-
35
-	$oneDay = 60 * 60 * 24 * 50000;
36
-
37
-	// Try memcached first
38
-	$key = wfMemcKey( 'comments-all', 'standalone-hook' );
39
-	$data = $wgMemc->get( $key );
40
-
41
-	if( $data ) { // success, got it from memcached!
42
-		$commentsAll = $data;
43
-		//$dbr = wfGetDB( DB_SLAVE );
44
-	} elseif ( !$data || $args['nocache'] ) { // just query the DB
45
-		$dbr = wfGetDB( DB_SLAVE );
46
-
47
-		$res = $dbr->select(
48
-			array( 'Comments', 'page' ),
49
-			array(
50
-				'Comment_Username', 'comment_ip', 'comment_text',
51
-				'comment_date', 'Comment_user_id', 'CommentID',
52
-				'IFNULL(Comment_Plus_Count - Comment_Minus_Count,0) AS Comment_Score',
53
-				'Comment_Plus_Count AS CommentVotePlus',
54
-				'Comment_Minus_Count AS CommentVoteMinus',
55
-				'Comment_Parent_ID', 'page_title', 'page_namespace'
56
-			),
57
-			array(
58
-				'comment_page_id = page_id',
59
-				'UNIX_TIMESTAMP(comment_date) > ' . ( time() - ( $oneDay ) )
60
-			),
61
-			__METHOD__,
62
-			array( 'ORDER BY' => '(comment_date) DESC')
63
-		);
64
-
65
-		$commentsAll = array();
66
-		foreach ( $res as $row ) {
67
-			$commentsAll[] = array(
68
-				'username' => $row->Comment_Username,
69
-				'userid' => $row->Comment_user_id,
70
-				'score' => $row->CommentVotePlus,
71
-				'text' => $row->comment_text,
72
-				'id' => $row->CommentID,
73
-				'pagens' => $row->page_namespace,
74
-				'pagetitle' => $row->page_title,
75
-				'date' => $row->comment_date
76
-			);
77
-		}
78
-
79
-		$wgMemc->set( $key, $commentsAll, $oneDay );
80
-	}
81
-
82
-	$comments = '';
83
-
84
-	foreach ( $commentsAll as $commentsAllTemp ) {
85
-		$title2 = Title::makeTitle(
86
-			$commentsAllTemp['pagens'],
87
-			$commentsAllTemp['pagetitle']
88
-		);
89
-
90
-		if( $commentsAllTemp['userid'] != 0 ) {
91
-			$title = Title::makeTitle( NS_USER, $commentsAllTemp['username'] );
92
-			$commentPoster_Display = $commentsAllTemp['username'];
93
-			$commentPoster = '<a href="' . $title->getFullURL() .
94
-				'" title="' . $title->getText() . '" rel="nofollow">' .
95
-				$commentsAllTemp['username'] . '</a>';
96
-			//avatar = new wAvatar( $commentsAllTemp['userid'], 's' );
97
-			$commentIcon = 'extensions/Comments/images/default_s.gif';
98
-		} else {
99
-			$title = Title::makeTitle( NS_USER, $commentsAllTemp['username'] );
100
-			$commentPoster_Display = $commentsAllTemp['username'];
101
-			$commentPoster = '<a href="' . $title->getFullURL() .
102
-				'" title="' . $title->getText() . '" rel="nofollow">' .
103
-				$commentsAllTemp['username'] . '</a>';
104
-			//avatar = new wAvatar( $commentsAllTemp['userid'], 's' );
105
-			$commentIcon = 'extensions/Comments/images/default_s.gif';
106
-			
107
-			/*
108
-			$commentPoster_Display = wfMsg( 'comment-anon-name' );
109
-			$commentPoster = wfMsg( 'comment-anon-name' );
110
-			$commentIcon = '{$IP}/extensions/Comments/images/default_s.gif';
111
-			*/
112
-		}
113
-
114
-		// $comment_text = substr( $commentsAllTemp['text'], 0,  550 - strlen( $commentPoster_Display ) );
115
-		$comment_text = $commentsAllTemp['text'];
116
-		if( $comment_text != $commentsAllTemp['text'] ) {
117
-			$comment_text .= wfMsg( 'ellipsis' );
118
-		}
119
-		
120
-
121
-		$comments .= '<div style="width:90%;">';
122
-		$comments .= '<div style="float:left;width:220px;">';
123
-		$comments .= '<div style="float:left;width:20px;"><img src='. $commentIcon . ' alt="" align="middle" border="0"/></div>';
124
-		$comments .= '<div style="float:left;width:100px;"><span style="font-size: 70%">' . $commentsAllTemp['date'] . '</span> - </div>';
125
-		$comments .= '<div style="float:left;width:100px;"><span class="cod-poster">' . $commentPoster . ': </span></div></div>';
126
-		$comments .= '<div style="float:left;width:60%;">';
127
-		$comments .= '<div style="float:left;"><span class="cod-comment"><a href="' . 
128
-						$title2->getFullURL() . '#comment-' . $commentsAllTemp['id'] . 
129
-						'" title="' . $title2->getText() . '">' . '<span>' . $comment_text . '</span></a></div>';
130
-		$comments .= '</div><div style="clear:both;"></div></div><hr>';
131
-		
132
-//		$comments .= '<div class="cod">';
133
-//		$sign = '';
134
-//		/*if ( $commentsAllTemp['score'] > 0 ) {
135
-//			$sign = '+';
136
-//		} elseif ( $commentsAllTemp['score'] < 0 ) {
137
-//			$sign = '-'; // this *really* shouldn't be happening...
138
-//		}*/
139
-//		$comments .= '<div><span class="cod-score">' . $sign .
140
-//			'</span> <img src='. $commentIcon .
141
-//			'" alt="" align="middle" style="margin-bottom:8px; margin-right: 10px;" border="0"/>
142
-//			<span class="cod-poster"><span style="font-size: 70%">' . $commentsAllTemp['date'] . '</span> - ' . $commentPoster . ': </span>';
143
-//		$comments .= '<span class="cod-comment"><a href="' .
144
-//			$title2->getFullURL() . '#comment-' . $commentsAllTemp['id'] .
145
-//			'" title="' . $title2->getText() . '">' . '<span>' . $comment_text . '</span></div>' .
146
-//			'</a></span>';
147
-//		$comments .= '</div>';
148
-	}
149
-
150
-	$output = '';
151
-	if ( !empty( $comments ) ) {
152
-		$output .= $comments;
153
-	} else {
154
-		$output .= wfMsg( 'comments-no-comments-of-day' );
155
-	}
156
-
157
-	return $output;
158
-}
159
-
160
-
161
-
162
-
163
-
164
-
165
-
166
-
167
-
168
-
169
-
170
-
171
-
172
-
173
-
174
-
175
-
176
-
177
-
1
+<?php
2
+/**
3
+ * Comments of the Day parser hook -- shows the five newest comments that have
4
+ * been sent within the last 24 hours.
5
+ *
6
+ * @file
7
+ * @ingroup Extensions
8
+ * @date 5 August 2011
9
+ */
10
+if ( !defined( 'MEDIAWIKI' ) ) {
11
+	die();
12
+}
13
+
14
+$wgHooks['ParserFirstCallInit'][] = 'wfCommentsListAll';
15
+
16
+/**
17
+ * Register the new <commentsAll /> parser hook with the Parser.
18
+ *
19
+ * @param $parser Parser: instance of Parser (not necessarily $wgParser)
20
+ * @return Boolean: true
21
+ */
22
+function wfCommentsListAll( &$parser ) {
23
+	$parser->setHook( 'commentsAll', 'getcommentsAll' );
24
+	return true;
25
+}
26
+
27
+/**
28
+ * Get comments all -- 
29
+ *
30
+ * @return String: HTML
31
+ */
32
+function getcommentsAll( $input, $args, $parser ) {
33
+	global $wgMemc, $wgUploadPath;
34
+
35
+	$oneDay = 60 * 60 * 24 * 50000;
36
+
37
+	// Try memcached first
38
+	$key = wfMemcKey( 'comments-all', 'standalone-hook' );
39
+	$data = $wgMemc->get( $key );
40
+
41
+	if( $data ) { // success, got it from memcached!
42
+		$commentsAll = $data;
43
+		//$dbr = wfGetDB( DB_SLAVE );
44
+	} elseif ( !$data || $args['nocache'] ) { // just query the DB
45
+		$dbr = wfGetDB( DB_SLAVE );
46
+
47
+		$res = $dbr->select(
48
+			array( 'Comments', 'page' ),
49
+			array(
50
+				'Comment_Username', 'comment_ip', 'comment_text',
51
+				'comment_date', 'Comment_user_id', 'CommentID',
52
+				'IFNULL(Comment_Plus_Count - Comment_Minus_Count,0) AS Comment_Score',
53
+				'Comment_Plus_Count AS CommentVotePlus',
54
+				'Comment_Minus_Count AS CommentVoteMinus',
55
+				'Comment_Parent_ID', 'page_title', 'page_namespace'
56
+			),
57
+			array(
58
+				'comment_page_id = page_id',
59
+				'UNIX_TIMESTAMP(comment_date) > ' . ( time() - ( $oneDay ) )
60
+			),
61
+			__METHOD__,
62
+			array( 'ORDER BY' => '(comment_date) DESC')
63
+		);
64
+
65
+		$commentsAll = array();
66
+		foreach ( $res as $row ) {
67
+			$commentsAll[] = array(
68
+				'username' => $row->Comment_Username,
69
+				'userid' => $row->Comment_user_id,
70
+				'score' => $row->CommentVotePlus,
71
+				'text' => $row->comment_text,
72
+				'id' => $row->CommentID,
73
+				'pagens' => $row->page_namespace,
74
+				'pagetitle' => $row->page_title,
75
+				'date' => $row->comment_date
76
+			);
77
+		}
78
+
79
+		$wgMemc->set( $key, $commentsAll, $oneDay );
80
+	}
81
+
82
+	$comments = '';
83
+
84
+	foreach ( $commentsAll as $commentsAllTemp ) {
85
+		$title2 = Title::makeTitle(
86
+			$commentsAllTemp['pagens'],
87
+			$commentsAllTemp['pagetitle']
88
+		);
89
+
90
+		if( $commentsAllTemp['userid'] != 0 ) {
91
+			$title = Title::makeTitle( NS_USER, $commentsAllTemp['username'] );
92
+			$commentPoster_Display = $commentsAllTemp['username'];
93
+			$commentPoster = '<a href="' . $title->getFullURL() .
94
+				'" title="' . $title->getText() . '" rel="nofollow">' .
95
+				$commentsAllTemp['username'] . '</a>';
96
+			//avatar = new wAvatar( $commentsAllTemp['userid'], 's' );
97
+			$commentIcon = 'extensions/Comments/images/default_s.gif';
98
+		} else {
99
+			$title = Title::makeTitle( NS_USER, $commentsAllTemp['username'] );
100
+			$commentPoster_Display = $commentsAllTemp['username'];
101
+			$commentPoster = '<a href="' . $title->getFullURL() .
102
+				'" title="' . $title->getText() . '" rel="nofollow">' .
103
+				$commentsAllTemp['username'] . '</a>';
104
+			//avatar = new wAvatar( $commentsAllTemp['userid'], 's' );
105
+			$commentIcon = 'extensions/Comments/resources/images/default_s.gif';
106
+
107
+            if ( filter_var($commentPoster_Display, FILTER_VALIDATE_IP) !== false ){
108
+                // Wert ist eine IP-Adresse
109
+                $commentPoster = "Anonym";
110
+            }
111
+			/*
112
+			$commentPoster_Display = wfMsg( 'comment-anon-name' );
113
+			$commentPoster = wfMsg( 'comment-anon-name' );
114
+			$commentIcon = '{$IP}/extensions/Comments/images/default_s.gif';
115
+			*/
116
+		}
117
+
118
+		// $comment_text = substr( $commentsAllTemp['text'], 0,  550 - strlen( $commentPoster_Display ) );
119
+		$comment_text = $commentsAllTemp['text'];
120
+		if( $comment_text != $commentsAllTemp['text'] ) {
121
+			$comment_text .= wfMsg( 'ellipsis' );
122
+		}
123
+		
124
+
125
+		$comments .= '<div style="width:90%;">';
126
+		$comments .= '<div style="float:left;width:220px;">';
127
+		$comments .= '<div style="float:left;width:20px;"><img src='. $commentIcon . ' alt="" align="middle" border="0"/></div>';
128
+		$comments .= '<div style="float:left;width:100px;"><span style="font-size: 70%">' . $commentsAllTemp['date'] . '</span> - </div>';
129
+		$comments .= '<div style="float:left;width:100px;"><span class="cod-poster">' . $commentPoster . ': </span></div></div>';
130
+		$comments .= '<div style="float:left;width:60%;">';
131
+		$comments .= '<div style="float:left;"><span class="cod-comment"><a href="' . 
132
+						$title2->getFullURL() . '#comment-' . $commentsAllTemp['id'] . 
133
+						'" title="' . $title2->getText() . '">' . '<span>' . $comment_text . '</span></a></div>';
134
+		$comments .= '</div><div style="clear:both;"></div></div><hr>';
135
+		
136
+//		$comments .= '<div class="cod">';
137
+//		$sign = '';
138
+//		/*if ( $commentsAllTemp['score'] > 0 ) {
139
+//			$sign = '+';
140
+//		} elseif ( $commentsAllTemp['score'] < 0 ) {
141
+//			$sign = '-'; // this *really* shouldn't be happening...
142
+//		}*/
143
+//		$comments .= '<div><span class="cod-score">' . $sign .
144
+//			'</span> <img src='. $commentIcon .
145
+//			'" alt="" align="middle" style="margin-bottom:8px; margin-right: 10px;" border="0"/>
146
+//			<span class="cod-poster"><span style="font-size: 70%">' . $commentsAllTemp['date'] . '</span> - ' . $commentPoster . ': </span>';
147
+//		$comments .= '<span class="cod-comment"><a href="' .
148
+//			$title2->getFullURL() . '#comment-' . $commentsAllTemp['id'] .
149
+//			'" title="' . $title2->getText() . '">' . '<span>' . $comment_text . '</span></div>' .
150
+//			'</a></span>';
151
+//		$comments .= '</div>';
152
+	}
153
+
154
+	$output = '';
155
+	if ( !empty( $comments ) ) {
156
+		$output .= $comments;
157
+	} else {
158
+		$output .= wfMsg( 'comments-no-comments-of-day' );
159
+	}
160
+
161
+	return $output;
162
+}
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+
172
+
173
+
174
+
175
+
176
+
177
+
178
+
179
+
180
+
181
+

Carregando…
Cancelar
Salvar