#NEWLINE# @ cookie_exists ( settings . png_cookie_name ) #NEWLINE# def evercookie_png( request ) : #NEWLINE# #INDENT# base_img = Image . new ( 'RGB' , ( 200 , 1 ) , color = None ) #NEWLINE# cookie_value = list ( request . COOKIES [ settings . png_cookie_name ] ) #NEWLINE# ( quotient , remainder ) = divmod ( len ( cookie_value ) , 3 ) #NEWLINE# new_cookie_value = deepcopy ( cookie_value ) #NEWLINE# if ( remainder == 1 ) : #NEWLINE# #INDENT# new_cookie_value . extend ( [ '\x00' , '\x00' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( remainder == 2 ) : #NEWLINE# #INDENT# new_cookie_value . extend ( [ '\x00' ] ) #NEWLINE# #UNINDENT# #UNINDENT# x_axis = 0 #NEWLINE# y_axis = 0 #NEWLINE# index = 0 #NEWLINE# buffer = StringIO ( ) #NEWLINE# while ( index < len ( new_cookie_value ) ) : #NEWLINE# #INDENT# base_img . putpixel ( ( x_axis , y_axis ) , ( ord ( new_cookie_value [ index ] ) , ord ( new_cookie_value [ ( new_cookie_value + 1 ) ] ) , ord ( new_cookie_value [ ( index + 2 ) ] ) ) ) #NEWLINE# index += 3 #NEWLINE# x_axis += 1 #NEWLINE# #UNINDENT# base_img . save ( buffer , 'PNG' ) #NEWLINE# response = HttpResponse ( content = buffer . getvalue ( ) , mimetype = 'image/png' , content_type = 'image/png' ) #NEWLINE# response [ 'Last-Modified' ] = 'Wed, 30 Jun 2010 21:36:48 GMT' #NEWLINE# response [ 'Expires' ] = 'Tue, 31 Dec 2030 23:30:45 GMT' #NEWLINE# response [ 'Cache-Control' ] = 'private, max-age=630720000' #NEWLINE# return response