#NEWLINE# def get_XPAT( self , group_name , header , pattern , start_id , end_id = 'ggg' ) : #NEWLINE# #INDENT# forum_id = self . get_forum ( group_name ) #NEWLINE# prefix = settings . phpbb_table_prefix #NEWLINE# stmt = ( "\n                SELECT\n                    A.post_id,\n                    A.topic_id,\n                    C.username,\n                    C.user_email,\n                    CASE WHEN B.post_subject = '' THEN CONCAT('Re: ', D.topic_title) ELSE B.post_subject END,\n                    A.post_time,\n                    B.post_text,\n                    A.post_username\n                FROM\n                    %sposts A, \n                    %sposts_text B\n                LEFT JOIN\n                    %susers C\n                ON\n                    A.poster_id=C.user_id\n                LEFT JOIN\n                    %stopics D\n                ON\n                    A.topic_id = D.topic_id\n                WHERE\n                    A.forum_id=%s AND\n                    %s REGEXP '%s' AND\n                    A.post_id = B.post_id AND\n                    A.post_id >= %s" % ( prefix , prefix , prefix , prefix , forum_id , header , strutil . format_wildcards ( pattern ) , start_id ) ) #NEWLINE# if ( end_id != 'ggg' ) : #NEWLINE# #INDENT# stmt = ( '%s AND A.post_id <= %s' % ( stmt , end_id ) ) #NEWLINE# #UNINDENT# num_rows = self . cursor . execute ( stmt ) #NEWLINE# if ( num_rows == 0 ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# result = list ( self . cursor . fetchall ( ) ) #NEWLINE# hdrs = [ ] #NEWLINE# for row in result : #NEWLINE# #INDENT# if ( header . upper ( ) == 'SUBJECT' ) : #NEWLINE# #INDENT# hdrs . append ( ( '%s %s' % ( row [ 0 ] , row [ 4 ] ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( header . upper ( ) == 'FROM' ) : #NEWLINE# #INDENT# hdrs . append ( ( '%s %s <%s>' % ( row [ 0 ] , row [ 2 ] , row [ 3 ] ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( header . upper ( ) == 'DATE' ) : #NEWLINE# #INDENT# hdrs . append ( ( '%s %s' % ( row [ 0 ] , strutil . get_formatted_time ( time . localtime ( result [ 5 ] ) ) ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( header . upper ( ) == 'MESSAGE-ID' ) : #NEWLINE# #INDENT# hdrs . append ( ( '%s <%s@%s>' % ( row [ 0 ] , row [ 0 ] , group_name ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( header . upper ( ) == 'REFERENCES' ) and ( row [ 1 ] != 0 ) ) : #NEWLINE# #INDENT# hdrs . append ( ( '%s <%s@%s>' % ( row [ 0 ] , row [ 1 ] , group_name ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( header . upper ( ) == 'BYTES' ) : #NEWLINE# #INDENT# hdrs . append ( ( '%s %s' % ( row [ 0 ] , len ( row [ 6 ] ) ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( header . upper ( ) == 'LINES' ) : #NEWLINE# #INDENT# hdrs . append ( ( '%s %s' % ( row [ 0 ] , len ( row [ 6 ] . split ( '\n' ) ) ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( header . upper ( ) == 'XREF' ) : #NEWLINE# #INDENT# hdrs . append ( ( '%s %s %s:%s' % ( row [ 0 ] , settings . nntp_hostname , group_name , row [ 0 ] ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if ( len ( hdrs ) == 0 ) : #NEWLINE# #INDENT# return '' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return '\r\n' . join ( hdrs )